diff --git a/aws/resource_aws_cognito_user_pool.go b/aws/resource_aws_cognito_user_pool.go index c4895ac5fe2..79a5e106ee7 100644 --- a/aws/resource_aws_cognito_user_pool.go +++ b/aws/resource_aws_cognito_user_pool.go @@ -67,6 +67,7 @@ func resourceAwsCognitoUserPool() *schema.Resource { "unused_account_validity_days": { Type: schema.TypeInt, Optional: true, + Computed: true, Deprecated: "Use password_policy.temporary_password_validity_days instead", ValidateFunc: validation.IntBetween(0, 90), ConflictsWith: []string{"password_policy.0.temporary_password_validity_days"}, diff --git a/aws/resource_aws_cognito_user_pool_test.go b/aws/resource_aws_cognito_user_pool_test.go index b16e2e15ae5..77a121025ce 100644 --- a/aws/resource_aws_cognito_user_pool_test.go +++ b/aws/resource_aws_cognito_user_pool_test.go @@ -150,6 +150,33 @@ func TestAccAWSCognitoUserPool_withAdminCreateUserConfiguration(t *testing.T) { }) } +// Reference: https://github.com/terraform-providers/terraform-provider-aws/issues/11858 +func TestAccAWSCognitoUserPool_withAdminCreateUserConfigurationAndPasswordPolicy(t *testing.T) { + name := acctest.RandomWithPrefix("tf-acc-test") + resourceName := "aws_cognito_user_pool.test" + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t); testAccPreCheckAWSCognitoIdentityProvider(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSCognitoUserPoolDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSCognitoUserPoolConfig_withAdminCreateUserConfigAndPasswordPolicy(name), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckAWSCognitoUserPoolExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "admin_create_user_config.0.allow_admin_create_user_only", "true"), + resource.TestCheckResourceAttr(resourceName, "password_policy.0.temporary_password_validity_days", "7"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func TestAccAWSCognitoUserPool_withAdvancedSecurityMode(t *testing.T) { name := acctest.RandString(5) resourceName := "aws_cognito_user_pool.test" @@ -1112,6 +1139,27 @@ resource "aws_cognito_user_pool" "test" { `, name) } +func testAccAWSCognitoUserPoolConfig_withAdminCreateUserConfigAndPasswordPolicy(rName string) string { + return fmt.Sprintf(` +resource "aws_cognito_user_pool" "test" { + name = %[1]q + + admin_create_user_config { + allow_admin_create_user_only = true + } + + password_policy { + minimum_length = 7 + require_lowercase = true + require_numbers = false + require_symbols = true + require_uppercase = false + temporary_password_validity_days = 7 + } +} +`, rName) +} + func testAccAWSCognitoUserPoolConfig_withPasswordPolicy(name string) string { return fmt.Sprintf(` resource "aws_cognito_user_pool" "test" {