Skip to content

Commit

Permalink
Merge pull request #19 from kunduso/add-to-parameter-store
Browse files Browse the repository at this point in the history
Created resources that enable access to Amazon ElastiCache
  • Loading branch information
kunduso authored Oct 29, 2023
2 parents ae7c9bf + f5bf1cb commit 77ac37d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
22 changes: 22 additions & 0 deletions iam_role.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#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 = "ssm_parameter_policy"
path = "/"
description = "Policy to read from 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.elasticache_ep.arn, aws_ssm_parameter.elasticache_port.arn]
}
]
})
}
13 changes: 13 additions & 0 deletions ssm_parameter.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssm_parameter
resource "aws_ssm_parameter" "elasticache_ep" {
name = "/elasticache/${aws_elasticache_replication_group.app4.replication_group_id}/endpoint"
type = "SecureString"
key_id = aws_kms_key.encrytion_rest.id
value = aws_elasticache_replication_group.app4.configuration_endpoint_address
}
resource "aws_ssm_parameter" "elasticache_port" {
name = "/elasticache/${aws_elasticache_replication_group.app4.replication_group_id}/port"
type = "SecureString"
key_id = aws_kms_key.encrytion_rest.id
value = aws_elasticache_replication_group.app4.port
}

0 comments on commit 77ac37d

Please sign in to comment.