Created
July 13, 2022 15:31
-
-
Save sergsoares/dde1c7614fbfc8c985483af030f5c03f to your computer and use it in GitHub Desktop.
Demonstração de ideia para criação de policies dinâmicas com attach em múltiplos users e roles.
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
# terraform.tfvars | |
policies = [ | |
{ | |
policy_name = "policy-alpha", | |
roles_to_attach = [] | |
users_to_attach = ["user1", "user2"] | |
content = {} | |
}, | |
{ | |
policy_name = "policy-beta", | |
roles_to_attach = [] | |
users_to_attach = ["user1", "user2"] | |
content = {} | |
} | |
] | |
# Resultado que eu gostaria de gerar atrávés de resources com count e usando local para pré-processar. | |
resource "aws_iam_policy" "policy" { | |
name = value["policy_alpha"] | |
policy = value["policy_alpha"].content | |
} | |
resource "aws_iam_policy" "policy" { | |
name = value["policy_beta"] | |
policy = value["policy_beta"].content | |
} | |
resource "aws_iam_user_policy_attachment" "attach_users" { | |
user = "policy_alpha" | |
policy_arn = "user1" | |
} | |
resource "aws_iam_user_policy_attachment" "attach_users" { | |
user = "policy_alpha" | |
policy_arn = "user2" | |
} | |
resource "aws_iam_user_policy_attachment" "attach_users" { | |
user = "policy_beta" | |
policy_arn = "user1" | |
} | |
resource "aws_iam_user_policy_attachment" "attach_users" { | |
user = "policy_beta" | |
policy_arn = "user2" | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment