diff --git a/.changelog/40253.txt b/.changelog/40253.txt new file mode 100644 index 000000000000..2e0a205feb8a --- /dev/null +++ b/.changelog/40253.txt @@ -0,0 +1,3 @@ +```release-note:bug +resource/aws_chatbot_slack_channel_configuration: Fix inconsistent provider result when order of `sns_topic_arns`changes +``` \ No newline at end of file diff --git a/internal/service/chatbot/slack_channel_configuration.go b/internal/service/chatbot/slack_channel_configuration.go index 06e5c259f305..472ea430539e 100644 --- a/internal/service/chatbot/slack_channel_configuration.go +++ b/internal/service/chatbot/slack_channel_configuration.go @@ -19,6 +19,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/listplanmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/setplanmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/types" @@ -64,9 +65,9 @@ func (r *slackChannelConfigurationResource) Schema(ctx context.Context, request Required: true, }, "guardrail_policy_arns": schema.ListAttribute{ - Optional: true, - Computed: true, - ElementType: types.StringType, + CustomType: fwtypes.ListOfStringType, + Optional: true, + Computed: true, PlanModifiers: []planmodifier.List{ listplanmodifier.UseStateForUnknown(), }, @@ -95,12 +96,12 @@ func (r *slackChannelConfigurationResource) Schema(ctx context.Context, request "slack_team_name": schema.StringAttribute{ Computed: true, }, - "sns_topic_arns": schema.ListAttribute{ - Optional: true, - Computed: true, - ElementType: types.StringType, - PlanModifiers: []planmodifier.List{ - listplanmodifier.UseStateForUnknown(), + "sns_topic_arns": schema.SetAttribute{ + CustomType: fwtypes.SetOfStringType, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), }, }, names.AttrTags: tftags.TagsAttribute(), @@ -218,7 +219,13 @@ func (r *slackChannelConfigurationResource) Update(ctx context.Context, request conn := r.Meta().ChatbotClient(ctx) - if slackChannelConfigurationHasChanges(ctx, new, old) { + diff, d := fwflex.Calculate(ctx, new, old) + response.Diagnostics.Append(d...) + if response.Diagnostics.HasError() { + return + } + + if diff.HasChanges() { input := &chatbot.UpdateSlackChannelConfigurationInput{} response.Diagnostics.Append(fwflex.Expand(ctx, new, input)...) if response.Diagnostics.HasError() { @@ -398,20 +405,20 @@ func waitSlackChannelConfigurationDeleted(ctx context.Context, conn *chatbot.Cli } type slackChannelConfigurationResourceModel struct { - ChatConfigurationARN types.String `tfsdk:"chat_configuration_arn"` - ConfigurationName types.String `tfsdk:"configuration_name"` - GuardrailPolicyARNs types.List `tfsdk:"guardrail_policy_arns"` - IAMRoleARN types.String `tfsdk:"iam_role_arn"` - LoggingLevel fwtypes.StringEnum[loggingLevel] `tfsdk:"logging_level"` - SlackChannelID types.String `tfsdk:"slack_channel_id"` - SlackChannelName types.String `tfsdk:"slack_channel_name"` - SlackTeamID types.String `tfsdk:"slack_team_id"` - SlackTeamName types.String `tfsdk:"slack_team_name"` - SNSTopicARNs types.List `tfsdk:"sns_topic_arns"` - Tags tftags.Map `tfsdk:"tags"` - TagsAll tftags.Map `tfsdk:"tags_all"` - Timeouts timeouts.Value `tfsdk:"timeouts"` - UserAuthorizationRequired types.Bool `tfsdk:"user_authorization_required"` + ChatConfigurationARN types.String `tfsdk:"chat_configuration_arn"` + ConfigurationName types.String `tfsdk:"configuration_name"` + GuardrailPolicyARNs fwtypes.ListValueOf[types.String] `tfsdk:"guardrail_policy_arns"` + IAMRoleARN types.String `tfsdk:"iam_role_arn"` + LoggingLevel fwtypes.StringEnum[loggingLevel] `tfsdk:"logging_level"` + SlackChannelID types.String `tfsdk:"slack_channel_id"` + SlackChannelName types.String `tfsdk:"slack_channel_name"` + SlackTeamID types.String `tfsdk:"slack_team_id"` + SlackTeamName types.String `tfsdk:"slack_team_name"` + SNSTopicARNs fwtypes.SetValueOf[types.String] `tfsdk:"sns_topic_arns"` + Tags tftags.Map `tfsdk:"tags"` + TagsAll tftags.Map `tfsdk:"tags_all"` + Timeouts timeouts.Value `tfsdk:"timeouts"` + UserAuthorizationRequired types.Bool `tfsdk:"user_authorization_required"` } func (data *slackChannelConfigurationResourceModel) InitFromID() error { @@ -434,17 +441,3 @@ func (loggingLevel) Values() []loggingLevel { loggingLevelNone, } } - -func slackChannelConfigurationHasChanges(_ context.Context, plan, state slackChannelConfigurationResourceModel) bool { - return !plan.ChatConfigurationARN.Equal(state.ChatConfigurationARN) || - !plan.ConfigurationName.Equal(state.ConfigurationName) || - !plan.GuardrailPolicyARNs.Equal(state.GuardrailPolicyARNs) || - !plan.IAMRoleARN.Equal(state.IAMRoleARN) || - !plan.LoggingLevel.Equal(state.LoggingLevel) || - !plan.SlackChannelID.Equal(state.SlackChannelID) || - !plan.SlackChannelName.Equal(state.SlackChannelName) || - !plan.SlackTeamID.Equal(state.SlackTeamID) || - !plan.SlackTeamName.Equal(state.SlackTeamName) || - !plan.SNSTopicARNs.Equal(state.SNSTopicARNs) || - !plan.UserAuthorizationRequired.Equal(state.UserAuthorizationRequired) -} diff --git a/internal/service/rds/cluster_test.go b/internal/service/rds/cluster_test.go index 5809dd64c20d..b7d937c83f72 100644 --- a/internal/service/rds/cluster_test.go +++ b/internal/service/rds/cluster_test.go @@ -581,7 +581,7 @@ func TestAccRDSCluster_storageTypeGeneralPurposeToProvisionedIOPS(t *testing.T) { Config: testAccClusterConfig_storageChange(rName, "gp3"), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(resourceName, "storage_type", "gp3"), + resource.TestCheckResourceAttr(resourceName, names.AttrStorageType, "gp3"), ), }, { diff --git a/internal/service/rds/instance.go b/internal/service/rds/instance.go index 9735d4b7846f..bfaf0c3a631f 100644 --- a/internal/service/rds/instance.go +++ b/internal/service/rds/instance.go @@ -2589,7 +2589,7 @@ func dbInstancePopulateModify(input *rds.ModifyDBInstanceInput, d *schema.Resour if slices.Contains([]string{storageTypeIO1, storageTypeIO2}, aws.ToString(input.StorageType)) { input.Iops = aws.Int32(int32(d.Get(names.AttrIOPS).(int))) - input.AllocatedStorage = aws.Int32(int32(d.Get("allocated_storage").(int))) + input.AllocatedStorage = aws.Int32(int32(d.Get(names.AttrAllocatedStorage).(int))) } }