-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#5 store rds password arn in ssm parameter
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 GitHub Actions / scan
|
||
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] | ||
} | ||
] | ||
}) | ||
} |