diff --git a/aws/resource_aws_cognito_user_pool_client.go b/aws/resource_aws_cognito_user_pool_client.go index e4a3ae596e2..94a1c0e6dc7 100644 --- a/aws/resource_aws_cognito_user_pool_client.go +++ b/aws/resource_aws_cognito_user_pool_client.go @@ -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()) } diff --git a/aws/resource_aws_cognito_user_pool_client_test.go b/aws/resource_aws_cognito_user_pool_client_test.go index 13e04d4bc58..43ca0d6e4bf 100644 --- a/aws/resource_aws_cognito_user_pool_client_test.go +++ b/aws/resource_aws_cognito_user_pool_client_test.go @@ -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) @@ -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" {