Skip to content

Commit

Permalink
support removing custom_email_sender and custom_sms_sender triggers
Browse files Browse the repository at this point in the history
  • Loading branch information
swain committed Jan 23, 2023
1 parent 9542a8a commit bd1f827
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .changelog/29047.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_cognito_user_pool: Support removing custom_email_sender and custom_sms_sender triggers from lambda_config
```
2 changes: 0 additions & 2 deletions internal/service/cognitoidp/user_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ func ResourceUserPool() *schema.Resource {
"custom_email_sender": {
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
RequiredWith: []string{"lambda_config.0.kms_key_id"},
Elem: &schema.Resource{
Expand All @@ -307,7 +306,6 @@ func ResourceUserPool() *schema.Resource {
"custom_sms_sender": {
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
RequiredWith: []string{"lambda_config.0.kms_key_id"},
Elem: &schema.Resource{
Expand Down
36 changes: 36 additions & 0 deletions internal/service/cognitoidp/user_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1170,6 +1170,12 @@ func TestAccCognitoIDPUserPool_WithLambda_email(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "lambda_config.0.custom_email_sender.0.lambda_version", "V1_0"),
),
},
{
Config: testAccUserPoolConfig_lambdaEmailSenderUpdatedRemove(rName),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "lambda_config.#", "0"),
),
},
},
})
}
Expand Down Expand Up @@ -1211,6 +1217,12 @@ func TestAccCognitoIDPUserPool_WithLambda_sms(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "lambda_config.0.custom_sms_sender.0.lambda_version", "V1_0"),
),
},
{
Config: testAccUserPoolConfig_lambdaSMSSenderUpdatedRemove(rName),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "lambda_config.#", "0"),
),
},
},
})
}
Expand Down Expand Up @@ -2261,6 +2273,18 @@ resource "aws_cognito_user_pool" "test" {
`, name))
}

func testAccUserPoolConfig_lambdaEmailSenderUpdatedRemove(name string) string {
return acctest.ConfigCompose(testAccUserPoolLambdaConfig_base(name), fmt.Sprintf(`
resource "aws_cognito_user_pool" "test" {
name = %[1]q
lambda_config {
kms_key_id = aws_kms_key.test.arn
}
}
`, name))
}

func testAccUserPoolConfig_lambdaSMSSender(name string) string {
return acctest.ConfigCompose(testAccUserPoolLambdaConfig_base(name), fmt.Sprintf(`
resource "aws_cognito_user_pool" "test" {
Expand Down Expand Up @@ -2303,6 +2327,18 @@ resource "aws_cognito_user_pool" "test" {
`, name))
}

func testAccUserPoolConfig_lambdaSMSSenderUpdatedRemove(name string) string {
return acctest.ConfigCompose(testAccUserPoolLambdaConfig_base(name), fmt.Sprintf(`
resource "aws_cognito_user_pool" "test" {
name = %[1]q
lambda_config {
kms_key_id = aws_kms_key.test.arn
}
}
`, name))
}

func testAccUserPoolConfig_schemaAttributes(name string) string {
return fmt.Sprintf(`
resource "aws_cognito_user_pool" "test" {
Expand Down

0 comments on commit bd1f827

Please sign in to comment.