From 637bcfc5f5a957be38c1e4311f12887dd06ef0b3 Mon Sep 17 00:00:00 2001 From: lvthillo Date: Tue, 19 Nov 2024 20:14:14 +0100 Subject: [PATCH 1/8] feat: add new sesv2 attributes --- internal/service/sesv2/configuration_set.go | 32 +++++++++++++++++++ .../sesv2/configuration_set_data_source.go | 8 +++++ .../configuration_set_data_source_test.go | 6 ++-- .../service/sesv2/configuration_set_test.go | 15 +++++---- 4 files changed, 53 insertions(+), 8 deletions(-) diff --git a/internal/service/sesv2/configuration_set.go b/internal/service/sesv2/configuration_set.go index 476c5baa6b1..0e31bf0b541 100644 --- a/internal/service/sesv2/configuration_set.go +++ b/internal/service/sesv2/configuration_set.go @@ -58,6 +58,11 @@ func resourceConfigurationSet() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ + "max_delivery_seconds": { + Type: schema.TypeInt, + Optional: true, + ValidateFunc: validation.IntBetween(300, 50400), + }, "sending_pool_name": { Type: schema.TypeString, Optional: true, @@ -133,6 +138,11 @@ func resourceConfigurationSet() *schema.Resource { Type: schema.TypeString, Required: true, }, + "https_policy": { + Type: schema.TypeString, + Optional: true, + ValidateDiagFunc: enum.Validate[types.HttpsPolicy](), + }, }, }, }, @@ -322,6 +332,10 @@ 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 { + in.MaxDeliverySeconds = aws.Int64(int64(v)) + } + if v, ok := tfMap["sending_pool_name"].(string); ok && v != "" { in.SendingPoolName = aws.String(v) } @@ -409,6 +423,10 @@ func resourceConfigurationSetUpdate(ctx context.Context, d *schema.ResourceData, if v, ok := tfMap["custom_redirect_domain"].(string); ok && v != "" { in.CustomRedirectDomain = aws.String(v) } + + if v, ok := tfMap["https_policy"].(string); ok && v != "" { + in.HttpsPolicy = types.HttpsPolicy(v) + } } log.Printf("[DEBUG] Updating SESV2 ConfigurationSet TrackingOptions (%s): %#v", d.Id(), in) @@ -493,6 +511,10 @@ func flattenDeliveryOptions(apiObject *types.DeliveryOptions) map[string]interfa m := map[string]interface{}{} + if v := apiObject.MaxDeliverySeconds; v != nil { + m["max_delivery_seconds"] = aws.ToInt64(v) + } + if v := apiObject.SendingPoolName; v != nil { m["sending_pool_name"] = aws.ToString(v) } @@ -565,6 +587,8 @@ func flattenTrackingOptions(apiObject *types.TrackingOptions) map[string]interfa m["custom_redirect_domain"] = aws.ToString(v) } + m["https_policy"] = string(apiObject.HttpsPolicy) + return m } @@ -617,6 +641,10 @@ func expandDeliveryOptions(tfMap map[string]interface{}) *types.DeliveryOptions a := &types.DeliveryOptions{} + if v, ok := tfMap["max_delivery_seconds"].(int); ok { + a.MaxDeliverySeconds = aws.Int64(int64(v)) + } + if v, ok := tfMap["sending_pool_name"].(string); ok && v != "" { a.SendingPoolName = aws.String(v) } @@ -697,6 +725,10 @@ func expandTrackingOptions(tfMap map[string]interface{}) *types.TrackingOptions a.CustomRedirectDomain = aws.String(v) } + if v, ok := tfMap["https_policy"].(string); ok && v != "" { + a.HttpsPolicy = types.HttpsPolicy(v) + } + return a } diff --git a/internal/service/sesv2/configuration_set_data_source.go b/internal/service/sesv2/configuration_set_data_source.go index 17ccf0df05c..a3e732cacf8 100644 --- a/internal/service/sesv2/configuration_set_data_source.go +++ b/internal/service/sesv2/configuration_set_data_source.go @@ -37,6 +37,10 @@ func dataSourceConfigurationSet() *schema.Resource { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ + "max_delivery_seconds": { + Type: schema.TypeInt, + Computed: true, + }, "sending_pool_name": { Type: schema.TypeString, Computed: true, @@ -101,6 +105,10 @@ func dataSourceConfigurationSet() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "https_policy": { + Type: schema.TypeString, + Computed: true, + }, }, }, }, diff --git a/internal/service/sesv2/configuration_set_data_source_test.go b/internal/service/sesv2/configuration_set_data_source_test.go index bd8f6215443..f5412278f00 100644 --- a/internal/service/sesv2/configuration_set_data_source_test.go +++ b/internal/service/sesv2/configuration_set_data_source_test.go @@ -32,6 +32,7 @@ func TestAccSESV2ConfigurationSetDataSource_basic(t *testing.T) { resource.TestCheckResourceAttrPair(resourceName, names.AttrARN, dataSourceName, names.AttrARN), resource.TestCheckResourceAttrPair(resourceName, "configuration_set_name", dataSourceName, "configuration_set_name"), resource.TestCheckResourceAttrPair(resourceName, "delivery_options.#", dataSourceName, "delivery_options.#"), + resource.TestCheckResourceAttrPair(resourceName, "delivery_options.0.max_delivery_seconds", dataSourceName, "delivery_options.0.max_delivery_seconds"), resource.TestCheckResourceAttrPair(resourceName, "delivery_options.0.sending_pool_name", dataSourceName, "delivery_options.0.sending_pool_name"), resource.TestCheckResourceAttrPair(resourceName, "delivery_options.0.tls_policy", dataSourceName, "delivery_options.0.tls_policy"), resource.TestCheckResourceAttrPair(resourceName, "reputation_options.#", dataSourceName, "reputation_options.#"), @@ -40,7 +41,7 @@ func TestAccSESV2ConfigurationSetDataSource_basic(t *testing.T) { resource.TestCheckResourceAttrPair(resourceName, "sending_options.#", dataSourceName, "sending_options.#"), resource.TestCheckResourceAttrPair(resourceName, "sending_options.0.sending_enabled", dataSourceName, "sending_options.0.sending_enabled"), resource.TestCheckResourceAttrPair(resourceName, "suppression_options.#", dataSourceName, "suppression_options.#"), - resource.TestCheckResourceAttrPair(resourceName, "suppression_options.#", dataSourceName, "suppression_options.#"), + resource.TestCheckResourceAttrPair(resourceName, "suppression_options.0.suppressed_reasons", dataSourceName, "suppression_options.0.suppressed_reasons"), resource.TestCheckResourceAttrPair(resourceName, acctest.CtTagsPercent, dataSourceName, acctest.CtTagsPercent), resource.TestCheckResourceAttrPair(resourceName, "vdm_options.#", dataSourceName, "vdm_options.#"), resource.TestCheckResourceAttrPair(resourceName, "vdm_options.0.dashboard_options.#", dataSourceName, "vdm_options.0.dashboard_options.#"), @@ -59,7 +60,8 @@ resource "aws_sesv2_configuration_set" "test" { configuration_set_name = %[1]q delivery_options { - tls_policy = "REQUIRE" + max_delivery_seconds = 300 + tls_policy = "REQUIRE" } reputation_options { diff --git a/internal/service/sesv2/configuration_set_test.go b/internal/service/sesv2/configuration_set_test.go index db44853d3a1..df65d57173d 100644 --- a/internal/service/sesv2/configuration_set_test.go +++ b/internal/service/sesv2/configuration_set_test.go @@ -71,7 +71,7 @@ func TestAccSESV2ConfigurationSet_disappears(t *testing.T) { }) } -func TestAccSESV2ConfigurationSet_tlsPolicy(t *testing.T) { +func TestAccSESV2ConfigurationSet_deliveryOptions(t *testing.T) { ctx := acctest.Context(t) rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_sesv2_configuration_set.test" @@ -83,10 +83,11 @@ func TestAccSESV2ConfigurationSet_tlsPolicy(t *testing.T) { CheckDestroy: testAccCheckConfigurationSetDestroy(ctx), Steps: []resource.TestStep{ { - Config: testAccConfigurationSetConfig_tlsPolicy(rName, string(types.TlsPolicyRequire)), + Config: testAccConfigurationSetConfig_deliveryOptions(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)), ), }, @@ -96,10 +97,11 @@ func TestAccSESV2ConfigurationSet_tlsPolicy(t *testing.T) { ImportStateVerify: true, }, { - Config: testAccConfigurationSetConfig_tlsPolicy(rName, string(types.TlsPolicyOptional)), + Config: testAccConfigurationSetConfig_deliveryOptions(rName, 800, string(types.TlsPolicyOptional)), Check: resource.ComposeTestCheckFunc( testAccCheckConfigurationSetExists(ctx, resourceName), resource.TestCheckResourceAttr(resourceName, "delivery_options.#", "1"), + resource.TestCheckResourceAttr(resourceName, "delivery_options.0.max_delivery_seconds", "800"), resource.TestCheckResourceAttr(resourceName, "delivery_options.0.tls_policy", string(types.TlsPolicyOptional)), ), }, @@ -381,16 +383,17 @@ resource "aws_sesv2_configuration_set" "test" { `, rName) } -func testAccConfigurationSetConfig_tlsPolicy(rName, tlsPolicy string) string { +func testAccConfigurationSetConfig_deliveryOptions(rName string, MaxDeliverySeconds int, tlsPolicy string) string { return fmt.Sprintf(` resource "aws_sesv2_configuration_set" "test" { configuration_set_name = %[1]q delivery_options { - tls_policy = %[2]q + max_delivery_seconds = %[2]d + tls_policy = %[3]q } } -`, rName, tlsPolicy) +`, rName, MaxDeliverySeconds, tlsPolicy) } func testAccConfigurationSetConfig_reputationMetricsEnabled(rName string, reputationMetricsEnabled bool) string { From 1dd8ee33c6715507631e843ffb1503ae4f7d0c87 Mon Sep 17 00:00:00 2001 From: lvthillo Date: Tue, 19 Nov 2024 20:33:16 +0100 Subject: [PATCH 2/8] docs: update docs --- website/docs/d/sesv2_configuration_set.html.markdown | 2 ++ website/docs/r/sesv2_configuration_set.html.markdown | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/website/docs/d/sesv2_configuration_set.html.markdown b/website/docs/d/sesv2_configuration_set.html.markdown index 3b44e63b316..b0e72eb935c 100644 --- a/website/docs/d/sesv2_configuration_set.html.markdown +++ b/website/docs/d/sesv2_configuration_set.html.markdown @@ -31,6 +31,7 @@ The following arguments are required: This data source exports the following attributes in addition to the arguments above: * `delivery_options` - An object that defines the dedicated IP pool that is used to send emails that you send using the configuration set. + * `max_delivery_seconds` - The maximum amount of time, in seconds, that Amazon SES API v2 will attempt delivery of email. If specified, the value must greater than or equal to 300 seconds (5 minutes) and less than or equal to 50400 seconds (840 minutes). * `sending_pool_name` - The name of the dedicated IP pool to associate with the configuration set. * `tls_policy` - Specifies whether messages that use the configuration set are required to use Transport Layer Security (TLS). * `reputation_options` - An object that defines whether or not Amazon SES collects reputation metrics for the emails that you send that use the configuration set. @@ -43,6 +44,7 @@ This data source exports the following attributes in addition to the arguments a * `tags` - Key-value map of resource tags for the container recipe. * `tracking_options` - An object that defines the open and click tracking options for emails that you send using the configuration set. * `custom_redirect_domain` - The domain to use for tracking open and click events. + * `https_policy`: The https policy to use for tracking open and click events. Valid values are `REQUIRE`, `REQUIRE_OPEN_ONLY` or `OPTIONAL`. * `vdm_options` - An object that contains information about the VDM preferences for your configuration set. * `dashboard_options` - Specifies additional settings for your VDM configuration as applicable to the Dashboard. * `engagement_metrics` - Specifies the status of your VDM engagement metrics collection. diff --git a/website/docs/r/sesv2_configuration_set.html.markdown b/website/docs/r/sesv2_configuration_set.html.markdown index 801c76f8123..9b743249d2e 100644 --- a/website/docs/r/sesv2_configuration_set.html.markdown +++ b/website/docs/r/sesv2_configuration_set.html.markdown @@ -19,7 +19,8 @@ resource "aws_sesv2_configuration_set" "example" { configuration_set_name = "example" delivery_options { - tls_policy = "REQUIRE" + max_delivery_seconds = 300 + tls_policy = "REQUIRE" } reputation_options { @@ -36,6 +37,7 @@ resource "aws_sesv2_configuration_set" "example" { tracking_options { custom_redirect_domain = "example.com" + https_policy = "REQUIRE" } } ``` @@ -57,6 +59,7 @@ This resource supports the following arguments: The `delivery_options` configuration block supports the following arguments: +* `max_delivery_seconds` - The maximum amount of time, in seconds, that Amazon SES API v2 will attempt delivery of email. If specified, the value must greater than or equal to 300 seconds (5 minutes) and less than or equal to 50400 seconds (840 minutes). * `sending_pool_name` - (Optional) The name of the dedicated IP pool to associate with the configuration set. * `tls_policy` - (Optional) Specifies whether messages that use the configuration set are required to use Transport Layer Security (TLS). Valid values: `REQUIRE`, `OPTIONAL`. @@ -83,6 +86,7 @@ The `suppression_options` configuration block supports the following arguments: The `tracking_options` configuration block supports the following arguments: * `custom_redirect_domain` - (Required) The domain to use for tracking open and click events. +* `https_policy`: The https policy to use for tracking open and click events. Valid values are `REQUIRE`, `REQUIRE_OPEN_ONLY` or `OPTIONAL`. ### `vdm_options` Block From c3aebb661576555c8b9def35ef5f766f5af8fad6 Mon Sep 17 00:00:00 2001 From: lvthillo Date: Tue, 19 Nov 2024 20:43:32 +0100 Subject: [PATCH 3/8] feat: add release note --- .changelog/40194.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/40194.txt diff --git a/.changelog/40194.txt b/.changelog/40194.txt new file mode 100644 index 00000000000..9239441cff8 --- /dev/null +++ b/.changelog/40194.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/aws_sesv2_configuration_set: Add missing `max_delivery_seconds` and `https_policy` arguments. +``` From 1cfc235843c05dc1a8abe640896da130e86985c1 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Thu, 12 Dec 2024 10:18:02 -0500 Subject: [PATCH 4/8] Tweak CHANGELOG entry. --- .changelog/40194.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changelog/40194.txt b/.changelog/40194.txt index 9239441cff8..135e83376b9 100644 --- a/.changelog/40194.txt +++ b/.changelog/40194.txt @@ -1,3 +1,3 @@ ```release-note:enhancement -resource/aws_sesv2_configuration_set: Add missing `max_delivery_seconds` and `https_policy` arguments. +resource/aws_sesv2_configuration_set: Add `delivery_options.max_delivery_seconds` and `tracking_options.https_policy` arguments ``` From fa5934dd6e70d91bfc865c00818cb38ef0c14cc8 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Thu, 12 Dec 2024 10:19:08 -0500 Subject: [PATCH 5/8] Missing CHANGELOG entry. --- .changelog/40194.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.changelog/40194.txt b/.changelog/40194.txt index 135e83376b9..90f0845add8 100644 --- a/.changelog/40194.txt +++ b/.changelog/40194.txt @@ -1,3 +1,7 @@ ```release-note:enhancement resource/aws_sesv2_configuration_set: Add `delivery_options.max_delivery_seconds` and `tracking_options.https_policy` arguments ``` + +```release-note:enhancement +data-source/aws_sesv2_configuration_set: Add `delivery_options.max_delivery_seconds` and `tracking_options.https_policy` attributes +``` \ No newline at end of file From 8feed69947446b7f5580b447cef7e328c90092d7 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Thu, 12 Dec 2024 10:29:42 -0500 Subject: [PATCH 6/8] r/aws_sesv2_configuration_set: Cosmetics. --- internal/service/sesv2/configuration_set.go | 250 +++++++++----------- 1 file changed, 110 insertions(+), 140 deletions(-) diff --git a/internal/service/sesv2/configuration_set.go b/internal/service/sesv2/configuration_set.go index 0e31bf0b541..1a9be61fe56 100644 --- a/internal/service/sesv2/configuration_set.go +++ b/internal/service/sesv2/configuration_set.go @@ -5,7 +5,6 @@ package sesv2 import ( "context" - "errors" "fmt" "log" "time" @@ -22,6 +21,7 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/create" "github.com/hashicorp/terraform-provider-aws/internal/enum" "github.com/hashicorp/terraform-provider-aws/internal/errs" + "github.com/hashicorp/terraform-provider-aws/internal/flex" tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" @@ -197,8 +197,9 @@ func resourceConfigurationSetCreate(ctx context.Context, d *schema.ResourceData, var diags diag.Diagnostics conn := meta.(*conns.AWSClient).SESV2Client(ctx) + name := d.Get("configuration_set_name").(string) input := &sesv2.CreateConfigurationSetInput{ - ConfigurationSetName: aws.String(d.Get("configuration_set_name").(string)), + ConfigurationSetName: aws.String(name), Tags: getTagsIn(ctx), } @@ -236,16 +237,13 @@ func resourceConfigurationSetCreate(ctx context.Context, d *schema.ResourceData, input.VdmOptions = expandVDMOptions(v.([]interface{})[0].(map[string]interface{})) } - out, err := conn.CreateConfigurationSet(ctx, input) - if err != nil { - return create.AppendDiagError(diags, names.SESV2, create.ErrActionCreating, resNameConfigurationSet, d.Get("configuration_set_name").(string), err) - } + _, err := conn.CreateConfigurationSet(ctx, input) - if out == nil { - return create.AppendDiagError(diags, names.SESV2, create.ErrActionCreating, resNameConfigurationSet, d.Get("configuration_set_name").(string), errors.New("empty output")) + if err != nil { + return create.AppendDiagError(diags, names.SESV2, create.ErrActionCreating, resNameConfigurationSet, name, err) } - d.SetId(d.Get("configuration_set_name").(string)) + d.SetId(name) return append(diags, resourceConfigurationSetRead(ctx, d, meta)...) } @@ -254,7 +252,7 @@ func resourceConfigurationSetRead(ctx context.Context, d *schema.ResourceData, m var diags diag.Diagnostics conn := meta.(*conns.AWSClient).SESV2Client(ctx) - out, err := findConfigurationSetByID(ctx, conn, d.Id()) + output, err := findConfigurationSetByID(ctx, conn, d.Id()) if !d.IsNewResource() && tfresource.NotFound(err) { log.Printf("[WARN] SESV2 ConfigurationSet (%s) not found, removing from state", d.Id()) @@ -266,51 +264,45 @@ func resourceConfigurationSetRead(ctx context.Context, d *schema.ResourceData, m return create.AppendDiagError(diags, names.SESV2, create.ErrActionReading, resNameConfigurationSet, d.Id(), err) } - d.Set(names.AttrARN, configurationSetARN(ctx, meta.(*conns.AWSClient), aws.ToString(out.ConfigurationSetName))) - d.Set("configuration_set_name", out.ConfigurationSetName) - - if out.DeliveryOptions != nil { - if err := d.Set("delivery_options", []interface{}{flattenDeliveryOptions(out.DeliveryOptions)}); err != nil { + d.Set(names.AttrARN, configurationSetARN(ctx, meta.(*conns.AWSClient), aws.ToString(output.ConfigurationSetName))) + d.Set("configuration_set_name", output.ConfigurationSetName) + if output.DeliveryOptions != nil { + if err := d.Set("delivery_options", []interface{}{flattenDeliveryOptions(output.DeliveryOptions)}); err != nil { return create.AppendDiagError(diags, names.SESV2, create.ErrActionSetting, resNameConfigurationSet, d.Id(), err) } } else { d.Set("delivery_options", nil) } - - if out.ReputationOptions != nil { - if err := d.Set("reputation_options", []interface{}{flattenReputationOptions(out.ReputationOptions)}); err != nil { + if output.ReputationOptions != nil { + if err := d.Set("reputation_options", []interface{}{flattenReputationOptions(output.ReputationOptions)}); err != nil { return create.AppendDiagError(diags, names.SESV2, create.ErrActionSetting, resNameConfigurationSet, d.Id(), err) } } else { d.Set("reputation_options", nil) } - - if out.SendingOptions != nil { - if err := d.Set("sending_options", []interface{}{flattenSendingOptions(out.SendingOptions)}); err != nil { + if output.SendingOptions != nil { + if err := d.Set("sending_options", []interface{}{flattenSendingOptions(output.SendingOptions)}); err != nil { return create.AppendDiagError(diags, names.SESV2, create.ErrActionSetting, resNameConfigurationSet, d.Id(), err) } } else { d.Set("sending_options", nil) } - - if out.SuppressionOptions != nil { - if err := d.Set("suppression_options", []interface{}{flattenSuppressionOptions(out.SuppressionOptions)}); err != nil { + if output.SuppressionOptions != nil { + if err := d.Set("suppression_options", []interface{}{flattenSuppressionOptions(output.SuppressionOptions)}); err != nil { return create.AppendDiagError(diags, names.SESV2, create.ErrActionSetting, resNameConfigurationSet, d.Id(), err) } } else { d.Set("suppression_options", nil) } - - if out.TrackingOptions != nil { - if err := d.Set("tracking_options", []interface{}{flattenTrackingOptions(out.TrackingOptions)}); err != nil { + if output.TrackingOptions != nil { + if err := d.Set("tracking_options", []interface{}{flattenTrackingOptions(output.TrackingOptions)}); err != nil { return create.AppendDiagError(diags, names.SESV2, create.ErrActionSetting, resNameConfigurationSet, d.Id(), err) } } else { d.Set("tracking_options", nil) } - - if out.VdmOptions != nil { - if err := d.Set("vdm_options", []interface{}{flattenVDMOptions(out.VdmOptions)}); err != nil { + if output.VdmOptions != nil { + if err := d.Set("vdm_options", []interface{}{flattenVDMOptions(output.VdmOptions)}); err != nil { return create.AppendDiagError(diags, names.SESV2, create.ErrActionSetting, resNameConfigurationSet, d.Id(), err) } } else { @@ -325,7 +317,7 @@ func resourceConfigurationSetUpdate(ctx context.Context, d *schema.ResourceData, conn := meta.(*conns.AWSClient).SESV2Client(ctx) if d.HasChanges("delivery_options") { - in := &sesv2.PutConfigurationSetDeliveryOptionsInput{ + input := &sesv2.PutConfigurationSetDeliveryOptionsInput{ ConfigurationSetName: aws.String(d.Id()), } @@ -333,27 +325,27 @@ func resourceConfigurationSetUpdate(ctx context.Context, d *schema.ResourceData, tfMap := v.([]interface{})[0].(map[string]interface{}) if v, ok := tfMap["max_delivery_seconds"].(int); ok { - in.MaxDeliverySeconds = aws.Int64(int64(v)) + input.MaxDeliverySeconds = aws.Int64(int64(v)) } if v, ok := tfMap["sending_pool_name"].(string); ok && v != "" { - in.SendingPoolName = aws.String(v) + input.SendingPoolName = aws.String(v) } if v, ok := tfMap["tls_policy"].(string); ok && v != "" { - in.TlsPolicy = types.TlsPolicy(v) + input.TlsPolicy = types.TlsPolicy(v) } } - log.Printf("[DEBUG] Updating SESV2 ConfigurationSet DeliveryOptions (%s): %#v", d.Id(), in) - _, err := conn.PutConfigurationSetDeliveryOptions(ctx, in) + _, err := conn.PutConfigurationSetDeliveryOptions(ctx, input) + if err != nil { return create.AppendDiagError(diags, names.SESV2, create.ErrActionUpdating, resNameConfigurationSet, d.Id(), err) } } if d.HasChanges("reputation_options") { - in := &sesv2.PutConfigurationSetReputationOptionsInput{ + input := &sesv2.PutConfigurationSetReputationOptionsInput{ ConfigurationSetName: aws.String(d.Id()), } @@ -361,39 +353,39 @@ func resourceConfigurationSetUpdate(ctx context.Context, d *schema.ResourceData, tfMap := v.([]interface{})[0].(map[string]interface{}) if v, ok := tfMap["reputation_metrics_enabled"].(bool); ok { - in.ReputationMetricsEnabled = v + input.ReputationMetricsEnabled = v } } - log.Printf("[DEBUG] Updating SESV2 ConfigurationSet ReputationOptions (%s): %#v", d.Id(), in) - _, err := conn.PutConfigurationSetReputationOptions(ctx, in) + _, err := conn.PutConfigurationSetReputationOptions(ctx, input) + if err != nil { return create.AppendDiagError(diags, names.SESV2, create.ErrActionUpdating, resNameConfigurationSet, d.Id(), err) } } if d.HasChanges("sending_options") { + input := &sesv2.PutConfigurationSetSendingOptionsInput{ + ConfigurationSetName: aws.String(d.Id()), + } + if v, ok := d.GetOk("sending_options"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { tfMap := v.([]interface{})[0].(map[string]interface{}) - in := &sesv2.PutConfigurationSetSendingOptionsInput{ - ConfigurationSetName: aws.String(d.Id()), - } - if v, ok := tfMap["sending_enabled"].(bool); ok { - in.SendingEnabled = v + input.SendingEnabled = v } + } - log.Printf("[DEBUG] Updating SESV2 ConfigurationSet SendingOptions (%s): %#v", d.Id(), in) - _, err := conn.PutConfigurationSetSendingOptions(ctx, in) - if err != nil { - return create.AppendDiagError(diags, names.SESV2, create.ErrActionUpdating, resNameConfigurationSet, d.Id(), err) - } + _, err := conn.PutConfigurationSetSendingOptions(ctx, input) + + if err != nil { + return create.AppendDiagError(diags, names.SESV2, create.ErrActionUpdating, resNameConfigurationSet, d.Id(), err) } } if d.HasChanges("suppression_options") { - in := &sesv2.PutConfigurationSetSuppressionOptionsInput{ + input := &sesv2.PutConfigurationSetSuppressionOptionsInput{ ConfigurationSetName: aws.String(d.Id()), } @@ -401,19 +393,19 @@ func resourceConfigurationSetUpdate(ctx context.Context, d *schema.ResourceData, tfMap := v.([]interface{})[0].(map[string]interface{}) if v, ok := tfMap["suppressed_reasons"].([]interface{}); ok && len(v) > 0 { - in.SuppressedReasons = expandSuppressedReasons(v) + input.SuppressedReasons = flex.ExpandStringyValueList[types.SuppressionListReason](v) } } - log.Printf("[DEBUG] Updating SESV2 ConfigurationSet SuppressionOptions (%s): %#v", d.Id(), in) - _, err := conn.PutConfigurationSetSuppressionOptions(ctx, in) + _, err := conn.PutConfigurationSetSuppressionOptions(ctx, input) + if err != nil { return create.AppendDiagError(diags, names.SESV2, create.ErrActionUpdating, resNameConfigurationSet, d.Id(), err) } } if d.HasChanges("tracking_options") { - in := &sesv2.PutConfigurationSetTrackingOptionsInput{ + input := &sesv2.PutConfigurationSetTrackingOptionsInput{ ConfigurationSetName: aws.String(d.Id()), } @@ -421,32 +413,32 @@ func resourceConfigurationSetUpdate(ctx context.Context, d *schema.ResourceData, tfMap := v.([]interface{})[0].(map[string]interface{}) if v, ok := tfMap["custom_redirect_domain"].(string); ok && v != "" { - in.CustomRedirectDomain = aws.String(v) + input.CustomRedirectDomain = aws.String(v) } if v, ok := tfMap["https_policy"].(string); ok && v != "" { - in.HttpsPolicy = types.HttpsPolicy(v) + input.HttpsPolicy = types.HttpsPolicy(v) } } - log.Printf("[DEBUG] Updating SESV2 ConfigurationSet TrackingOptions (%s): %#v", d.Id(), in) - _, err := conn.PutConfigurationSetTrackingOptions(ctx, in) + _, err := conn.PutConfigurationSetTrackingOptions(ctx, input) + if err != nil { return create.AppendDiagError(diags, names.SESV2, create.ErrActionUpdating, resNameConfigurationSet, d.Id(), err) } } if d.HasChanges("vdm_options") { - in := &sesv2.PutConfigurationSetVdmOptionsInput{ + input := &sesv2.PutConfigurationSetVdmOptionsInput{ ConfigurationSetName: aws.String(d.Id()), } if v, ok := d.GetOk("vdm_options"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { - in.VdmOptions = expandVDMOptions(v.([]interface{})[0].(map[string]interface{})) + input.VdmOptions = expandVDMOptions(v.([]interface{})[0].(map[string]interface{})) } - log.Printf("[DEBUG] Updating SESV2 ConfigurationSet VdmOptions (%s): %#v", d.Id(), in) - _, err := conn.PutConfigurationSetVdmOptions(ctx, in) + _, err := conn.PutConfigurationSetVdmOptions(ctx, input) + if err != nil { return create.AppendDiagError(diags, names.SESV2, create.ErrActionUpdating, resNameConfigurationSet, d.Id(), err) } @@ -509,19 +501,19 @@ func flattenDeliveryOptions(apiObject *types.DeliveryOptions) map[string]interfa return nil } - m := map[string]interface{}{} + tfMap := map[string]interface{}{ + "tls_policy": apiObject.TlsPolicy, + } if v := apiObject.MaxDeliverySeconds; v != nil { - m["max_delivery_seconds"] = aws.ToInt64(v) + tfMap["max_delivery_seconds"] = aws.ToInt64(v) } if v := apiObject.SendingPoolName; v != nil { - m["sending_pool_name"] = aws.ToString(v) + tfMap["sending_pool_name"] = aws.ToString(v) } - m["tls_policy"] = string(apiObject.TlsPolicy) - - return m + return tfMap } func flattenReputationOptions(apiObject *types.ReputationOptions) map[string]interface{} { @@ -529,15 +521,15 @@ func flattenReputationOptions(apiObject *types.ReputationOptions) map[string]int return nil } - m := map[string]interface{}{ + tfMap := map[string]interface{}{ "reputation_metrics_enabled": apiObject.ReputationMetricsEnabled, } if v := apiObject.LastFreshStart; v != nil { - m["last_fresh_start"] = v.Format(time.RFC3339) + tfMap["last_fresh_start"] = v.Format(time.RFC3339) } - return m + return tfMap } func flattenSendingOptions(apiObject *types.SendingOptions) map[string]interface{} { @@ -545,11 +537,11 @@ func flattenSendingOptions(apiObject *types.SendingOptions) map[string]interface return nil } - m := map[string]interface{}{ + tfMap := map[string]interface{}{ "sending_enabled": apiObject.SendingEnabled, } - return m + return tfMap } func flattenSuppressionOptions(apiObject *types.SuppressionOptions) map[string]interface{} { @@ -557,23 +549,13 @@ func flattenSuppressionOptions(apiObject *types.SuppressionOptions) map[string]i return nil } - m := map[string]interface{}{} + tfMap := map[string]interface{}{} if v := apiObject.SuppressedReasons; v != nil { - m["suppressed_reasons"] = flattenSuppressedReasons(apiObject.SuppressedReasons) - } - - return m -} - -func flattenSuppressedReasons(apiObject []types.SuppressionListReason) []string { - var out []string - - for _, v := range apiObject { - out = append(out, string(v)) + tfMap["suppressed_reasons"] = apiObject.SuppressedReasons } - return out + return tfMap } func flattenTrackingOptions(apiObject *types.TrackingOptions) map[string]interface{} { @@ -581,15 +563,15 @@ func flattenTrackingOptions(apiObject *types.TrackingOptions) map[string]interfa return nil } - m := map[string]interface{}{} + tfMap := map[string]interface{}{ + "https_policy": apiObject.HttpsPolicy, + } if v := apiObject.CustomRedirectDomain; v != nil { - m["custom_redirect_domain"] = aws.ToString(v) + tfMap["custom_redirect_domain"] = aws.ToString(v) } - m["https_policy"] = string(apiObject.HttpsPolicy) - - return m + return tfMap } func flattenVDMOptions(apiObject *types.VdmOptions) map[string]interface{} { @@ -597,17 +579,17 @@ func flattenVDMOptions(apiObject *types.VdmOptions) map[string]interface{} { return nil } - m := map[string]interface{}{} + tfMap := map[string]interface{}{} if v := apiObject.DashboardOptions; v != nil { - m["dashboard_options"] = []interface{}{flattenDashboardOptions(v)} + tfMap["dashboard_options"] = []interface{}{flattenDashboardOptions(v)} } if v := apiObject.GuardianOptions; v != nil { - m["guardian_options"] = []interface{}{flattenGuardianOptions(v)} + tfMap["guardian_options"] = []interface{}{flattenGuardianOptions(v)} } - return m + return tfMap } func flattenDashboardOptions(apiObject *types.DashboardOptions) map[string]interface{} { @@ -615,11 +597,11 @@ func flattenDashboardOptions(apiObject *types.DashboardOptions) map[string]inter return nil } - m := map[string]interface{}{ - "engagement_metrics": string(apiObject.EngagementMetrics), + tfMap := map[string]interface{}{ + "engagement_metrics": apiObject.EngagementMetrics, } - return m + return tfMap } func flattenGuardianOptions(apiObject *types.GuardianOptions) map[string]interface{} { @@ -627,11 +609,11 @@ func flattenGuardianOptions(apiObject *types.GuardianOptions) map[string]interfa return nil } - m := map[string]interface{}{ - "optimized_shared_delivery": string(apiObject.OptimizedSharedDelivery), + tfMap := map[string]interface{}{ + "optimized_shared_delivery": apiObject.OptimizedSharedDelivery, } - return m + return tfMap } func expandDeliveryOptions(tfMap map[string]interface{}) *types.DeliveryOptions { @@ -639,21 +621,21 @@ func expandDeliveryOptions(tfMap map[string]interface{}) *types.DeliveryOptions return nil } - a := &types.DeliveryOptions{} + apiObject := &types.DeliveryOptions{} if v, ok := tfMap["max_delivery_seconds"].(int); ok { - a.MaxDeliverySeconds = aws.Int64(int64(v)) + apiObject.MaxDeliverySeconds = aws.Int64(int64(v)) } if v, ok := tfMap["sending_pool_name"].(string); ok && v != "" { - a.SendingPoolName = aws.String(v) + apiObject.SendingPoolName = aws.String(v) } if v, ok := tfMap["tls_policy"].(string); ok && v != "" { - a.TlsPolicy = types.TlsPolicy(v) + apiObject.TlsPolicy = types.TlsPolicy(v) } - return a + return apiObject } func expandReputationOptions(tfMap map[string]interface{}) *types.ReputationOptions { @@ -661,13 +643,13 @@ func expandReputationOptions(tfMap map[string]interface{}) *types.ReputationOpti return nil } - a := &types.ReputationOptions{} + apiObject := &types.ReputationOptions{} if v, ok := tfMap["reputation_metrics_enabled"].(bool); ok { - a.ReputationMetricsEnabled = v + apiObject.ReputationMetricsEnabled = v } - return a + return apiObject } func expandSendingOptions(tfMap map[string]interface{}) *types.SendingOptions { @@ -675,13 +657,13 @@ func expandSendingOptions(tfMap map[string]interface{}) *types.SendingOptions { return nil } - a := &types.SendingOptions{} + apiObject := &types.SendingOptions{} if v, ok := tfMap["sending_enabled"].(bool); ok { - a.SendingEnabled = v + apiObject.SendingEnabled = v } - return a + return apiObject } func expandSuppressionOptions(tfMap map[string]interface{}) *types.SuppressionOptions { @@ -693,7 +675,7 @@ func expandSuppressionOptions(tfMap map[string]interface{}) *types.SuppressionOp if v, ok := tfMap["suppressed_reasons"].([]interface{}); ok { if len(v) > 0 { - apiObject.SuppressedReasons = expandSuppressedReasons(v) + apiObject.SuppressedReasons = flex.ExpandStringyValueList[types.SuppressionListReason](v) } else { apiObject.SuppressedReasons = make([]types.SuppressionListReason, 0) } @@ -702,34 +684,22 @@ func expandSuppressionOptions(tfMap map[string]interface{}) *types.SuppressionOp return apiObject } -func expandSuppressedReasons(tfList []interface{}) []types.SuppressionListReason { - var out []types.SuppressionListReason - - for _, v := range tfList { - if v, ok := v.(string); ok && v != "" { - out = append(out, types.SuppressionListReason(v)) - } - } - - return out -} - func expandTrackingOptions(tfMap map[string]interface{}) *types.TrackingOptions { if tfMap == nil { return nil } - a := &types.TrackingOptions{} + apiObject := &types.TrackingOptions{} if v, ok := tfMap["custom_redirect_domain"].(string); ok && v != "" { - a.CustomRedirectDomain = aws.String(v) + apiObject.CustomRedirectDomain = aws.String(v) } if v, ok := tfMap["https_policy"].(string); ok && v != "" { - a.HttpsPolicy = types.HttpsPolicy(v) + apiObject.HttpsPolicy = types.HttpsPolicy(v) } - return a + return apiObject } func expandVDMOptions(tfMap map[string]interface{}) *types.VdmOptions { @@ -737,17 +707,17 @@ func expandVDMOptions(tfMap map[string]interface{}) *types.VdmOptions { return nil } - a := &types.VdmOptions{} + apiObject := &types.VdmOptions{} if v, ok := tfMap["dashboard_options"].([]interface{}); ok && len(v) > 0 && v[0] != nil { - a.DashboardOptions = expandDashboardOptions(v[0].(map[string]interface{})) + apiObject.DashboardOptions = expandDashboardOptions(v[0].(map[string]interface{})) } if v, ok := tfMap["guardian_options"].([]interface{}); ok && len(v) > 0 && v[0] != nil { - a.GuardianOptions = expandGuardianOptions(v[0].(map[string]interface{})) + apiObject.GuardianOptions = expandGuardianOptions(v[0].(map[string]interface{})) } - return a + return apiObject } func expandDashboardOptions(tfMap map[string]interface{}) *types.DashboardOptions { @@ -755,13 +725,13 @@ func expandDashboardOptions(tfMap map[string]interface{}) *types.DashboardOption return nil } - a := &types.DashboardOptions{} + apiObject := &types.DashboardOptions{} if v, ok := tfMap["engagement_metrics"].(string); ok && v != "" { - a.EngagementMetrics = types.FeatureStatus(v) + apiObject.EngagementMetrics = types.FeatureStatus(v) } - return a + return apiObject } func expandGuardianOptions(tfMap map[string]interface{}) *types.GuardianOptions { @@ -769,13 +739,13 @@ func expandGuardianOptions(tfMap map[string]interface{}) *types.GuardianOptions return nil } - a := &types.GuardianOptions{} + apiObject := &types.GuardianOptions{} if v, ok := tfMap["optimized_shared_delivery"].(string); ok && v != "" { - a.OptimizedSharedDelivery = types.FeatureStatus(v) + apiObject.OptimizedSharedDelivery = types.FeatureStatus(v) } - return a + return apiObject } func configurationSetARN(ctx context.Context, c *conns.AWSClient, configurationSetName string) string { From 50285ae13d6e0db9c8104670227ad95e9e581a94 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Thu, 12 Dec 2024 10:31:08 -0500 Subject: [PATCH 7/8] d/aws_sesv2_configuration_set: Cosmetics. --- .../sesv2/configuration_set_data_source.go | 39 ++++++++----------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/internal/service/sesv2/configuration_set_data_source.go b/internal/service/sesv2/configuration_set_data_source.go index a3e732cacf8..fe5d2e773be 100644 --- a/internal/service/sesv2/configuration_set_data_source.go +++ b/internal/service/sesv2/configuration_set_data_source.go @@ -158,58 +158,53 @@ func dataSourceConfigurationSetRead(ctx context.Context, d *schema.ResourceData, name := d.Get("configuration_set_name").(string) - out, err := findConfigurationSetByID(ctx, conn, name) + output, err := findConfigurationSetByID(ctx, conn, name) + if err != nil { return create.AppendDiagError(diags, names.SESV2, create.ErrActionReading, dsNameConfigurationSet, name, err) } - d.SetId(aws.ToString(out.ConfigurationSetName)) - - d.Set(names.AttrARN, configurationSetARN(ctx, meta.(*conns.AWSClient), aws.ToString(out.ConfigurationSetName))) - d.Set("configuration_set_name", out.ConfigurationSetName) + d.SetId(aws.ToString(output.ConfigurationSetName)) - if out.DeliveryOptions != nil { - if err := d.Set("delivery_options", []interface{}{flattenDeliveryOptions(out.DeliveryOptions)}); err != nil { + d.Set(names.AttrARN, configurationSetARN(ctx, meta.(*conns.AWSClient), aws.ToString(output.ConfigurationSetName))) + d.Set("configuration_set_name", output.ConfigurationSetName) + if output.DeliveryOptions != nil { + if err := d.Set("delivery_options", []interface{}{flattenDeliveryOptions(output.DeliveryOptions)}); err != nil { return create.AppendDiagError(diags, names.SESV2, create.ErrActionSetting, dsNameConfigurationSet, d.Id(), err) } } else { d.Set("delivery_options", nil) } - - if out.ReputationOptions != nil { - if err := d.Set("reputation_options", []interface{}{flattenReputationOptions(out.ReputationOptions)}); err != nil { + if output.ReputationOptions != nil { + if err := d.Set("reputation_options", []interface{}{flattenReputationOptions(output.ReputationOptions)}); err != nil { return create.AppendDiagError(diags, names.SESV2, create.ErrActionSetting, dsNameConfigurationSet, d.Id(), err) } } else { d.Set("reputation_options", nil) } - - if out.SendingOptions != nil { - if err := d.Set("sending_options", []interface{}{flattenSendingOptions(out.SendingOptions)}); err != nil { + if output.SendingOptions != nil { + if err := d.Set("sending_options", []interface{}{flattenSendingOptions(output.SendingOptions)}); err != nil { return create.AppendDiagError(diags, names.SESV2, create.ErrActionSetting, dsNameConfigurationSet, d.Id(), err) } } else { d.Set("sending_options", nil) } - - if out.SuppressionOptions != nil { - if err := d.Set("suppression_options", []interface{}{flattenSuppressionOptions(out.SuppressionOptions)}); err != nil { + if output.SuppressionOptions != nil { + if err := d.Set("suppression_options", []interface{}{flattenSuppressionOptions(output.SuppressionOptions)}); err != nil { return create.AppendDiagError(diags, names.SESV2, create.ErrActionSetting, dsNameConfigurationSet, d.Id(), err) } } else { d.Set("suppression_options", nil) } - - if out.TrackingOptions != nil { - if err := d.Set("tracking_options", []interface{}{flattenTrackingOptions(out.TrackingOptions)}); err != nil { + if output.TrackingOptions != nil { + if err := d.Set("tracking_options", []interface{}{flattenTrackingOptions(output.TrackingOptions)}); err != nil { return create.AppendDiagError(diags, names.SESV2, create.ErrActionSetting, dsNameConfigurationSet, d.Id(), err) } } else { d.Set("tracking_options", nil) } - - if out.VdmOptions != nil { - if err := d.Set("vdm_options", []interface{}{flattenVDMOptions(out.VdmOptions)}); err != nil { + if output.VdmOptions != nil { + if err := d.Set("vdm_options", []interface{}{flattenVDMOptions(output.VdmOptions)}); err != nil { return create.AppendDiagError(diags, names.SESV2, create.ErrActionSetting, dsNameConfigurationSet, d.Id(), err) } } else { From 71586e2d96f9348cdf786ed614f8c2214feae6af Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Thu, 12 Dec 2024 10:34:28 -0500 Subject: [PATCH 8/8] Tidy up error messages. --- internal/service/sesv2/configuration_set.go | 13 +++++++------ .../service/sesv2/configuration_set_data_source.go | 13 +++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/internal/service/sesv2/configuration_set.go b/internal/service/sesv2/configuration_set.go index 1a9be61fe56..3801d519173 100644 --- a/internal/service/sesv2/configuration_set.go +++ b/internal/service/sesv2/configuration_set.go @@ -21,6 +21,7 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/create" "github.com/hashicorp/terraform-provider-aws/internal/enum" "github.com/hashicorp/terraform-provider-aws/internal/errs" + "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" "github.com/hashicorp/terraform-provider-aws/internal/flex" tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" @@ -268,42 +269,42 @@ func resourceConfigurationSetRead(ctx context.Context, d *schema.ResourceData, m d.Set("configuration_set_name", output.ConfigurationSetName) if output.DeliveryOptions != nil { if err := d.Set("delivery_options", []interface{}{flattenDeliveryOptions(output.DeliveryOptions)}); err != nil { - return create.AppendDiagError(diags, names.SESV2, create.ErrActionSetting, resNameConfigurationSet, d.Id(), err) + return sdkdiag.AppendErrorf(diags, "setting delivery_options: %s", err) } } else { d.Set("delivery_options", nil) } if output.ReputationOptions != nil { if err := d.Set("reputation_options", []interface{}{flattenReputationOptions(output.ReputationOptions)}); err != nil { - return create.AppendDiagError(diags, names.SESV2, create.ErrActionSetting, resNameConfigurationSet, d.Id(), err) + return sdkdiag.AppendErrorf(diags, "setting reputation_options: %s", err) } } else { d.Set("reputation_options", nil) } if output.SendingOptions != nil { if err := d.Set("sending_options", []interface{}{flattenSendingOptions(output.SendingOptions)}); err != nil { - return create.AppendDiagError(diags, names.SESV2, create.ErrActionSetting, resNameConfigurationSet, d.Id(), err) + return sdkdiag.AppendErrorf(diags, "setting sending_options: %s", err) } } else { d.Set("sending_options", nil) } if output.SuppressionOptions != nil { if err := d.Set("suppression_options", []interface{}{flattenSuppressionOptions(output.SuppressionOptions)}); err != nil { - return create.AppendDiagError(diags, names.SESV2, create.ErrActionSetting, resNameConfigurationSet, d.Id(), err) + return sdkdiag.AppendErrorf(diags, "setting suppression_options: %s", err) } } else { d.Set("suppression_options", nil) } if output.TrackingOptions != nil { if err := d.Set("tracking_options", []interface{}{flattenTrackingOptions(output.TrackingOptions)}); err != nil { - return create.AppendDiagError(diags, names.SESV2, create.ErrActionSetting, resNameConfigurationSet, d.Id(), err) + return sdkdiag.AppendErrorf(diags, "setting tracking_options: %s", err) } } else { d.Set("tracking_options", nil) } if output.VdmOptions != nil { if err := d.Set("vdm_options", []interface{}{flattenVDMOptions(output.VdmOptions)}); err != nil { - return create.AppendDiagError(diags, names.SESV2, create.ErrActionSetting, resNameConfigurationSet, d.Id(), err) + return sdkdiag.AppendErrorf(diags, "setting vdm_options: %s", err) } } else { d.Set("vdm_options", nil) diff --git a/internal/service/sesv2/configuration_set_data_source.go b/internal/service/sesv2/configuration_set_data_source.go index fe5d2e773be..1938a940fc3 100644 --- a/internal/service/sesv2/configuration_set_data_source.go +++ b/internal/service/sesv2/configuration_set_data_source.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/hashicorp/terraform-provider-aws/internal/conns" "github.com/hashicorp/terraform-provider-aws/internal/create" + "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -170,42 +171,42 @@ func dataSourceConfigurationSetRead(ctx context.Context, d *schema.ResourceData, d.Set("configuration_set_name", output.ConfigurationSetName) if output.DeliveryOptions != nil { if err := d.Set("delivery_options", []interface{}{flattenDeliveryOptions(output.DeliveryOptions)}); err != nil { - return create.AppendDiagError(diags, names.SESV2, create.ErrActionSetting, dsNameConfigurationSet, d.Id(), err) + return sdkdiag.AppendErrorf(diags, "setting delivery_options: %s", err) } } else { d.Set("delivery_options", nil) } if output.ReputationOptions != nil { if err := d.Set("reputation_options", []interface{}{flattenReputationOptions(output.ReputationOptions)}); err != nil { - return create.AppendDiagError(diags, names.SESV2, create.ErrActionSetting, dsNameConfigurationSet, d.Id(), err) + return sdkdiag.AppendErrorf(diags, "setting reputation_options: %s", err) } } else { d.Set("reputation_options", nil) } if output.SendingOptions != nil { if err := d.Set("sending_options", []interface{}{flattenSendingOptions(output.SendingOptions)}); err != nil { - return create.AppendDiagError(diags, names.SESV2, create.ErrActionSetting, dsNameConfigurationSet, d.Id(), err) + return sdkdiag.AppendErrorf(diags, "setting sending_options: %s", err) } } else { d.Set("sending_options", nil) } if output.SuppressionOptions != nil { if err := d.Set("suppression_options", []interface{}{flattenSuppressionOptions(output.SuppressionOptions)}); err != nil { - return create.AppendDiagError(diags, names.SESV2, create.ErrActionSetting, dsNameConfigurationSet, d.Id(), err) + return sdkdiag.AppendErrorf(diags, "setting suppression_options: %s", err) } } else { d.Set("suppression_options", nil) } if output.TrackingOptions != nil { if err := d.Set("tracking_options", []interface{}{flattenTrackingOptions(output.TrackingOptions)}); err != nil { - return create.AppendDiagError(diags, names.SESV2, create.ErrActionSetting, dsNameConfigurationSet, d.Id(), err) + return sdkdiag.AppendErrorf(diags, "setting tracking_options: %s", err) } } else { d.Set("tracking_options", nil) } if output.VdmOptions != nil { if err := d.Set("vdm_options", []interface{}{flattenVDMOptions(output.VdmOptions)}); err != nil { - return create.AppendDiagError(diags, names.SESV2, create.ErrActionSetting, dsNameConfigurationSet, d.Id(), err) + return sdkdiag.AppendErrorf(diags, "setting vdm_options: %s", err) } } else { d.Set("vdm_options", nil)