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

fix: Add nil checks to fix perpetual diff of rule arg for aws_ce_cost_category #38449

Merged
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/38449.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_ce_cost_category: Fix perpetual diff with the `rule` argument on update
```
26 changes: 21 additions & 5 deletions internal/service/ce/cost_category.go
Original file line number Diff line number Diff line change
Expand Up @@ -716,9 +716,16 @@ func flattenCostCategoryRule(apiObject *awstypes.CostCategoryRule) map[string]in
tfMap := map[string]interface{}{}

tfMap["inherited_value"] = flattenCostCategoryInheritedValueDimension(apiObject.InheritedValue)
tfMap[names.AttrRule] = []interface{}{flattenExpression(apiObject.Rule)}

if v := apiObject.Rule; v != nil {
tfMap[names.AttrRule] = []interface{}{flattenExpression(apiObject.Rule)}
}

tfMap[names.AttrType] = string(apiObject.Type)
tfMap[names.AttrValue] = aws.ToString(apiObject.Value)

if v := apiObject.Value; v != nil {
tfMap[names.AttrValue] = aws.ToString(v)
}

return tfMap
}
Expand All @@ -745,7 +752,10 @@ func flattenCostCategoryInheritedValueDimension(apiObject *awstypes.CostCategory
var tfList []map[string]interface{}
tfMap := map[string]interface{}{}

tfMap["dimension_key"] = aws.ToString(apiObject.DimensionKey)
if v := apiObject.DimensionKey; v != nil {
tfMap["dimension_key"] = aws.ToString(v)
}

tfMap["dimension_name"] = string(apiObject.DimensionName)

tfList = append(tfList, tfMap)
Expand Down Expand Up @@ -797,7 +807,10 @@ func flattenCostCategoryValues(apiObject *awstypes.CostCategoryValues) []map[str
var tfList []map[string]interface{}
tfMap := map[string]interface{}{}

tfMap[names.AttrKey] = aws.ToString(apiObject.Key)
if v := apiObject.Key; v != nil {
tfMap[names.AttrKey] = aws.ToString(v)
}

tfMap["match_options"] = flex.FlattenStringyValueList(apiObject.MatchOptions)
tfMap[names.AttrValues] = apiObject.Values

Expand Down Expand Up @@ -831,7 +844,10 @@ func flattenTagValues(apiObject *awstypes.TagValues) []map[string]interface{} {
var tfList []map[string]interface{}
tfMap := map[string]interface{}{}

tfMap[names.AttrKey] = aws.ToString(apiObject.Key)
if v := apiObject.Key; v != nil {
tfMap[names.AttrKey] = aws.ToString(v)
}

tfMap["match_options"] = flex.FlattenStringyValueList(apiObject.MatchOptions)
tfMap[names.AttrValues] = apiObject.Values

Expand Down
Loading