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

[WIP] - Allow suppressed_reasons to be an empty list in order to overwrite the default suppressed reasons #28670

Closed
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
9 changes: 6 additions & 3 deletions internal/service/sesv2/configuration_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ func ResourceConfigurationSet() *schema.Resource {
"suppressed_reasons": {
Type: schema.TypeList,
Optional: true,
MinItems: 1,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateDiagFunc: enum.Validate[types.SuppressionListReason](),
Expand Down Expand Up @@ -573,8 +572,12 @@ func expandSuppressionOptions(tfMap map[string]interface{}) *types.SuppressionOp

a := &types.SuppressionOptions{}

if v, ok := tfMap["suppressed_reasons"].([]interface{}); ok && len(v) > 0 {
a.SuppressedReasons = expandSuppressedReasons(v)
if v, ok := tfMap["suppressed_reasons"].([]interface{}); ok {
if len(v) > 0 {
a.SuppressedReasons = expandSuppressedReasons(v)
} else {
a.SuppressedReasons = make([]types.SuppressionListReason, 0)
}
}

return a
Expand Down
39 changes: 39 additions & 0 deletions internal/service/sesv2/configuration_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,33 @@ func TestAccSESV2ConfigurationSet_suppressedReasons(t *testing.T) {
})
}

func TestAccSESV2ConfigurationSet_suppressedReasonsEmpty(t *testing.T) {
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_sesv2_configuration_set.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
ErrorCheck: acctest.ErrorCheck(t, names.SESV2EndpointID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckConfigurationSetDestroy,
Steps: []resource.TestStep{
{
Config: testAccConfigurationSetConfig_suppressedReasonsEmpty(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckConfigurationSetExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "suppression_options.#", "1"),
resource.TestCheckResourceAttr(resourceName, "suppression_options.0.suppressed_reasons.#", "0"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccSESV2ConfigurationSet_tags(t *testing.T) {
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_sesv2_configuration_set.test"
Expand Down Expand Up @@ -356,6 +383,18 @@ resource "aws_sesv2_configuration_set" "test" {
`, rName, suppressedReason)
}

func testAccConfigurationSetConfig_suppressedReasonsEmpty(rName string) string {
return fmt.Sprintf(`
resource "aws_sesv2_configuration_set" "test" {
configuration_set_name = %[1]q

suppression_options {
suppressed_reasons = []
}
}
`, rName)
}

func testAccConfigurationSetConfig_tags1(rName, tagKey1, tagValue1 string) string {
return fmt.Sprintf(`
resource "aws_sesv2_configuration_set" "test" {
Expand Down