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

r/aws_sesv2_configuration: Fix delivery_options.max_delivery_seconds handling #40670

Merged
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
3 changes: 3 additions & 0 deletions .changelog/40670.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_sesv2_configuration_set: Fix handling of `delivery_options.max_delivery_seconds` when not configured
```
4 changes: 2 additions & 2 deletions internal/service/sesv2/configuration_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ func resourceConfigurationSetUpdate(ctx context.Context, d *schema.ResourceData,
if v, ok := d.GetOk("delivery_options"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil {
tfMap := v.([]interface{})[0].(map[string]interface{})

if v, ok := tfMap["max_delivery_seconds"].(int); ok {
if v, ok := tfMap["max_delivery_seconds"].(int); ok && v != 0 {
input.MaxDeliverySeconds = aws.Int64(int64(v))
}

Expand Down Expand Up @@ -624,7 +624,7 @@ func expandDeliveryOptions(tfMap map[string]interface{}) *types.DeliveryOptions

apiObject := &types.DeliveryOptions{}

if v, ok := tfMap["max_delivery_seconds"].(int); ok {
if v, ok := tfMap["max_delivery_seconds"].(int); ok && v != 0 {
apiObject.MaxDeliverySeconds = aws.Int64(int64(v))
}

Expand Down
30 changes: 25 additions & 5 deletions internal/service/sesv2/configuration_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,10 @@ func TestAccSESV2ConfigurationSet_deliveryOptions(t *testing.T) {
CheckDestroy: testAccCheckConfigurationSetDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccConfigurationSetConfig_deliveryOptions(rName, 300, string(types.TlsPolicyRequire)),
Config: testAccConfigurationSetConfig_deliveryOptions(rName, string(types.TlsPolicyRequire)),
Check: resource.ComposeTestCheckFunc(
testAccCheckConfigurationSetExists(ctx, resourceName),
resource.TestCheckResourceAttr(resourceName, "delivery_options.#", "1"),
resource.TestCheckResourceAttr(resourceName, "delivery_options.0.max_delivery_seconds", "300"),
resource.TestCheckResourceAttr(resourceName, "delivery_options.0.tls_policy", string(types.TlsPolicyRequire)),
),
},
Expand All @@ -97,7 +96,16 @@ func TestAccSESV2ConfigurationSet_deliveryOptions(t *testing.T) {
ImportStateVerify: true,
},
{
Config: testAccConfigurationSetConfig_deliveryOptions(rName, 800, string(types.TlsPolicyOptional)),
Config: testAccConfigurationSetConfig_deliveryOptions_maxDeliverySeconds(rName, 300, string(types.TlsPolicyRequire)),
Check: resource.ComposeTestCheckFunc(
testAccCheckConfigurationSetExists(ctx, resourceName),
resource.TestCheckResourceAttr(resourceName, "delivery_options.#", "1"),
resource.TestCheckResourceAttr(resourceName, "delivery_options.0.max_delivery_seconds", "300"),
resource.TestCheckResourceAttr(resourceName, "delivery_options.0.tls_policy", string(types.TlsPolicyRequire)),
),
},
{
Config: testAccConfigurationSetConfig_deliveryOptions_maxDeliverySeconds(rName, 800, string(types.TlsPolicyOptional)),
Check: resource.ComposeTestCheckFunc(
testAccCheckConfigurationSetExists(ctx, resourceName),
resource.TestCheckResourceAttr(resourceName, "delivery_options.#", "1"),
Expand Down Expand Up @@ -383,7 +391,19 @@ resource "aws_sesv2_configuration_set" "test" {
`, rName)
}

func testAccConfigurationSetConfig_deliveryOptions(rName string, MaxDeliverySeconds int, tlsPolicy string) string {
func testAccConfigurationSetConfig_deliveryOptions(rName string, tlsPolicy string) string {
return fmt.Sprintf(`
resource "aws_sesv2_configuration_set" "test" {
configuration_set_name = %[1]q

delivery_options {
tls_policy = %[2]q
}
}
`, rName, tlsPolicy)
}

func testAccConfigurationSetConfig_deliveryOptions_maxDeliverySeconds(rName string, maxDeliverySeconds int, tlsPolicy string) string {
return fmt.Sprintf(`
resource "aws_sesv2_configuration_set" "test" {
configuration_set_name = %[1]q
Expand All @@ -393,7 +413,7 @@ resource "aws_sesv2_configuration_set" "test" {
tls_policy = %[3]q
}
}
`, rName, MaxDeliverySeconds, tlsPolicy)
`, rName, maxDeliverySeconds, tlsPolicy)
}

func testAccConfigurationSetConfig_reputationMetricsEnabled(rName string, reputationMetricsEnabled bool) string {
Expand Down
Loading