Skip to content

Commit

Permalink
resource/aws_cognito_user_pool: Remove deprecated admin_create_user_c…
Browse files Browse the repository at this point in the history
…onfig.unused_account_validity_days argument (#14294)

Reference: #10890
Reference: #13398

Output from acceptance testing:

```
--- PASS: TestAccAWSCognitoUserPool_basic (16.93s)
--- PASS: TestAccAWSCognitoUserPool_MfaConfiguration_SmsConfiguration (47.75s)
--- PASS: TestAccAWSCognitoUserPool_MfaConfiguration_SmsConfigurationAndSoftwareTokenMfaConfiguration (50.45s)
--- PASS: TestAccAWSCognitoUserPool_MfaConfiguration_SmsConfigurationToSoftwareTokenMfaConfiguration (46.37s)
--- PASS: TestAccAWSCognitoUserPool_MfaConfiguration_SoftwareTokenMfaConfiguration (41.83s)
--- PASS: TestAccAWSCognitoUserPool_MfaConfiguration_SoftwareTokenMfaConfigurationToSmsConfiguration (35.22s)
--- PASS: TestAccAWSCognitoUserPool_SmsAuthenticationMessage (36.72s)
--- PASS: TestAccAWSCognitoUserPool_SmsConfiguration (45.69s)
--- PASS: TestAccAWSCognitoUserPool_SmsConfiguration_ExternalId (43.87s)
--- PASS: TestAccAWSCognitoUserPool_SmsConfiguration_SnsCallerArn (41.27s)
--- PASS: TestAccAWSCognitoUserPool_SmsVerificationMessage (21.39s)
--- PASS: TestAccAWSCognitoUserPool_update (38.77s)
--- PASS: TestAccAWSCognitoUserPool_withAdminCreateUserConfiguration (26.14s)
--- PASS: TestAccAWSCognitoUserPool_withAdminCreateUserConfigurationAndPasswordPolicy (13.70s)
--- PASS: TestAccAWSCognitoUserPool_withAdvancedSecurityMode (32.33s)
--- PASS: TestAccAWSCognitoUserPool_withAliasAttributes (23.59s)
--- PASS: TestAccAWSCognitoUserPool_withDeviceConfiguration (21.89s)
--- PASS: TestAccAWSCognitoUserPool_withEmailVerificationMessage (21.15s)
--- PASS: TestAccAWSCognitoUserPool_withLambdaConfig (46.71s)
--- PASS: TestAccAWSCognitoUserPool_withPasswordPolicy (36.75s)
--- PASS: TestAccAWSCognitoUserPool_withSchemaAttributes (22.83s)
--- PASS: TestAccAWSCognitoUserPool_withTags (33.77s)
--- PASS: TestAccAWSCognitoUserPool_withUsernameConfiguration (28.12s)
--- PASS: TestAccAWSCognitoUserPool_withVerificationMessageTemplate (21.48s)
```
  • Loading branch information
bflad authored Jul 24, 2020
1 parent 33116d1 commit 3301c00
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 55 deletions.
15 changes: 3 additions & 12 deletions aws/resource_aws_cognito_user_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,6 @@ 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"},
},
},
},
},
Expand Down Expand Up @@ -301,10 +293,9 @@ func resourceAwsCognitoUserPool() *schema.Resource {
Optional: true,
},
"temporary_password_validity_days": {
Type: schema.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(0, 365),
ConflictsWith: []string{"admin_create_user_config.0.unused_account_validity_days"},
Type: schema.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(0, 365),
},
},
},
Expand Down
38 changes: 0 additions & 38 deletions aws/resource_aws_cognito_user_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ func TestAccAWSCognitoUserPool_withAdminCreateUserConfiguration(t *testing.T) {
Config: testAccAWSCognitoUserPoolConfig_withAdminCreateUserConfiguration(name),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckAWSCognitoUserPoolExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "admin_create_user_config.0.unused_account_validity_days", "6"),
resource.TestCheckResourceAttr(resourceName, "admin_create_user_config.0.allow_admin_create_user_only", "true"),
resource.TestCheckResourceAttr(resourceName, "admin_create_user_config.0.invite_message_template.0.email_message", "Your username is {username} and temporary password is {####}. "),
resource.TestCheckResourceAttr(resourceName, "admin_create_user_config.0.invite_message_template.0.email_subject", "FooBar {####}"),
Expand All @@ -128,21 +127,9 @@ func TestAccAWSCognitoUserPool_withAdminCreateUserConfiguration(t *testing.T) {
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccAWSCognitoUserPoolConfig_withAdminCreateUserConfigurationUpdatedError(name),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "admin_create_user_config.0.unused_account_validity_days", "6"),
resource.TestCheckResourceAttr(resourceName, "admin_create_user_config.0.allow_admin_create_user_only", "false"),
resource.TestCheckResourceAttr(resourceName, "admin_create_user_config.0.invite_message_template.0.email_message", "Your username is {username} and constant password is {####}. "),
resource.TestCheckResourceAttr(resourceName, "admin_create_user_config.0.invite_message_template.0.email_subject", "Foo{####}BaBaz"),
resource.TestCheckResourceAttr(resourceName, "admin_create_user_config.0.invite_message_template.0.sms_message", "Your username is {username} and constant password is {####}."),
),
ExpectNonEmptyPlan: true,
},
{
Config: testAccAWSCognitoUserPoolConfig_withAdminCreateUserConfigurationUpdated(name),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "admin_create_user_config.0.unused_account_validity_days", "6"),
resource.TestCheckResourceAttr(resourceName, "admin_create_user_config.0.allow_admin_create_user_only", "false"),
resource.TestCheckResourceAttr(resourceName, "admin_create_user_config.0.invite_message_template.0.email_message", "Your username is {username} and constant password is {####}. "),
resource.TestCheckResourceAttr(resourceName, "admin_create_user_config.0.invite_message_template.0.email_subject", "Foo{####}BaBaz"),
Expand Down Expand Up @@ -1104,7 +1091,6 @@ func TestAccAWSCognitoUserPool_update(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "email_verification_subject", "FooBar {####}"),
resource.TestCheckResourceAttr(resourceName, "sms_verification_message", "{####} Baz"),
resource.TestCheckResourceAttr(resourceName, "sms_authentication_message", authenticationMessage),
resource.TestCheckResourceAttr(resourceName, "admin_create_user_config.0.unused_account_validity_days", "6"),
resource.TestCheckResourceAttr(resourceName, "admin_create_user_config.0.allow_admin_create_user_only", "true"),
resource.TestCheckResourceAttr(resourceName, "admin_create_user_config.0.invite_message_template.0.email_message", "Your username is {username} and temporary password is {####}. "),
resource.TestCheckResourceAttr(resourceName, "admin_create_user_config.0.invite_message_template.0.email_subject", "FooBar {####}"),
Expand Down Expand Up @@ -1133,7 +1119,6 @@ func TestAccAWSCognitoUserPool_update(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "email_verification_subject", "FooBar {####}"),
resource.TestCheckResourceAttr(resourceName, "sms_verification_message", "{####} Baz"),
resource.TestCheckResourceAttr(resourceName, "sms_authentication_message", updatedAuthenticationMessage),
resource.TestCheckResourceAttr(resourceName, "admin_create_user_config.0.unused_account_validity_days", "6"),
resource.TestCheckResourceAttr(resourceName, "admin_create_user_config.0.allow_admin_create_user_only", "true"),
resource.TestCheckResourceAttr(resourceName, "admin_create_user_config.0.invite_message_template.0.email_message", "Your username is {username} and temporary password is {####}. "),
resource.TestCheckResourceAttr(resourceName, "admin_create_user_config.0.invite_message_template.0.email_subject", "FooBar {####}"),
Expand All @@ -1157,7 +1142,6 @@ func TestAccAWSCognitoUserPool_update(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "email_verification_subject", "FooBar {####}"),
resource.TestCheckResourceAttr(resourceName, "sms_verification_message", "{####} Baz"),
resource.TestCheckResourceAttr(resourceName, "sms_authentication_message", updatedAuthenticationMessage),
resource.TestCheckResourceAttr(resourceName, "admin_create_user_config.0.unused_account_validity_days", "6"),
resource.TestCheckResourceAttr(resourceName, "admin_create_user_config.0.allow_admin_create_user_only", "true"),
resource.TestCheckResourceAttr(resourceName, "admin_create_user_config.0.invite_message_template.0.email_message", "Your username is {username} and temporary password is {####}. "),
resource.TestCheckResourceAttr(resourceName, "admin_create_user_config.0.invite_message_template.0.email_subject", "FooBar {####}"),
Expand Down Expand Up @@ -1295,7 +1279,6 @@ resource "aws_cognito_user_pool" "test" {
admin_create_user_config {
allow_admin_create_user_only = true
unused_account_validity_days = 6
invite_message_template {
email_message = "Your username is {username} and temporary password is {####}. "
Expand All @@ -1307,33 +1290,13 @@ resource "aws_cognito_user_pool" "test" {
`, name)
}

func testAccAWSCognitoUserPoolConfig_withAdminCreateUserConfigurationUpdatedError(name string) string {
return fmt.Sprintf(`
resource "aws_cognito_user_pool" "test" {
name = "terraform-test-pool-%s"
admin_create_user_config {
allow_admin_create_user_only = false
unused_account_validity_days = 7
invite_message_template {
email_message = "Your username is {username} and constant password is {####}. "
email_subject = "Foo{####}BaBaz"
sms_message = "Your username is {username} and constant password is {####}."
}
}
}
`, name)
}

func testAccAWSCognitoUserPoolConfig_withAdminCreateUserConfigurationUpdated(name string) string {
return fmt.Sprintf(`
resource "aws_cognito_user_pool" "test" {
name = "terraform-test-pool-%s"
admin_create_user_config {
allow_admin_create_user_only = false
unused_account_validity_days = 6
invite_message_template {
email_message = "Your username is {username} and constant password is {####}. "
Expand Down Expand Up @@ -1917,7 +1880,6 @@ resource "aws_cognito_user_pool" "test" {
admin_create_user_config {
allow_admin_create_user_only = true
unused_account_validity_days = 6
invite_message_template {
email_message = "Your username is {username} and temporary password is {####}. "
Expand Down
4 changes: 0 additions & 4 deletions aws/structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -2474,8 +2474,6 @@ func expandCognitoUserPoolAdminCreateUserConfig(config map[string]interface{}) *
}
}

configs.UnusedAccountValidityDays = aws.Int64(int64(config["unused_account_validity_days"].(int)))

return configs
}

Expand Down Expand Up @@ -2510,8 +2508,6 @@ func flattenCognitoUserPoolAdminCreateUserConfig(s *cognitoidentityprovider.Admi
}
}

config["unused_account_validity_days"] = *s.UnusedAccountValidityDays

return []map[string]interface{}{config}
}

Expand Down
35 changes: 35 additions & 0 deletions website/docs/guides/version-3-upgrade.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Upgrade topics:
- [Resource: aws_acm_certificate](#resource-aws_acm_certificate)
- [Resource: aws_api_gateway_method_settings](#resource-aws_api_gateway_method_settings)
- [Resource: aws_autoscaling_group](#resource-aws_autoscaling_group)
- [Resource: aws_cognito_user_pool](#resource-aws_cognito_user_pool)
- [Resource: aws_dx_gateway](#resource-aws_dx_gateway)
- [Resource: aws_ebs_volume](#resource-aws_ebs_volume)
- [Resource: aws_elastic_transcoder_preset](#resource-aws_elastic_transcoder_preset)
Expand Down Expand Up @@ -574,6 +575,40 @@ resource "aws_autoscaling_group" "example"{
}
```

## Resource: aws_cognito_user_pool

### Removal of admin_create_user_config.unused_account_validity_days Argument

The Cognito API previously deprecated the `admin_create_user_config` configuration block `unused_account_validity_days` argument in preference of the `password_policy` configuration block `temporary_password_validity_days` argument. Configurations will need to be updated to use the API supported configuration.

For example, given this previous configuration:

```hcl
resource "aws_cognito_user_pool" "example" {
# ... other configuration ...
admin_create_user_config {
# ... potentially other configuration ...
unused_account_validity_days = 7
}
}
```

An updated configuration:

```hcl
resource "aws_cognito_user_pool" "example" {
# ... other configuration ...
password_policy {
# ... potentially other configuration ...
temporary_password_validity_days = 7
}
}
```

## Resource: aws_dx_gateway

### Removal of Automatic aws_dx_gateway_association Import
Expand Down
1 change: 0 additions & 1 deletion website/docs/r/cognito_user_pool.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ The following arguments are supported:

* `allow_admin_create_user_only` (Optional) - Set to True if only the administrator is allowed to create user profiles. Set to False if users can sign themselves up via an app.
* `invite_message_template` (Optional) - The [invite message template structure](#invite-message-template).
* `unused_account_validity_days` (Optional) - **DEPRECATED** Use password_policy.temporary_password_validity_days instead - The user account expiration limit, in days, after which the account is no longer usable.

##### Invite Message template

Expand Down

0 comments on commit 3301c00

Please sign in to comment.