Skip to content

Commit

Permalink
#5 store rds password arn in ssm parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
kunduso committed Aug 25, 2024
1 parent def3331 commit 3511ad3
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions ssm_parameter.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssm_parameter
resource "aws_ssm_parameter" "rds_secret_arn" {

Check failure on line 2 in ssm_parameter.tf

View workflow job for this annotation

GitHub Actions / scan

CKV_AWS_337: "Ensure SSM parameters are using KMS CMK"

Check failure on line 2 in ssm_parameter.tf

View workflow job for this annotation

GitHub Actions / scan

CKV_AWS_337: "Ensure SSM parameters are using KMS CMK"
name = "/${var.name}/rds-password-arn"
type = "SecureString"
value = aws_db_instance.postgresql.master_user_secret[0].secret_arn
}
#Create a policy to read from the specific parameter store
#https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy
resource "aws_iam_policy" "ssm_parameter_policy" {
name = "${var.name}-ssm-parameter-read-policy"
path = "/"
description = "Policy to read the RDS Password ARN stored in the SSM Parameter Store."
# Terraform's "jsonencode" function converts a
# Terraform expression result to valid JSON syntax.
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Effect = "Allow",
Action = [
"ssm:GetParameters",
"ssm:GetParameter"
],
Resource = [aws_ssm_parameter.rds_secret_arn.arn]
}
]
})
}

0 comments on commit 3511ad3

Please sign in to comment.