forked from lfalorni/terraform-aws-lambda-graphql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsecretmanager.tf
32 lines (28 loc) · 1.04 KB
/
secretmanager.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
data "aws_secretsmanager_secret" "secret_manager" {
count = length(var.secret_managers)
name = var.secret_managers[count.index]
}
data "aws_iam_policy_document" "secrets_manager_get_secret" {
count = length(var.secret_managers)
statement {
sid = "AccessIndicatorsSecrets"
actions = [
"secretsmanager:GetSecretValue",
]
effect = "Allow"
resources = [
data.aws_secretsmanager_secret.secret_manager[count.index].arn
]
}
}
resource "aws_iam_policy" "secrets_manager_get_secret" {
count = length(var.secret_managers)
name = "${local.camel_app_name}SecretManager${title(var.stage)}-${var.secret_managers[count.index]}-graphql"
policy = data.aws_iam_policy_document.secrets_manager_get_secret[count.index].json
}
resource "aws_iam_role_policy_attachment" "secrets_manager_get_secret" {
count = length(var.secret_managers)
depends_on = [aws_iam_policy.secrets_manager_get_secret]
role = aws_iam_role.graphql_lambda_role.name
policy_arn = aws_iam_policy.secrets_manager_get_secret[count.index].arn
}