Skip to content

Commit

Permalink
Merge pull request #38568 from HubbardHarvey3/ses-awssdkv2-migration
Browse files Browse the repository at this point in the history
Ses awssdkv2 migration
  • Loading branch information
jar-b authored Aug 6, 2024
2 parents ac25cb8 + 49a17ab commit 9fb9325
Show file tree
Hide file tree
Showing 42 changed files with 774 additions and 640 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/servicecatalogappregistry v1.28.3
github.com/aws/aws-sdk-go-v2/service/servicediscovery v1.31.3
github.com/aws/aws-sdk-go-v2/service/servicequotas v1.23.3
github.com/aws/aws-sdk-go-v2/service/ses v1.25.2
github.com/aws/aws-sdk-go-v2/service/sesv2 v1.32.3
github.com/aws/aws-sdk-go-v2/service/sfn v1.30.0
github.com/aws/aws-sdk-go-v2/service/shield v1.27.3
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,8 @@ github.com/aws/aws-sdk-go-v2/service/servicediscovery v1.31.3 h1:EthA93BNgTnk36F
github.com/aws/aws-sdk-go-v2/service/servicediscovery v1.31.3/go.mod h1:4xh/h0pevPhBkA4b2iYosZaqrThccxFREQxiGuZpJlc=
github.com/aws/aws-sdk-go-v2/service/servicequotas v1.23.3 h1:J6R7Mo3nDY9BmmG4V9EpQa70A0XOoCuWPYTpsmouM48=
github.com/aws/aws-sdk-go-v2/service/servicequotas v1.23.3/go.mod h1:be52Ycqv581QoIOZzHfZFWlJLcGAI2M/ItUSlx7lLp0=
github.com/aws/aws-sdk-go-v2/service/ses v1.25.2 h1:NMFHOa6j5/PcxXNy2JEwN5nT79YMiWE55uDW9w5LO5o=
github.com/aws/aws-sdk-go-v2/service/ses v1.25.2/go.mod h1:cCXA/nP50r07dXq9qB0oM55YdYl6152Nd/2B+JrB9zo=
github.com/aws/aws-sdk-go-v2/service/sesv2 v1.32.3 h1:DLJCsgYZoNIIIFnWd3MXyg9ehgnlihOKDEvOAkzGRMc=
github.com/aws/aws-sdk-go-v2/service/sesv2 v1.32.3/go.mod h1:klyMXN+cNAndrESWMyT7LA8Ll0I6Nc03jxfSkeuU/Xg=
github.com/aws/aws-sdk-go-v2/service/sfn v1.30.0 h1:FIprHGk9sztofQcgyHrIOh4QQo0rO1kjHmksxDrXMtg=
Expand Down
6 changes: 3 additions & 3 deletions internal/conns/awsclient_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 15 additions & 14 deletions internal/service/ses/active_receipt_rule_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ import (
"fmt"
"log"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/arn"
"github.com/aws/aws-sdk-go/service/ses"
"github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/aws/arn"
"github.com/aws/aws-sdk-go-v2/service/ses"
awstypes "github.com/aws/aws-sdk-go-v2/service/ses/types"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/hashicorp/terraform-provider-aws/internal/conns"
"github.com/hashicorp/terraform-provider-aws/internal/errs"
"github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag"
"github.com/hashicorp/terraform-provider-aws/names"
)
Expand Down Expand Up @@ -48,15 +49,15 @@ func ResourceActiveReceiptRuleSet() *schema.Resource {

func resourceActiveReceiptRuleSetUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
var diags diag.Diagnostics
conn := meta.(*conns.AWSClient).SESConn(ctx)
conn := meta.(*conns.AWSClient).SESClient(ctx)

ruleSetName := d.Get("rule_set_name").(string)

createOpts := &ses.SetActiveReceiptRuleSetInput{
RuleSetName: aws.String(ruleSetName),
}

_, err := conn.SetActiveReceiptRuleSetWithContext(ctx, createOpts)
_, err := conn.SetActiveReceiptRuleSet(ctx, createOpts)
if err != nil {
return sdkdiag.AppendErrorf(diags, "setting active SES rule set: %s", err)
}
Expand All @@ -68,13 +69,13 @@ func resourceActiveReceiptRuleSetUpdate(ctx context.Context, d *schema.ResourceD

func resourceActiveReceiptRuleSetRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
var diags diag.Diagnostics
conn := meta.(*conns.AWSClient).SESConn(ctx)
conn := meta.(*conns.AWSClient).SESClient(ctx)

describeOpts := &ses.DescribeActiveReceiptRuleSetInput{}

response, err := conn.DescribeActiveReceiptRuleSetWithContext(ctx, describeOpts)
response, err := conn.DescribeActiveReceiptRuleSet(ctx, describeOpts)
if err != nil {
if tfawserr.ErrCodeEquals(err, ses.ErrCodeRuleSetDoesNotExistException) {
if errs.IsA[*awstypes.RuleSetDoesNotExistException](err) {
log.Printf("[WARN] SES Receipt Rule Set (%s) belonging to SES Active Receipt Rule Set not found, removing from state", d.Id())
d.SetId("")
return diags
Expand Down Expand Up @@ -104,13 +105,13 @@ func resourceActiveReceiptRuleSetRead(ctx context.Context, d *schema.ResourceDat

func resourceActiveReceiptRuleSetDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
var diags diag.Diagnostics
conn := meta.(*conns.AWSClient).SESConn(ctx)
conn := meta.(*conns.AWSClient).SESClient(ctx)

deleteOpts := &ses.SetActiveReceiptRuleSetInput{
RuleSetName: nil,
}

_, err := conn.SetActiveReceiptRuleSetWithContext(ctx, deleteOpts)
_, err := conn.SetActiveReceiptRuleSet(ctx, deleteOpts)
if err != nil {
return sdkdiag.AppendErrorf(diags, "deleting active SES rule set: %s", err)
}
Expand All @@ -119,11 +120,11 @@ func resourceActiveReceiptRuleSetDelete(ctx context.Context, d *schema.ResourceD
}

func resourceActiveReceiptRuleSetImport(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
conn := meta.(*conns.AWSClient).SESConn(ctx)
conn := meta.(*conns.AWSClient).SESClient(ctx)

describeOpts := &ses.DescribeActiveReceiptRuleSetInput{}

response, err := conn.DescribeActiveReceiptRuleSetWithContext(ctx, describeOpts)
response, err := conn.DescribeActiveReceiptRuleSet(ctx, describeOpts)
if err != nil {
return nil, err
}
Expand All @@ -132,7 +133,7 @@ func resourceActiveReceiptRuleSetImport(ctx context.Context, d *schema.ResourceD
return nil, fmt.Errorf("no active Receipt Rule Set found")
}

if aws.StringValue(response.Metadata.Name) != d.Id() {
if aws.ToString(response.Metadata.Name) != d.Id() {
return nil, fmt.Errorf("SES Receipt Rule Set (%s) belonging to SES Active Receipt Rule Set not found", d.Id())
}

Expand Down
12 changes: 6 additions & 6 deletions internal/service/ses/active_receipt_rule_set_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"context"
"fmt"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/arn"
"github.com/aws/aws-sdk-go/service/ses"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/aws/arn"
"github.com/aws/aws-sdk-go-v2/service/ses"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-provider-aws/internal/conns"
Expand Down Expand Up @@ -38,9 +38,9 @@ func DataSourceActiveReceiptRuleSet() *schema.Resource {

func dataSourceActiveReceiptRuleSetRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
var diags diag.Diagnostics
conn := meta.(*conns.AWSClient).SESConn(ctx)
conn := meta.(*conns.AWSClient).SESClient(ctx)

data, err := conn.DescribeActiveReceiptRuleSetWithContext(ctx, &ses.DescribeActiveReceiptRuleSetInput{})
data, err := conn.DescribeActiveReceiptRuleSet(ctx, &ses.DescribeActiveReceiptRuleSetInput{})

if err != nil {
return sdkdiag.AppendErrorf(diags, "reading SES Active Receipt Rule Set: %s", err)
Expand All @@ -49,7 +49,7 @@ func dataSourceActiveReceiptRuleSetRead(ctx context.Context, d *schema.ResourceD
return sdkdiag.AppendErrorf(diags, "reading SES Active Receipt Rule Set: %s", tfresource.NewEmptyResultError(nil))
}

name := aws.StringValue(data.Metadata.Name)
name := aws.ToString(data.Metadata.Name)
d.SetId(name)
d.Set("rule_set_name", name)
arn := arn.ARN{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"testing"

"github.com/YakDriver/regexache"
"github.com/aws/aws-sdk-go/service/ses"
"github.com/aws/aws-sdk-go-v2/service/ses"
sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-provider-aws/internal/acctest"
Expand Down Expand Up @@ -85,9 +85,9 @@ data "aws_ses_active_receipt_rule_set" "test" {}
}

func testAccPreCheckUnsetActiveRuleSet(ctx context.Context, t *testing.T) {
conn := acctest.Provider.Meta().(*conns.AWSClient).SESConn(ctx)
conn := acctest.Provider.Meta().(*conns.AWSClient).SESClient(ctx)

output, err := conn.DescribeActiveReceiptRuleSetWithContext(ctx, &ses.DescribeActiveReceiptRuleSetInput{})
output, err := conn.DescribeActiveReceiptRuleSet(ctx, &ses.DescribeActiveReceiptRuleSetInput{})
if acctest.PreCheckSkipError(err) {
t.Skipf("skipping acceptance testing: %s", err)
}
Expand All @@ -98,7 +98,7 @@ func testAccPreCheckUnsetActiveRuleSet(ctx context.Context, t *testing.T) {
t.Fatalf("unexpected PreCheck error: %s", err)
}

_, err = conn.SetActiveReceiptRuleSetWithContext(ctx, &ses.SetActiveReceiptRuleSetInput{
_, err = conn.SetActiveReceiptRuleSet(ctx, &ses.SetActiveReceiptRuleSetInput{
RuleSetName: nil,
})
if acctest.PreCheckSkipError(err) {
Expand Down
18 changes: 9 additions & 9 deletions internal/service/ses/active_receipt_rule_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"fmt"
"testing"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ses"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/ses"
sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/terraform"
Expand Down Expand Up @@ -98,19 +98,19 @@ func testAccActiveReceiptRuleSet_disappears(t *testing.T) {

func testAccCheckActiveReceiptRuleSetDestroy(ctx context.Context) resource.TestCheckFunc {
return func(s *terraform.State) error {
conn := acctest.Provider.Meta().(*conns.AWSClient).SESConn(ctx)
conn := acctest.Provider.Meta().(*conns.AWSClient).SESClient(ctx)

for _, rs := range s.RootModule().Resources {
if rs.Type != "aws_ses_active_receipt_rule_set" {
continue
}

response, err := conn.DescribeActiveReceiptRuleSetWithContext(ctx, &ses.DescribeActiveReceiptRuleSetInput{})
response, err := conn.DescribeActiveReceiptRuleSet(ctx, &ses.DescribeActiveReceiptRuleSetInput{})
if err != nil {
return err
}

if response.Metadata != nil && (aws.StringValue(response.Metadata.Name) == rs.Primary.ID) {
if response.Metadata != nil && (aws.ToString(response.Metadata.Name) == rs.Primary.ID) {
return fmt.Errorf("Active receipt rule set still exists")
}
}
Expand All @@ -130,15 +130,15 @@ func testAccCheckActiveReceiptRuleSetExists(ctx context.Context, n string) resou
return fmt.Errorf("SES Active Receipt Rule Set name not set")
}

conn := acctest.Provider.Meta().(*conns.AWSClient).SESConn(ctx)
conn := acctest.Provider.Meta().(*conns.AWSClient).SESClient(ctx)

response, err := conn.DescribeActiveReceiptRuleSetWithContext(ctx, &ses.DescribeActiveReceiptRuleSetInput{})
response, err := conn.DescribeActiveReceiptRuleSet(ctx, &ses.DescribeActiveReceiptRuleSetInput{})
if err != nil {
return err
}

if response.Metadata != nil && (aws.StringValue(response.Metadata.Name) != rs.Primary.ID) {
return fmt.Errorf("The active receipt rule set (%s) was not set to %s", aws.StringValue(response.Metadata.Name), rs.Primary.ID)
if response.Metadata != nil && (aws.ToString(response.Metadata.Name) != rs.Primary.ID) {
return fmt.Errorf("The active receipt rule set (%s) was not set to %s", aws.ToString(response.Metadata.Name), rs.Primary.ID)
}

return nil
Expand Down
Loading

0 comments on commit 9fb9325

Please sign in to comment.