-
Notifications
You must be signed in to change notification settings - Fork 2
/
iam_role.tf
56 lines (56 loc) · 1.72 KB
/
iam_role.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#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 ElastiCache endpoint and port number 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.elasticache_ep.arn, aws_ssm_parameter.elasticache_port.arn]
},
{
Effect = "Allow",
Action = [
"kms:Decrypt"
]
Resource = [aws_kms_key.encryption_rest.arn]
}
]
})
}
#https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy
resource "aws_iam_policy" "secret_manager_policy" {
name = "${var.name}-secret-read-policy"
path = "/"
description = "Policy to read the ElastiCache AUTH Token stored in AWS Secrets Manager secret."
# Terraform's "jsonencode" function converts a
# Terraform expression result to valid JSON syntax.
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Effect = "Allow",
Action = [
"secretsmanager:GetSecretValue"
]
Resource = [aws_secretsmanager_secret_version.auth.arn]
},
{
Effect = "Allow",
Action = [
"kms:Decrypt"
]
Resource = [aws_kms_key.encryption_secret.arn]
}
]
})
}