Skip to content

Commit

Permalink
Encrypt SSL SSM parameters with KMS CMK
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Carlucci committed Nov 28, 2023
1 parent 606aeb3 commit 82e46a1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions terraform/ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ data "aws_iam_policy_document" "hello_world_task_execution_role_policy" {
aws_ssm_parameter.app_ssl_cert.arn
]
}

statement {
actions = ["kms:Decrypt"]
effect = "Allow"
resources = [aws_kms_key.primary.arn]
}
}

resource "aws_iam_role_policy" "hello_world_task_execution_role_policy" {
Expand Down
4 changes: 4 additions & 0 deletions terraform/ssm.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
resource "aws_ssm_parameter" "app_ssl_key" {
description = "The self-signed SSL certificate key for the ECS application tasks."
key_id = aws_kms_key.primary.id

# Parameter name cannot start with "aws", so using the awkward /terraform namespace
name = "/terraform/${local.application_name}/${var.environment}/ssl-certificate-key"
type = "SecureString"
Expand All @@ -8,6 +10,8 @@ resource "aws_ssm_parameter" "app_ssl_key" {

resource "aws_ssm_parameter" "app_ssl_cert" {
description = "The self-signed SSL certificate for the ECS application tasks."
key_id = aws_kms_key.primary.id

# Parameter name cannot start with "aws", so using the awkward /terraform namespace
name = "/terraform/${local.application_name}/${var.environment}/ssl-certificate"
type = "SecureString"
Expand Down

0 comments on commit 82e46a1

Please sign in to comment.