Skip to content

Commit e45ea2c

Browse files
authored
Merge pull request #43996 from tabito-hara/b-aws_chatbot_slack_channel_configuration-forcenew_configuration_name
[bugfix] aws_chatbot_slack_channel_configuration: Force resource replacement when configuration_name is modified
2 parents 9d7c39d + eadd113 commit e45ea2c

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

.changelog/43996.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
resource/aws_chatbot_slack_channel_configuration: Force resource replacement when `configuration_name` is modified
3+
```

internal/service/chatbot/slack_channel_configuration.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ func (r *slackChannelConfigurationResource) Schema(ctx context.Context, request
5959
"chat_configuration_arn": framework.ARNAttributeComputedOnly(),
6060
"configuration_name": schema.StringAttribute{
6161
Required: true,
62+
PlanModifiers: []planmodifier.String{
63+
stringplanmodifier.RequiresReplace(),
64+
},
6265
},
6366
"guardrail_policy_arns": schema.ListAttribute{
6467
CustomType: fwtypes.ListOfStringType,

internal/service/chatbot/slack_channel_configuration_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/aws/aws-sdk-go-v2/service/chatbot/types"
1515
sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
1616
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
17+
"github.com/hashicorp/terraform-plugin-testing/plancheck"
1718
"github.com/hashicorp/terraform-plugin-testing/terraform"
1819
"github.com/hashicorp/terraform-provider-aws/internal/acctest"
1920
"github.com/hashicorp/terraform-provider-aws/internal/conns"
@@ -46,6 +47,8 @@ func testAccSlackChannelConfiguration_basic(t *testing.T) {
4647

4748
var slackchannelconfiguration types.SlackChannelConfiguration
4849
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
50+
rNameUpdated := rName + "-updated"
51+
resourceName := testResourceSlackChannelConfiguration
4952

5053
// The slack workspace must be created via the AWS Console. It cannot be created via APIs or Terraform.
5154
// Once it is created, export the name of the workspace in the env variable for this test
@@ -81,6 +84,24 @@ func testAccSlackChannelConfiguration_basic(t *testing.T) {
8184
ImportStateVerify: true,
8285
ImportStateVerifyIdentifierAttribute: "chat_configuration_arn",
8386
},
87+
{
88+
Config: testAccSlackChannelConfigurationConfig_basic(rNameUpdated, channelID, teamID),
89+
ConfigPlanChecks: resource.ConfigPlanChecks{
90+
PreApply: []plancheck.PlanCheck{
91+
plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionDestroyBeforeCreate),
92+
},
93+
},
94+
Check: resource.ComposeTestCheckFunc(
95+
testAccCheckSlackChannelConfigurationExists(ctx, testResourceSlackChannelConfiguration, &slackchannelconfiguration),
96+
resource.TestCheckResourceAttr(testResourceSlackChannelConfiguration, "configuration_name", rNameUpdated),
97+
acctest.MatchResourceAttrGlobalARN(ctx, testResourceSlackChannelConfiguration, "chat_configuration_arn", "chatbot", regexache.MustCompile(fmt.Sprintf(`chat-configuration/slack-channel/%s`, rName))),
98+
resource.TestCheckResourceAttrPair(testResourceSlackChannelConfiguration, names.AttrIAMRoleARN, "aws_iam_role.test", names.AttrARN),
99+
resource.TestCheckResourceAttr(testResourceSlackChannelConfiguration, "slack_channel_id", channelID),
100+
resource.TestCheckResourceAttrSet(testResourceSlackChannelConfiguration, "slack_channel_name"),
101+
resource.TestCheckResourceAttr(testResourceSlackChannelConfiguration, "slack_team_id", teamID),
102+
resource.TestCheckResourceAttrSet(testResourceSlackChannelConfiguration, "slack_team_name"),
103+
),
104+
},
84105
},
85106
})
86107
}

0 commit comments

Comments
 (0)