Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix name updates on cognito_user_pool_client resource #9437

Merged
Merged
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
4 changes: 4 additions & 0 deletions aws/resource_aws_cognito_user_pool_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,10 @@ func resourceAwsCognitoUserPoolClientUpdate(d *schema.ResourceData, meta interfa
UserPoolId: aws.String(d.Get("user_pool_id").(string)),
}

if v, ok := d.GetOk("name"); ok {
params.ClientName = aws.String(v.(string))
}

if v, ok := d.GetOk("explicit_auth_flows"); ok {
params.ExplicitAuthFlows = expandStringList(v.(*schema.Set).List())
}
Expand Down
40 changes: 40 additions & 0 deletions aws/resource_aws_cognito_user_pool_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,33 @@ func TestAccAWSCognitoUserPoolClient_RefreshTokenValidity(t *testing.T) {
})
}

func TestAccAWSCognitoUserPoolClient_ClientName(t *testing.T) {
rName := acctest.RandomWithPrefix("tf-acc-test")
rName2 := acctest.RandomWithPrefix("tf-acc-test")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t); testAccPreCheckAWSCognitoIdentityProvider(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSCognitoUserPoolClientDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSCognitoUserPoolClientConfig_ClientName(rName),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckAWSCognitoUserPoolClientExists("aws_cognito_user_pool_client.client"),
resource.TestCheckResourceAttr("aws_cognito_user_pool_client.client", "name", rName),
),
},
{
Config: testAccAWSCognitoUserPoolClientConfig_ClientName(rName2),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckAWSCognitoUserPoolClientExists("aws_cognito_user_pool_client.client"),
resource.TestCheckResourceAttr("aws_cognito_user_pool_client.client", "name", rName2),
),
},
},
})
}

func TestAccAWSCognitoUserPoolClient_allFields(t *testing.T) {
userPoolName := fmt.Sprintf("tf-acc-cognito-user-pool-%s", acctest.RandString(7))
clientName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
Expand Down Expand Up @@ -287,6 +314,19 @@ resource "aws_cognito_user_pool_client" "client" {
`, rName, rName, refreshTokenValidity)
}

func testAccAWSCognitoUserPoolClientConfig_ClientName(rName string) string {
return fmt.Sprintf(`
resource "aws_cognito_user_pool" "pool" {
name = "%s"
}

resource "aws_cognito_user_pool_client" "client" {
name = "%s"
user_pool_id = "${aws_cognito_user_pool.pool.id}"
}
`, rName, rName)
}

func testAccAWSCognitoUserPoolClientConfig_allFields(userPoolName, clientName string, refreshTokenValidity int) string {
return fmt.Sprintf(`
resource "aws_cognito_user_pool" "pool" {
Expand Down