Skip to content
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/iam_policy_document: Keep empty conditions #17752

Merged
merged 3 commits into from
Feb 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/17752.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
data-source/aws_iam_policy_document: Keep empty conditions
```
2 changes: 1 addition & 1 deletion aws/data_source_aws_iam_policy_document.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ func dataSourceAwsIamPolicyDocumentMakeConditions(in []interface{}, version stri
Variable: item["variable"].(string),
}
out[i].Values, err = dataSourceAwsIamPolicyDocumentReplaceVarsInList(
aws.StringValueSlice(expandStringList(item["values"].([]interface{}))),
aws.StringValueSlice(expandStringListKeepEmpty(item["values"].([]interface{}))),
version,
)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions aws/data_source_aws_iam_policy_document_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ data "aws_iam_policy_document" "test" {
variable = "s3:prefix"
values = [
"home/",
"",
"home/&{aws:username}/",
]
}
Expand Down Expand Up @@ -394,6 +395,7 @@ func testAccAWSIAMPolicyDocumentExpectedJSON() string {
"StringLike": {
"s3:prefix": [
"home/",
"",
"home/${aws:username}/"
]
}
Expand Down
10 changes: 10 additions & 0 deletions aws/structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,16 @@ func expandStringList(configured []interface{}) []*string {
return vs
}

func expandStringListKeepEmpty(configured []interface{}) []*string {
vs := make([]*string, 0, len(configured))
for _, v := range configured {
if val, ok := v.(string); ok {
vs = append(vs, aws.String(val))
}
}
return vs
}

// Takes the result of flatmap.Expand for an array of int64
// and returns a []*int64
func expandInt64List(configured []interface{}) []*int64 {
Expand Down