Skip to content
Open
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/47474.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_kinesis_firehose_delivery_stream: Fix perpetual diff for `cloudwatch_logging_options` when `enabled` is `false`
```
27 changes: 23 additions & 4 deletions internal/service/firehose/delivery_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,23 @@ func resourceDeliveryStream() *schema.Resource {
MigrateState: MigrateState,
SchemaFunc: func() map[string]*schema.Schema {
cloudWatchLoggingOptionsSchema := func() *schema.Schema {
// diffSuppressCloudWatchLoggingOptionsDisabled suppresses diffs for
// log_group_name and log_stream_name when cloudwatch_logging_options
// is disabled (enabled = false). The AWS API returns empty strings for
// these fields when logging is disabled, causing a perpetual diff
// against user-specified values.
diffSuppressCloudWatchLoggingOptionsDisabled := func(k, old, new string, d *schema.ResourceData) bool {
// Derive the enabled key from the current attribute key path.
// k is like "...cloudwatch_logging_options.0.log_group_name",
// so we find the last dot and replace the field name with "enabled".
enabledKey := k[:strings.LastIndex(k, ".")] + "." + names.AttrEnabled
enabled, ok := d.GetOk(enabledKey)
if ok && enabled.(bool) {
return false
}
return true
}

return &schema.Schema{
Type: schema.TypeList,
MaxItems: 1,
Expand All @@ -111,12 +128,14 @@ func resourceDeliveryStream() *schema.Resource {
Default: false,
},
names.AttrLogGroupName: {
Type: schema.TypeString,
Optional: true,
Type: schema.TypeString,
Optional: true,
DiffSuppressFunc: diffSuppressCloudWatchLoggingOptionsDisabled,
},
"log_stream_name": {
Type: schema.TypeString,
Optional: true,
Type: schema.TypeString,
Optional: true,
DiffSuppressFunc: diffSuppressCloudWatchLoggingOptionsDisabled,
},
},
},
Expand Down