-
-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: define iam_policy_statements object syntax #26
feat: define iam_policy_statements object syntax #26
Conversation
8960d44
to
f9191c9
Compare
/terratest |
/terratest |
variables.tf
Outdated
type = string | ||
identifiers = list(string) | ||
})), []) | ||
}) | ||
description = "Map of IAM policy statements to use in the policy. This can be used with or instead of the `var.iam_source_json_url`." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change "Map of" to "Object describing"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change "Map of" to "Object describing"
@Nuru from what I can see - a map is expected here, so I fixed the variable definition.
variables.tf
Outdated
type = object({ | ||
sid = optional(string, "") | ||
effect = optional(string, "") | ||
actions = optional(list(string), []) | ||
not_actions = optional(list(string), []) | ||
resources = optional(list(string), []) | ||
not_resources = optional(list(string), []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Add
version
here and inmain.tf
. - Move statement components to list of objects.
- Inputs that are not going to be expanded into blocks by
dynamic
should default tonull
. - In
main.tf
, replace lookups like
lookup(statement.value, "sid", statement.key)
With direct references
statement.value.sid
type = object({ | |
sid = optional(string, "") | |
effect = optional(string, "") | |
actions = optional(list(string), []) | |
not_actions = optional(list(string), []) | |
resources = optional(list(string), []) | |
not_resources = optional(list(string), []) | |
type = object({ | |
version = optional(string, null) | |
statement = list(object({ | |
sid = optional(string, null) | |
effect = optional(string, null) | |
actions = optional(list(string), null) | |
not_actions = optional(list(string), null) | |
resources = optional(list(string), null) | |
not_resources = optional(list(string), null) | |
})), []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Nuru thanks a lot for your review!
- Version arguments should be set for data source
aws_iam_policy_document
, so I added it as a separate variable. - I updated statements to the map of objects - that's what is expected in the example.
- Inputs were updated.
- Lookups were replaced👍
Please let me know your thoughts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gberenice I forgot we want this to be backward compatible and that means the input is a map. I will take it from here. Thank you very much for your contributions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Nuru sounds good, thank you!
36cf1ff
to
43364f4
Compare
/terratest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please see comments
/terratest |
examples/complete/variables.tf
Outdated
@@ -8,8 +8,68 @@ variable "iam_source_json_url" { | |||
default = null | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please update the description for the iam_source_json_url
variable in the example as well
description = <<-EOT
URL of the IAM policy (in JSON format) to download and use as `source_json` argument.
This is useful when using a 3rd party service that provides their own policy.
This can be used with or instead of `var.iam_policy`.
EOT
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please see comment
/terratest |
what
iam_policy_statements
variable definition to take Terraform object with optional attributes rather thantype = any
. Provider version is bumped sinceoptional
, as a non-experimental feature, was introduced in 1.3.why
references