This module create a policy with dynamic statements
module "my_policy" {
source = "terraform-aws-policy"
policy_name = "my_policy"
policy_description = "my policy does something"
policy_document_id = "AllowSomething"
policy_body = {
statement1 = {
sid = "statement1",
effect = "Allow",
actions = ["s3:*"],
resources = ["*"],
conditions = [
{
test = "StringLike",
variable = "s3:prefix",
values = ["", "home/", "home/&{aws:username}/"]
}
] # One condition for this statement. More statement can be added in the list
},
statement2 = {
sid = "statement2",
effect = "Allow",
actions = ["ec2:*"],
resources = ["*"],
conditions = [] # No condition for this statement
},
}
}| Name | Version |
|---|---|
| terraform | ~> 0.13 |
| aws | ~> 3 |
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| policy_body | The body parameters of the policy. | map(object( |
n/a | yes |
| policy_name | The name of the policy. | string |
n/a | yes |
| policy_description | Description of the IAM policy. | string |
null |
no |
| policy_document_id | The id of the policy document. | string |
null |
no |
| policy_path | Path in which to create the policy. | string |
"/" |
no |
| Name | Description |
|---|---|
| policy_arn | Policy arn |
| policy_id | Policy id |
| policy_name | Policy name |