Skip to content

Commit

Permalink
filter out empty kafka actions when expanding
Browse files Browse the repository at this point in the history
  • Loading branch information
mbbush committed Aug 29, 2023
1 parent bda97bc commit cb90ca2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions internal/service/iot/topic_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -1676,28 +1676,38 @@ func expandKafkaAction(tfList []interface{}) *iot.KafkaAction {
if len(tfList) == 0 || tfList[0] == nil {
return nil
}
empty := true

apiObject := &iot.KafkaAction{}
tfMap := tfList[0].(map[string]interface{})

if v, ok := tfMap["client_properties"].(map[string]interface{}); ok && len(v) > 0 {
apiObject.ClientProperties = flex.ExpandStringMap(v)
empty = false
}

if v, ok := tfMap["destination_arn"].(string); ok && v != "" {
apiObject.DestinationArn = aws.String(v)
empty = false
}

if v, ok := tfMap["key"].(string); ok && v != "" {
apiObject.Key = aws.String(v)
empty = false
}

if v, ok := tfMap["partition"].(string); ok && v != "" {
apiObject.Partition = aws.String(v)
empty = false
}

if v, ok := tfMap["topic"].(string); ok && v != "" {
apiObject.Topic = aws.String(v)
empty = false
}

if empty {
return nil
}

return apiObject
Expand Down

0 comments on commit cb90ca2

Please sign in to comment.