Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add KMS resource and examples #6

Merged
merged 1 commit into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ inception_projects = [

# needed for staging (default) only:
include_inception_project = true

# aws kms encrypt --profile "${{values.organization_var}}-${{values.environment_var}}" --region=${{values.region_var}}--key-id alias/secrets --plaintext "PASSWORD" --output text --query CiphertextBlob
# aws kms decrypt --profile "${{values.organization_var}}-${{values.environment_var}}" --region=${{values.region_var}} --ciphertext-blob "PASSWORD"--output text --query Plaintext | base64 -d
38 changes: 38 additions & 0 deletions site_inception/kms.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Defines the KMS master key

resource "aws_kms_key" "secrets" {
description = "Master encryption key for secrets"
deletion_window_in_days = 7
enable_key_rotation = "true"

tags = {
ManagedByTerraform = "yes"
}

policy = <<EOF
{
"Version": "2012-10-17",
"Id": "key-allow-users",
"Statement": [
{
"Sid": "Enable IAM User Permissions",
"Effect": "Allow",
"Principal": {
"AWS": [
"arn:aws:iam::${data.aws_caller_identity.current.account_id}:root"
]
},
"Action": "kms:*",
"Resource": "*"
}
]
}
EOF
}

# Defines the easy access name of the KMS master key

resource "aws_kms_alias" "secrets" {
name = "alias/secrets"
target_key_id = aws_kms_key.secrets.key_id
}