-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
data-source/aws_iam_policy_document: Prevent panic when combining single principal identifier with multiple principal identifiers #10780
Conversation
…gle principal identifer with multiple principal identifiers Reference: #10777 Output from acceptance testing before fix: ``` === CONT TestAccAWSDataSourceIAMPolicyDocument_Statement_Principal_Identifiers_StringAndSlice panic: interface conversion: interface {} is string, not []string [recovered] panic: interface conversion: interface {} is string, not []string goroutine 254 [running]: encoding/json.(*encodeState).marshal.func1(0xc00158f5a8) /usr/local/Cellar/go/1.13.4/libexec/src/encoding/json/encode.go:305 +0x9a panic(0x5a68a40, 0xc000d48210) /usr/local/Cellar/go/1.13.4/libexec/src/runtime/panic.go:679 +0x1b2 github.com/terraform-providers/terraform-provider-aws/aws.IAMPolicyStatementPrincipalSet.MarshalJSON(0xc000a17580, 0x2, 0x2, 0x100c733, 0x5a73f60, 0x591b720, 0x7178801, 0xbbd7098) /Users/bflad/src/github.com/terraform-providers/terraform-provider-aws/aws/iam_policy_model.go:101 +0x866 ``` Output from acceptance testing after fix: ``` --- PASS: TestAccAWSDataSourceIAMPolicyDocument_Statement_Principal_Identifiers_StringAndSlice (10.23s) --- PASS: TestAccAWSDataSourceIAMPolicyDocument_noStatementMerge (10.26s) --- PASS: TestAccAWSDataSourceIAMPolicyDocument_basic (10.29s) --- PASS: TestAccAWSDataSourceIAMPolicyDocument_noStatementOverride (10.30s) --- PASS: TestAccAWSDataSourceIAMPolicyDocument_sourceConflicting (10.40s) --- PASS: TestAccAWSDataSourceIAMPolicyDocument_override (10.53s) --- PASS: TestAccAWSDataSourceIAMPolicyDocument_duplicateSid (11.02s) --- PASS: TestAccAWSDataSourceIAMPolicyDocument_Version_20081017 (14.87s) --- PASS: TestAccAWSDataSourceIAMPolicyDocument_source (15.20s) ```
Can confirm this fixes the issue I opened as well as the more complex config which was crashing. |
@bflad unfortunately there is still something funny going on with multiple principals data "aws_iam_policy_document" "some-policy" {
statement {
effect = "Allow"
actions = [
"*"
]
resources = [
"*",
]
principals {
identifiers = [
"arn:aws:iam::111111111111:root",
"arn:aws:iam::222222222222:root",
]
type = "AWS"
}
principals {
identifiers = [
"arn:aws:iam::333333333333:root",
]
type = "AWS"
}
principals {
identifiers = [
"arn:aws:iam::444444444444:root",
]
type = "AWS"
}
}
}
output "some-policy-json" {
value = data.aws_iam_policy_document.some-policy.json
} yields the following
|
The following fix works for me but I'm not that proficient in go so please check it carefully
|
Patch in previous comment is PR to this PR here with tests: #10844 |
…_document data-source/aws_iam_policy_document: support multiple princiapls in iam policy document without dropping some
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.
LGTM 👍
This has been released in version 2.37.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks! |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Community Note
Closes #10777
Release note for CHANGELOG:
Output from acceptance testing before fix:
Output from acceptance testing after fix: