Skip to content

Commit

Permalink
r/cognito_resource_server allow name change without ForceNew
Browse files Browse the repository at this point in the history
  • Loading branch information
mbbush committed Mar 6, 2025
1 parent 63f21e9 commit eb0515b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
1 change: 0 additions & 1 deletion internal/service/cognitoidp/resource_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func resourceResourceServer() *schema.Resource {
names.AttrName: {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
names.AttrScope: {
Type: schema.TypeSet,
Expand Down
46 changes: 46 additions & 0 deletions internal/service/cognitoidp/resource_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,38 @@ func TestAccCognitoIDPResourceServer_scope(t *testing.T) {
})
}

func TestAccCognitoIDPResourceServer_nameChange(t *testing.T) {
ctx := acctest.Context(t)
var resourceServer awstypes.ResourceServerType
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
identifier := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_cognito_resource_server.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(ctx, t); testAccPreCheckIdentityProvider(ctx, t) },
ErrorCheck: acctest.ErrorCheck(t, names.CognitoIDPServiceID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckResourceServerDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccResourceServerConfig_basic(identifier, rName),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckResourceServerExists(ctx, resourceName, &resourceServer),
resource.TestCheckResourceAttr(resourceName, "name", rName),
),
},
{
Config: testAccResourceServerConfig_nameUpdate(identifier, rName),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckResourceServerExists(ctx, resourceName, &resourceServer),
resource.TestCheckResourceAttr(resourceName, "name", fmt.Sprintf(`%s updated`, rName)),
),
},
},
})

}

Check failure on line 156 in internal/service/cognitoidp/resource_server_test.go

View workflow job for this annotation

GitHub Actions / 5 of 5

unnecessary trailing newline (whitespace)

func testAccCheckResourceServerExists(ctx context.Context, n string, v *awstypes.ResourceServerType) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
Expand Down Expand Up @@ -184,6 +216,20 @@ resource "aws_cognito_user_pool" "test" {
`, identifier, rName)
}

func testAccResourceServerConfig_nameUpdate(identifier, rName string) string {
return fmt.Sprintf(`
resource "aws_cognito_resource_server" "test" {
identifier = %[1]q
name = "%[2]s updated"
user_pool_id = aws_cognito_user_pool.test.id
}
resource "aws_cognito_user_pool" "test" {
name = %[2]q
}
`, identifier, rName)
}

func testAccResourceServerConfig_scope(identifier, rName string) string {
return fmt.Sprintf(`
resource "aws_cognito_resource_server" "test" {
Expand Down

0 comments on commit eb0515b

Please sign in to comment.