Open dustyhorizon opened 1 year ago
Voting for Prioritization
Volunteering to Work on This Issue
Hey @dustyhorizon 👋 Thank you for taking the time to raise this! Can you give me a better idea of what you believe the resulting JSON would look like? I'm not quite following, and want to make sure I'm able to answer your question appropriately.
I have a similar confuse on this, for example:
data "aws_iam_policy_document" "override" {
statement {
sid = "SidToOverride"
actions = ["s3:*"]
resources = ["*"]
}
}
data "aws_iam_policy_document" "override_policy_document_example" {
override_policy_documents = [data.aws_iam_policy_document.override.json]
# NOTE: I want to override the principals and resources in the statement `SidToOverride`
statement {
sid = "SidToOverride"
principals {
type = "AWS"
identifiers = ["arn:aws:iam::123456789:role/developer"]
}
resources = [
"arn:aws:s3:::somebucket",
"arn:aws:s3:::somebucket/*",
]
}
}
data.override.aws_iam_policy_document.policy_document_example.json
actually generate the result without overrided principals and resources in the statement SidToOverride
:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "SidToOverride",
"Effect": "Allow",
"Action": "s3:*",
"Resource": "*"
}
]
}
here is the result what I expected:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "SidToOverride",
"Effect": "Allow",
"Action": "s3:*",
- "Resource": "*"
+ "Principal": {
+ "AWS": "arn:aws:iam::123456789:role/developer",
+ ],
+ "Resource": [
+ "arn:aws:s3:::somebucket",
+ "arn:aws:s3:::somebucket/*",
+ ]
}
]
}
maybe I misunderstand the usage, override_policy_documents
will override the entire statement by matching same sid, not just replace the partial fields. 🤔
I have exactly same problem. I'd like to provide ready made actions sets in module and let end user fill in resources list. Even add additional actions if needed. NOT replacing whole list.
Terraform Core Version
1.3.9
AWS Provider Version
4.55.0
Affected Resource(s)
aws_iam_policy_document
Expected Behavior
Per the documentations here I expected that resources with statements of a specific SID will override (merge) with the policies specific in
override_policy_documents
.Actual Behavior
Specifying the SID in the statement of the resource that is supposed to override one of the policy in
override_policy_documents
with the same SID does not does not seem to produce a "merged" policy.In fact, the documentations here also seem to suggest that "not merging" is the correct behavior ... unless the documentation is wrong too.
i.e. in the "combined" resource, I expected that the statement with SID
OverridePlaceHolderTwo
to result in policy witheffect = "Deny"
andactions = ["*"]
for that SID instead of the values from pre-merge / override.Relevant Error/Panic Output Snippet
No response
Terraform Configuration Files
Steps to Reproduce
terraform plan
json
output for the resultant document of the "combined" resourceDebug Output
No response
Panic Output
No response
Important Factoids
No response
References
No response
Would you like to implement a fix?
None