From accf28b037f275ef438f09f779d4b413b1747b8b Mon Sep 17 00:00:00 2001 From: Matt Burgess <549318+mattburgess@users.noreply.github.com> Date: Mon, 17 Jun 2024 23:22:04 +0100 Subject: [PATCH 1/3] elastictranscoder: Migrate to AWS SDK v2 --- go.mod | 7 +- go.sum | 14 +- internal/conns/awsclient_gen.go | 6 +- .../service/elastictranscoder/pipeline.go | 73 ++++----- .../elastictranscoder/pipeline_test.go | 47 +++--- internal/service/elastictranscoder/preset.go | 151 +++++++++--------- .../service/elastictranscoder/preset_test.go | 37 ++--- .../service_endpoints_gen_test.go | 147 ++++++++++++++--- .../elastictranscoder/service_package_gen.go | 36 ++--- names/data/names_data.hcl | 6 +- names/names.go | 1 + 11 files changed, 310 insertions(+), 215 deletions(-) diff --git a/go.mod b/go.mod index 56b93522468..9dda7818567 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/YakDriver/go-version v0.1.0 github.com/YakDriver/regexache v0.23.0 github.com/aws/aws-sdk-go v1.54.2 - github.com/aws/aws-sdk-go-v2 v1.27.2 + github.com/aws/aws-sdk-go-v2 v1.28.0 github.com/aws/aws-sdk-go-v2/config v1.27.18 github.com/aws/aws-sdk-go-v2/credentials v1.17.18 github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.5 @@ -90,6 +90,7 @@ require ( github.com/aws/aws-sdk-go-v2/service/elasticache v1.38.8 github.com/aws/aws-sdk-go-v2/service/elasticbeanstalk v1.23.10 github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.31.3 + github.com/aws/aws-sdk-go-v2/service/elastictranscoder v1.22.11 github.com/aws/aws-sdk-go-v2/service/emr v1.39.11 github.com/aws/aws-sdk-go-v2/service/emrserverless v1.21.2 github.com/aws/aws-sdk-go-v2/service/eventbridge v1.31.5 @@ -245,8 +246,8 @@ require ( github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect github.com/armon/go-radix v1.0.0 // indirect github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.2 // indirect - github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.9 // indirect - github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.9 // indirect + github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.10 // indirect + github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.10 // indirect github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0 // indirect github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.9 // indirect github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.2 // indirect diff --git a/go.sum b/go.sum index f73f5823c5c..59d2bc3fa2c 100644 --- a/go.sum +++ b/go.sum @@ -24,8 +24,8 @@ github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/aws/aws-sdk-go v1.54.2 h1:Wo6AVWcleNHrYa48YzfYz60hzxGRqsJrK5s/qePe+3I= github.com/aws/aws-sdk-go v1.54.2/go.mod h1:eRwEWoyTWFMVYVQzKMNHWP5/RV4xIUGMQfXQHfHkpNU= -github.com/aws/aws-sdk-go-v2 v1.27.2 h1:pLsTXqX93rimAOZG2FIYraDQstZaaGVVN4tNw65v0h8= -github.com/aws/aws-sdk-go-v2 v1.27.2/go.mod h1:ffIFB97e2yNsv4aTSGkqtHnppsIJzw7G7BReUZ3jCXM= +github.com/aws/aws-sdk-go-v2 v1.28.0 h1:ne6ftNhY0lUvlazMUQF15FF6NH80wKmPRFG7g2q6TCw= +github.com/aws/aws-sdk-go-v2 v1.28.0/go.mod h1:ffIFB97e2yNsv4aTSGkqtHnppsIJzw7G7BReUZ3jCXM= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.2 h1:x6xsQXGSmW6frevwDA+vi/wqhp1ct18mVXYN08/93to= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.2/go.mod h1:lPprDr1e6cJdyYeGXnRaJoP4Md+cDBvi2eOj00BlGmg= github.com/aws/aws-sdk-go-v2/config v1.27.18 h1:wFvAnwOKKe7QAyIxziwSKjmer9JBMH1vzIL6W+fYuKk= @@ -36,10 +36,10 @@ github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.5 h1:dDgptDO9dxeFkXy+tEgVkzS github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.5/go.mod h1:gjvE2KBUgUQhcv89jqxrIxH9GaKs1JbZzWejj/DaHGA= github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.16.24 h1:FzNwpVTZDCvm597Ty6mGYvxTolyC1oup0waaKntZI4E= github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.16.24/go.mod h1:wM9NElT/Wn6n3CT1eyVcXtfCy8lSVjjQXfdawQbSShc= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.9 h1:cy8ahBJuhtM8GTTSyOkfy6WVPV1IE+SS5/wfXUYuulw= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.9/go.mod h1:CZBXGLaJnEZI6EVNcPd7a6B5IC5cA/GkRWtu9fp3S6Y= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.9 h1:A4SYk07ef04+vxZToz9LWvAXl9LW0NClpPpMsi31cz0= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.9/go.mod h1:5jJcHuwDagxN+ErjQ3PU3ocf6Ylc/p9x+BLO/+X4iXw= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.10 h1:LZIUb8sQG2cb89QaVFtMSnER10gyKkqU1k3hP3g9das= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.10/go.mod h1:BRIqay//vnIOCZjoXWSLffL2uzbtxEmnSlfbvVh7Z/4= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.10 h1:HY7CXLA0GiQUo3WYxOP7WYkLcwvRX4cLPf5joUcrQGk= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.10/go.mod h1:kfRBSxRa+I+VyON7el3wLZdrO91oxUxEwdAaWgFqN90= github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0 h1:hT8rVHwugYE2lEfdFE0QWVo81lF7jMrYJVDWI+f+VxU= github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0/go.mod h1:8tu/lYfQfFe6IGnaOdrpVgEL2IrrDOf6/m9RQum4NkY= github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.9 h1:vHyZxoLVOgrI8GqX7OMHLXp4YYoxeEsrjweXKpye+ds= @@ -200,6 +200,8 @@ github.com/aws/aws-sdk-go-v2/service/elasticbeanstalk v1.23.10 h1:6MoPaz2J4C47Gi github.com/aws/aws-sdk-go-v2/service/elasticbeanstalk v1.23.10/go.mod h1:uW7bugGF+vIsQdE22S+akMpsB+eZsSjJ6Kv/1lKQT50= github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.31.3 h1:Avh8YS+sgb2OKRht0wdNwY8tqtsCzVrmc8dG8Wfy9LI= github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.31.3/go.mod h1:HbtHaw/hnNPaiqcyYnheILVyn81wOZiX9n2gYF5tPmM= +github.com/aws/aws-sdk-go-v2/service/elastictranscoder v1.22.11 h1:kyGPCefx2yRozrfn6jsWHwzMpm/DvTjVJYwo7Lndtbo= +github.com/aws/aws-sdk-go-v2/service/elastictranscoder v1.22.11/go.mod h1:4JsmTxKCGkcGGvJZXESavEnkpe7DfhUQ0RcwWj1xe5w= github.com/aws/aws-sdk-go-v2/service/emr v1.39.11 h1:PLsio+PhcBMUVjRypTYnZUAZ3qPYVWKmIgp3B8ZZxRM= github.com/aws/aws-sdk-go-v2/service/emr v1.39.11/go.mod h1:c4P6499AxhWdFqbnZ25WX77JfVEWFHWqWj9wITeFqlI= github.com/aws/aws-sdk-go-v2/service/emrserverless v1.21.2 h1:kl5gXTCoi2dEUplPE+p+dpdD/BiOWsp1zKNfd3Onhn4= diff --git a/internal/conns/awsclient_gen.go b/internal/conns/awsclient_gen.go index fa56803e051..1fb5d21a9f7 100644 --- a/internal/conns/awsclient_gen.go +++ b/internal/conns/awsclient_gen.go @@ -82,6 +82,7 @@ import ( elasticache_sdkv2 "github.com/aws/aws-sdk-go-v2/service/elasticache" elasticbeanstalk_sdkv2 "github.com/aws/aws-sdk-go-v2/service/elasticbeanstalk" elasticloadbalancingv2_sdkv2 "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2" + elastictranscoder_sdkv2 "github.com/aws/aws-sdk-go-v2/service/elastictranscoder" emr_sdkv2 "github.com/aws/aws-sdk-go-v2/service/emr" emrserverless_sdkv2 "github.com/aws/aws-sdk-go-v2/service/emrserverless" eventbridge_sdkv2 "github.com/aws/aws-sdk-go-v2/service/eventbridge" @@ -202,7 +203,6 @@ import ( efs_sdkv1 "github.com/aws/aws-sdk-go/service/efs" elasticache_sdkv1 "github.com/aws/aws-sdk-go/service/elasticache" elasticsearchservice_sdkv1 "github.com/aws/aws-sdk-go/service/elasticsearchservice" - elastictranscoder_sdkv1 "github.com/aws/aws-sdk-go/service/elastictranscoder" elb_sdkv1 "github.com/aws/aws-sdk-go/service/elb" elbv2_sdkv1 "github.com/aws/aws-sdk-go/service/elbv2" emr_sdkv1 "github.com/aws/aws-sdk-go/service/emr" @@ -655,8 +655,8 @@ func (c *AWSClient) ElasticBeanstalkClient(ctx context.Context) *elasticbeanstal return errs.Must(client[*elasticbeanstalk_sdkv2.Client](ctx, c, names.ElasticBeanstalk, make(map[string]any))) } -func (c *AWSClient) ElasticTranscoderConn(ctx context.Context) *elastictranscoder_sdkv1.ElasticTranscoder { - return errs.Must(conn[*elastictranscoder_sdkv1.ElasticTranscoder](ctx, c, names.ElasticTranscoder, make(map[string]any))) +func (c *AWSClient) ElasticTranscoderClient(ctx context.Context) *elastictranscoder_sdkv2.Client { + return errs.Must(client[*elastictranscoder_sdkv2.Client](ctx, c, names.ElasticTranscoder, make(map[string]any))) } func (c *AWSClient) ElasticsearchConn(ctx context.Context) *elasticsearchservice_sdkv1.ElasticsearchService { diff --git a/internal/service/elastictranscoder/pipeline.go b/internal/service/elastictranscoder/pipeline.go index 9f97f2f84bf..89ed029398a 100644 --- a/internal/service/elastictranscoder/pipeline.go +++ b/internal/service/elastictranscoder/pipeline.go @@ -8,14 +8,15 @@ import ( "log" "github.com/YakDriver/regexache" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/elastictranscoder" - "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/service/elastictranscoder" + awstypes "github.com/aws/aws-sdk-go-v2/service/elastictranscoder/types" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" "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/internal/flex" "github.com/hashicorp/terraform-provider-aws/internal/verify" @@ -236,7 +237,7 @@ func ResourcePipeline() *schema.Resource { func resourcePipelineCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).ElasticTranscoderConn(ctx) + conn := meta.(*conns.AWSClient).ElasticTranscoderClient(ctx) req := &elastictranscoder.CreatePipelineInput{ AwsKmsKeyArn: aws.String(d.Get("aws_kms_key_arn").(string)), @@ -265,12 +266,12 @@ func resourcePipelineCreate(ctx context.Context, d *schema.ResourceData, meta in } log.Printf("[DEBUG] Elastic Transcoder Pipeline create opts: %s", req) - resp, err := conn.CreatePipelineWithContext(ctx, req) + resp, err := conn.CreatePipeline(ctx, req) if err != nil { return sdkdiag.AppendErrorf(diags, "creating Elastic Transcoder Pipeline: %s", err) } - d.SetId(aws.StringValue(resp.Pipeline.Id)) + d.SetId(aws.ToString(resp.Pipeline.Id)) for _, w := range resp.Warnings { log.Printf("[WARN] Elastic Transcoder Pipeline %v: %v", *w.Code, *w.Message) @@ -279,7 +280,7 @@ func resourcePipelineCreate(ctx context.Context, d *schema.ResourceData, meta in return append(diags, resourcePipelineRead(ctx, d, meta)...) } -func expandETNotifications(d *schema.ResourceData) *elastictranscoder.Notifications { +func expandETNotifications(d *schema.ResourceData) *awstypes.Notifications { list, ok := d.GetOk("notifications") if !ok { return nil @@ -297,7 +298,7 @@ func expandETNotifications(d *schema.ResourceData) *elastictranscoder.Notificati rN := l[0].(map[string]interface{}) - return &elastictranscoder.Notifications{ + return &awstypes.Notifications{ Completed: aws.String(rN["completed"].(string)), Error: aws.String(rN["error"].(string)), Progressing: aws.String(rN["progressing"].(string)), @@ -305,14 +306,14 @@ func expandETNotifications(d *schema.ResourceData) *elastictranscoder.Notificati } } -func flattenETNotifications(n *elastictranscoder.Notifications) []map[string]interface{} { +func flattenETNotifications(n *awstypes.Notifications) []map[string]interface{} { if n == nil { return nil } allEmpty := func(s ...*string) bool { for _, s := range s { - if aws.StringValue(s) != "" { + if aws.ToString(s) != "" { return false } } @@ -325,16 +326,16 @@ func flattenETNotifications(n *elastictranscoder.Notifications) []map[string]int } result := map[string]interface{}{ - "completed": aws.StringValue(n.Completed), - "error": aws.StringValue(n.Error), - "progressing": aws.StringValue(n.Progressing), - "warning": aws.StringValue(n.Warning), + "completed": aws.ToString(n.Completed), + "error": aws.ToString(n.Error), + "progressing": aws.ToString(n.Progressing), + "warning": aws.ToString(n.Warning), } return []map[string]interface{}{result} } -func expandETPiplineOutputConfig(d *schema.ResourceData, key string) *elastictranscoder.PipelineOutputConfig { +func expandETPiplineOutputConfig(d *schema.ResourceData, key string) *awstypes.PipelineOutputConfig { list, ok := d.GetOk(key) if !ok { return nil @@ -347,7 +348,7 @@ func expandETPiplineOutputConfig(d *schema.ResourceData, key string) *elastictra cc := l[0].(map[string]interface{}) - cfg := &elastictranscoder.PipelineOutputConfig{ + cfg := &awstypes.PipelineOutputConfig{ Bucket: aws.String(cc[names.AttrBucket].(string)), StorageClass: aws.String(cc[names.AttrStorageClass].(string)), } @@ -362,21 +363,21 @@ func expandETPiplineOutputConfig(d *schema.ResourceData, key string) *elastictra return cfg } -func flattenETPipelineOutputConfig(cfg *elastictranscoder.PipelineOutputConfig) []map[string]interface{} { +func flattenETPipelineOutputConfig(cfg *awstypes.PipelineOutputConfig) []map[string]interface{} { if cfg == nil { return nil } result := map[string]interface{}{ - names.AttrBucket: aws.StringValue(cfg.Bucket), - names.AttrStorageClass: aws.StringValue(cfg.StorageClass), + names.AttrBucket: aws.ToString(cfg.Bucket), + names.AttrStorageClass: aws.ToString(cfg.StorageClass), } return []map[string]interface{}{result} } -func expandETPermList(permissions *schema.Set) []*elastictranscoder.Permission { - var perms []*elastictranscoder.Permission +func expandETPermList(permissions *schema.Set) []awstypes.Permission { + var perms []awstypes.Permission for _, p := range permissions.List() { if p == nil { @@ -385,8 +386,8 @@ func expandETPermList(permissions *schema.Set) []*elastictranscoder.Permission { m := p.(map[string]interface{}) - perm := &elastictranscoder.Permission{ - Access: flex.ExpandStringList(m["access"].([]interface{})), + perm := awstypes.Permission{ + Access: flex.ExpandStringValueList(m["access"].([]interface{})), Grantee: aws.String(m["grantee"].(string)), GranteeType: aws.String(m["grantee_type"].(string)), } @@ -396,14 +397,14 @@ func expandETPermList(permissions *schema.Set) []*elastictranscoder.Permission { return perms } -func flattenETPermList(perms []*elastictranscoder.Permission) []map[string]interface{} { +func flattenETPermList(perms []awstypes.Permission) []map[string]interface{} { var set []map[string]interface{} for _, p := range perms { result := map[string]interface{}{ - "access": flex.FlattenStringList(p.Access), - "grantee": aws.StringValue(p.Grantee), - "grantee_type": aws.StringValue(p.GranteeType), + "access": flex.FlattenStringValueList(p.Access), + "grantee": aws.ToString(p.Grantee), + "grantee_type": aws.ToString(p.GranteeType), } set = append(set, result) @@ -413,7 +414,7 @@ func flattenETPermList(perms []*elastictranscoder.Permission) []map[string]inter func resourcePipelineUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).ElasticTranscoderConn(ctx) + conn := meta.(*conns.AWSClient).ElasticTranscoderClient(ctx) req := &elastictranscoder.UpdatePipelineInput{ Id: aws.String(d.Id()), @@ -448,14 +449,14 @@ func resourcePipelineUpdate(ctx context.Context, d *schema.ResourceData, meta in } log.Printf("[DEBUG] Updating Elastic Transcoder Pipeline: %#v", req) - output, err := conn.UpdatePipelineWithContext(ctx, req) + output, err := conn.UpdatePipeline(ctx, req) if err != nil { return sdkdiag.AppendErrorf(diags, "updating Elastic Transcoder pipeline: %s", err) } for _, w := range output.Warnings { - log.Printf("[WARN] Elastic Transcoder Pipeline %v: %v", aws.StringValue(w.Code), - aws.StringValue(w.Message)) + log.Printf("[WARN] Elastic Transcoder Pipeline %v: %v", aws.ToString(w.Code), + aws.ToString(w.Message)) } return append(diags, resourcePipelineRead(ctx, d, meta)...) @@ -463,14 +464,14 @@ func resourcePipelineUpdate(ctx context.Context, d *schema.ResourceData, meta in func resourcePipelineRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).ElasticTranscoderConn(ctx) + conn := meta.(*conns.AWSClient).ElasticTranscoderClient(ctx) - resp, err := conn.ReadPipelineWithContext(ctx, &elastictranscoder.ReadPipelineInput{ + resp, err := conn.ReadPipeline(ctx, &elastictranscoder.ReadPipelineInput{ Id: aws.String(d.Id()), }) if err != nil { - if tfawserr.ErrCodeEquals(err, elastictranscoder.ErrCodeResourceNotFoundException) { + if errs.IsA[*awstypes.ResourceNotFoundException](err) { log.Printf("[WARN] Elastic Transcoder Pipeline (%s) not found, removing from state", d.Id()) d.SetId("") return diags @@ -529,10 +530,10 @@ func resourcePipelineRead(ctx context.Context, d *schema.ResourceData, meta inte func resourcePipelineDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).ElasticTranscoderConn(ctx) + conn := meta.(*conns.AWSClient).ElasticTranscoderClient(ctx) log.Printf("[DEBUG] Elastic Transcoder Delete Pipeline: %s", d.Id()) - _, err := conn.DeletePipelineWithContext(ctx, &elastictranscoder.DeletePipelineInput{ + _, err := conn.DeletePipeline(ctx, &elastictranscoder.DeletePipelineInput{ Id: aws.String(d.Id()), }) if err != nil { diff --git a/internal/service/elastictranscoder/pipeline_test.go b/internal/service/elastictranscoder/pipeline_test.go index e0e45aa008c..6c1822a8ec2 100644 --- a/internal/service/elastictranscoder/pipeline_test.go +++ b/internal/service/elastictranscoder/pipeline_test.go @@ -11,21 +11,22 @@ import ( "testing" "github.com/YakDriver/regexache" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/elastictranscoder" - "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/service/elastictranscoder" + awstypes "github.com/aws/aws-sdk-go-v2/service/elastictranscoder/types" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" + "github.com/hashicorp/terraform-provider-aws/internal/errs" tfelastictranscoder "github.com/hashicorp/terraform-provider-aws/internal/service/elastictranscoder" "github.com/hashicorp/terraform-provider-aws/names" ) func TestAccElasticTranscoderPipeline_basic(t *testing.T) { ctx := acctest.Context(t) - pipeline := &elastictranscoder.Pipeline{} + pipeline := &awstypes.Pipeline{} resourceName := "aws_elastictranscoder_pipeline.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -53,7 +54,7 @@ func TestAccElasticTranscoderPipeline_basic(t *testing.T) { func TestAccElasticTranscoderPipeline_kmsKey(t *testing.T) { ctx := acctest.Context(t) - pipeline := &elastictranscoder.Pipeline{} + pipeline := &awstypes.Pipeline{} resourceName := "aws_elastictranscoder_pipeline.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) keyResourceName := "aws_kms_key.test" @@ -82,7 +83,7 @@ func TestAccElasticTranscoderPipeline_kmsKey(t *testing.T) { func TestAccElasticTranscoderPipeline_notifications(t *testing.T) { ctx := acctest.Context(t) - pipeline := elastictranscoder.Pipeline{} + pipeline := awstypes.Pipeline{} resourceName := "aws_elastictranscoder_pipeline.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -119,19 +120,19 @@ func TestAccElasticTranscoderPipeline_notifications(t *testing.T) { // testAccCheckTags can be used to check the tags on a resource. func testAccCheckPipeline_notifications( - p *elastictranscoder.Pipeline, notifications []string) resource.TestCheckFunc { + p *awstypes.Pipeline, notifications []string) resource.TestCheckFunc { return func(s *terraform.State) error { var notes []string - if aws.StringValue(p.Notifications.Completed) != "" { + if aws.ToString(p.Notifications.Completed) != "" { notes = append(notes, "completed") } - if aws.StringValue(p.Notifications.Error) != "" { + if aws.ToString(p.Notifications.Error) != "" { notes = append(notes, "error") } - if aws.StringValue(p.Notifications.Progressing) != "" { + if aws.ToString(p.Notifications.Progressing) != "" { notes = append(notes, "progressing") } - if aws.StringValue(p.Notifications.Warning) != "" { + if aws.ToString(p.Notifications.Warning) != "" { notes = append(notes, "warning") } @@ -152,7 +153,7 @@ func testAccCheckPipeline_notifications( func TestAccElasticTranscoderPipeline_withContent(t *testing.T) { ctx := acctest.Context(t) - pipeline := &elastictranscoder.Pipeline{} + pipeline := &awstypes.Pipeline{} resourceName := "aws_elastictranscoder_pipeline.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -186,7 +187,7 @@ func TestAccElasticTranscoderPipeline_withContent(t *testing.T) { func TestAccElasticTranscoderPipeline_withPermissions(t *testing.T) { ctx := acctest.Context(t) - pipeline := &elastictranscoder.Pipeline{} + pipeline := &awstypes.Pipeline{} resourceName := "aws_elastictranscoder_pipeline.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -214,7 +215,7 @@ func TestAccElasticTranscoderPipeline_withPermissions(t *testing.T) { func TestAccElasticTranscoderPipeline_disappears(t *testing.T) { ctx := acctest.Context(t) - pipeline := &elastictranscoder.Pipeline{} + pipeline := &awstypes.Pipeline{} resourceName := "aws_elastictranscoder_pipeline.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -236,7 +237,7 @@ func TestAccElasticTranscoderPipeline_disappears(t *testing.T) { }) } -func testAccCheckPipelineExists(ctx context.Context, n string, res *elastictranscoder.Pipeline) resource.TestCheckFunc { +func testAccCheckPipelineExists(ctx context.Context, n string, res *awstypes.Pipeline) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] if !ok { @@ -247,9 +248,9 @@ func testAccCheckPipelineExists(ctx context.Context, n string, res *elastictrans return fmt.Errorf("No Pipeline ID is set") } - conn := acctest.Provider.Meta().(*conns.AWSClient).ElasticTranscoderConn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).ElasticTranscoderClient(ctx) - out, err := conn.ReadPipelineWithContext(ctx, &elastictranscoder.ReadPipelineInput{ + out, err := conn.ReadPipeline(ctx, &elastictranscoder.ReadPipelineInput{ Id: aws.String(rs.Primary.ID), }) @@ -265,24 +266,24 @@ func testAccCheckPipelineExists(ctx context.Context, n string, res *elastictrans func testAccCheckPipelineDestroy(ctx context.Context) resource.TestCheckFunc { return func(s *terraform.State) error { - conn := acctest.Provider.Meta().(*conns.AWSClient).ElasticTranscoderConn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).ElasticTranscoderClient(ctx) for _, rs := range s.RootModule().Resources { if rs.Type != "aws_elastictranscoder_pipline" { continue } - out, err := conn.ReadPipelineWithContext(ctx, &elastictranscoder.ReadPipelineInput{ + out, err := conn.ReadPipeline(ctx, &elastictranscoder.ReadPipelineInput{ Id: aws.String(rs.Primary.ID), }) - if tfawserr.ErrCodeEquals(err, elastictranscoder.ErrCodeResourceNotFoundException) { + if errs.IsA[*awstypes.ResourceNotFoundException](err) { continue } if err != nil { return fmt.Errorf("unexpected error: %w", err) } - if out.Pipeline != nil && aws.StringValue(out.Pipeline.Id) == rs.Primary.ID { + if out.Pipeline != nil && aws.ToString(out.Pipeline.Id) == rs.Primary.ID { return fmt.Errorf("Elastic Transcoder Pipeline still exists") } } @@ -291,11 +292,11 @@ func testAccCheckPipelineDestroy(ctx context.Context) resource.TestCheckFunc { } func testAccPreCheck(ctx context.Context, t *testing.T) { - conn := acctest.Provider.Meta().(*conns.AWSClient).ElasticTranscoderConn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).ElasticTranscoderClient(ctx) input := &elastictranscoder.ListPipelinesInput{} - _, err := conn.ListPipelinesWithContext(ctx, input) + _, err := conn.ListPipelines(ctx, input) if acctest.PreCheckSkipError(err) { t.Skipf("skipping acceptance testing: %s", err) diff --git a/internal/service/elastictranscoder/preset.go b/internal/service/elastictranscoder/preset.go index 6d08446043c..c87833fa3e7 100644 --- a/internal/service/elastictranscoder/preset.go +++ b/internal/service/elastictranscoder/preset.go @@ -7,14 +7,15 @@ import ( "context" "log" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/elastictranscoder" - "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/service/elastictranscoder" + awstypes "github.com/aws/aws-sdk-go-v2/service/elastictranscoder/types" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" "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/internal/flex" "github.com/hashicorp/terraform-provider-aws/names" @@ -42,7 +43,7 @@ func ResourcePreset() *schema.Resource { ForceNew: true, MaxItems: 1, Elem: &schema.Resource{ - // elastictranscoder.AudioParameters + // awstypes.AudioParameters Schema: map[string]*schema.Schema{ "audio_packing_mode": { Type: schema.TypeString, @@ -281,7 +282,7 @@ func ResourcePreset() *schema.Resource { ForceNew: true, MaxItems: 1, Elem: &schema.Resource{ - // elastictranscoder.VideoParameters + // awstypes.VideoParameters Schema: map[string]*schema.Schema{ "aspect_ratio": { Type: schema.TypeString, @@ -420,7 +421,7 @@ func ResourcePreset() *schema.Resource { Optional: true, ForceNew: true, Elem: &schema.Resource{ - // elastictranscoder.PresetWatermark + // awstypes.PresetWatermark Schema: map[string]*schema.Schema{ "horizontal_align": { Type: schema.TypeString, @@ -508,7 +509,7 @@ func ResourcePreset() *schema.Resource { func resourcePresetCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).ElasticTranscoderConn(ctx) + conn := meta.(*conns.AWSClient).ElasticTranscoderClient(ctx) req := &elastictranscoder.CreatePresetInput{ Audio: expandETAudioParams(d), @@ -527,21 +528,21 @@ func resourcePresetCreate(ctx context.Context, d *schema.ResourceData, meta inte } log.Printf("[DEBUG] Elastic Transcoder Preset create opts: %s", req) - resp, err := conn.CreatePresetWithContext(ctx, req) + resp, err := conn.CreatePreset(ctx, req) if err != nil { return sdkdiag.AppendErrorf(diags, "creating Elastic Transcoder Preset: %s", err) } - if aws.StringValue(resp.Warning) != "" { - log.Printf("[WARN] Elastic Transcoder Preset: %s", aws.StringValue(resp.Warning)) + if aws.ToString(resp.Warning) != "" { + log.Printf("[WARN] Elastic Transcoder Preset: %s", aws.ToString(resp.Warning)) } - d.SetId(aws.StringValue(resp.Preset.Id)) + d.SetId(aws.ToString(resp.Preset.Id)) return append(diags, resourcePresetRead(ctx, d, meta)...) } -func expandETThumbnails(d *schema.ResourceData) *elastictranscoder.Thumbnails { +func expandETThumbnails(d *schema.ResourceData) *awstypes.Thumbnails { list, ok := d.GetOk("thumbnails") if !ok { return nil @@ -553,7 +554,7 @@ func expandETThumbnails(d *schema.ResourceData) *elastictranscoder.Thumbnails { } t := l[0].(map[string]interface{}) - thumbnails := &elastictranscoder.Thumbnails{} + thumbnails := &awstypes.Thumbnails{} if v, ok := t["aspect_ratio"]; ok && v.(string) != "" { thumbnails.AspectRatio = aws.String(v.(string)) @@ -590,7 +591,7 @@ func expandETThumbnails(d *schema.ResourceData) *elastictranscoder.Thumbnails { return thumbnails } -func expandETAudioParams(d *schema.ResourceData) *elastictranscoder.AudioParameters { +func expandETAudioParams(d *schema.ResourceData) *awstypes.AudioParameters { list, ok := d.GetOk("audio") if !ok { return nil @@ -602,7 +603,7 @@ func expandETAudioParams(d *schema.ResourceData) *elastictranscoder.AudioParamet } audio := l[0].(map[string]interface{}) - ap := &elastictranscoder.AudioParameters{ + ap := &awstypes.AudioParameters{ AudioPackingMode: aws.String(audio["audio_packing_mode"].(string)), Channels: aws.String(audio["channels"].(string)), Codec: aws.String(audio["codec"].(string)), @@ -617,7 +618,7 @@ func expandETAudioParams(d *schema.ResourceData) *elastictranscoder.AudioParamet return ap } -func expandETAudioCodecOptions(d *schema.ResourceData) *elastictranscoder.AudioCodecOptions { +func expandETAudioCodecOptions(d *schema.ResourceData) *awstypes.AudioCodecOptions { l := d.Get("audio_codec_options").([]interface{}) if len(l) == 0 || l[0] == nil { return nil @@ -625,7 +626,7 @@ func expandETAudioCodecOptions(d *schema.ResourceData) *elastictranscoder.AudioC codec := l[0].(map[string]interface{}) - codecOpts := &elastictranscoder.AudioCodecOptions{} + codecOpts := &awstypes.AudioCodecOptions{} if v, ok := codec["signed"]; ok && v.(string) != "" { codecOpts.Signed = aws.String(v.(string)) @@ -646,21 +647,21 @@ func expandETAudioCodecOptions(d *schema.ResourceData) *elastictranscoder.AudioC return codecOpts } -func expandETVideoParams(d *schema.ResourceData) *elastictranscoder.VideoParameters { +func expandETVideoParams(d *schema.ResourceData) *awstypes.VideoParameters { l := d.Get("video").([]interface{}) if len(l) == 0 || l[0] == nil { return nil } p := l[0].(map[string]interface{}) - etVideoParams := &elastictranscoder.VideoParameters{ + etVideoParams := &awstypes.VideoParameters{ Watermarks: expandETVideoWatermarks(d), } if v, ok := d.GetOk("video_codec_options"); ok && len(v.(map[string]interface{})) > 0 { - etVideoParams.CodecOptions = flex.ExpandStringMap(v.(map[string]interface{})) + etVideoParams.CodecOptions = flex.ExpandStringValueMap(v.(map[string]interface{})) } else { - etVideoParams.CodecOptions = aws.StringMap(make(map[string]string)) + etVideoParams.CodecOptions = make(map[string]string) } if v, ok := p["aspect_ratio"]; ok && v.(string) != "" { @@ -722,12 +723,12 @@ func expandETVideoParams(d *schema.ResourceData) *elastictranscoder.VideoParamet return etVideoParams } -func expandETVideoWatermarks(d *schema.ResourceData) []*elastictranscoder.PresetWatermark { +func expandETVideoWatermarks(d *schema.ResourceData) []awstypes.PresetWatermark { s := d.Get("video_watermarks").(*schema.Set) if s == nil || s.Len() == 0 { return nil } - var watermarks []*elastictranscoder.PresetWatermark + var watermarks []awstypes.PresetWatermark for _, w := range s.List() { if w == nil { @@ -735,7 +736,7 @@ func expandETVideoWatermarks(d *schema.ResourceData) []*elastictranscoder.Preset } p := w.(map[string]interface{}) - watermark := &elastictranscoder.PresetWatermark{ + watermark := awstypes.PresetWatermark{ HorizontalAlign: aws.String(p["horizontal_align"].(string)), HorizontalOffset: aws.String(p["horizontal_offset"].(string)), Id: aws.String(p[names.AttrID].(string)), @@ -755,14 +756,14 @@ func expandETVideoWatermarks(d *schema.ResourceData) []*elastictranscoder.Preset func resourcePresetRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).ElasticTranscoderConn(ctx) + conn := meta.(*conns.AWSClient).ElasticTranscoderClient(ctx) - resp, err := conn.ReadPresetWithContext(ctx, &elastictranscoder.ReadPresetInput{ + resp, err := conn.ReadPreset(ctx, &elastictranscoder.ReadPresetInput{ Id: aws.String(d.Id()), }) if err != nil { - if tfawserr.ErrCodeEquals(err, elastictranscoder.ErrCodeResourceNotFoundException) { + if errs.IsA[*awstypes.ResourceNotFoundException](err) { log.Printf("[WARN] Elastic Transcoder Preset (%s) not found, removing from state", d.Id()) d.SetId("") return diags @@ -805,7 +806,7 @@ func resourcePresetRead(ctx context.Context, d *schema.ResourceData, meta interf } if preset.Video.CodecOptions != nil { - if err := d.Set("video_codec_options", aws.StringValueMap(preset.Video.CodecOptions)); err != nil { + if err := d.Set("video_codec_options", preset.Video.CodecOptions); err != nil { return sdkdiag.AppendErrorf(diags, "reading Elastic Transcoder Preset (%s): setting video_codec_options: %s", d.Id(), err) } } @@ -820,98 +821,98 @@ func resourcePresetRead(ctx context.Context, d *schema.ResourceData, meta interf return diags } -func flattenETAudioParameters(audio *elastictranscoder.AudioParameters) []map[string]interface{} { +func flattenETAudioParameters(audio *awstypes.AudioParameters) []map[string]interface{} { if audio == nil { return nil } result := map[string]interface{}{ - "audio_packing_mode": aws.StringValue(audio.AudioPackingMode), - "channels": aws.StringValue(audio.Channels), - "codec": aws.StringValue(audio.Codec), - "sample_rate": aws.StringValue(audio.SampleRate), + "audio_packing_mode": aws.ToString(audio.AudioPackingMode), + "channels": aws.ToString(audio.Channels), + "codec": aws.ToString(audio.Codec), + "sample_rate": aws.ToString(audio.SampleRate), } if audio.BitRate != nil { - result["bit_rate"] = aws.StringValue(audio.BitRate) + result["bit_rate"] = aws.ToString(audio.BitRate) } return []map[string]interface{}{result} } -func flattenETAudioCodecOptions(opts *elastictranscoder.AudioCodecOptions) []map[string]interface{} { +func flattenETAudioCodecOptions(opts *awstypes.AudioCodecOptions) []map[string]interface{} { if opts == nil { return nil } result := map[string]interface{}{ - "bit_depth": aws.StringValue(opts.BitDepth), - "bit_order": aws.StringValue(opts.BitOrder), - names.AttrProfile: aws.StringValue(opts.Profile), - "signed": aws.StringValue(opts.Signed), + "bit_depth": aws.ToString(opts.BitDepth), + "bit_order": aws.ToString(opts.BitOrder), + names.AttrProfile: aws.ToString(opts.Profile), + "signed": aws.ToString(opts.Signed), } return []map[string]interface{}{result} } -func flattenETThumbnails(thumbs *elastictranscoder.Thumbnails) []map[string]interface{} { +func flattenETThumbnails(thumbs *awstypes.Thumbnails) []map[string]interface{} { if thumbs == nil { return nil } result := map[string]interface{}{ - "aspect_ratio": aws.StringValue(thumbs.AspectRatio), - names.AttrFormat: aws.StringValue(thumbs.Format), - names.AttrInterval: aws.StringValue(thumbs.Interval), - "max_height": aws.StringValue(thumbs.MaxHeight), - "max_width": aws.StringValue(thumbs.MaxWidth), - "padding_policy": aws.StringValue(thumbs.PaddingPolicy), - "resolution": aws.StringValue(thumbs.Resolution), - "sizing_policy": aws.StringValue(thumbs.SizingPolicy), + "aspect_ratio": aws.ToString(thumbs.AspectRatio), + names.AttrFormat: aws.ToString(thumbs.Format), + names.AttrInterval: aws.ToString(thumbs.Interval), + "max_height": aws.ToString(thumbs.MaxHeight), + "max_width": aws.ToString(thumbs.MaxWidth), + "padding_policy": aws.ToString(thumbs.PaddingPolicy), + "resolution": aws.ToString(thumbs.Resolution), + "sizing_policy": aws.ToString(thumbs.SizingPolicy), } return []map[string]interface{}{result} } -func flattenETVideoParams(video *elastictranscoder.VideoParameters) []map[string]interface{} { +func flattenETVideoParams(video *awstypes.VideoParameters) []map[string]interface{} { if video == nil { return nil } result := map[string]interface{}{ - "aspect_ratio": aws.StringValue(video.AspectRatio), - "bit_rate": aws.StringValue(video.BitRate), - "codec": aws.StringValue(video.Codec), - "display_aspect_ratio": aws.StringValue(video.DisplayAspectRatio), - "fixed_gop": aws.StringValue(video.FixedGOP), - "frame_rate": aws.StringValue(video.FrameRate), - "keyframes_max_dist": aws.StringValue(video.KeyframesMaxDist), - "max_frame_rate": aws.StringValue(video.MaxFrameRate), - "max_height": aws.StringValue(video.MaxHeight), - "max_width": aws.StringValue(video.MaxWidth), - "padding_policy": aws.StringValue(video.PaddingPolicy), - "resolution": aws.StringValue(video.Resolution), - "sizing_policy": aws.StringValue(video.SizingPolicy), + "aspect_ratio": aws.ToString(video.AspectRatio), + "bit_rate": aws.ToString(video.BitRate), + "codec": aws.ToString(video.Codec), + "display_aspect_ratio": aws.ToString(video.DisplayAspectRatio), + "fixed_gop": aws.ToString(video.FixedGOP), + "frame_rate": aws.ToString(video.FrameRate), + "keyframes_max_dist": aws.ToString(video.KeyframesMaxDist), + "max_frame_rate": aws.ToString(video.MaxFrameRate), + "max_height": aws.ToString(video.MaxHeight), + "max_width": aws.ToString(video.MaxWidth), + "padding_policy": aws.ToString(video.PaddingPolicy), + "resolution": aws.ToString(video.Resolution), + "sizing_policy": aws.ToString(video.SizingPolicy), } return []map[string]interface{}{result} } -func flattenETWatermarks(watermarks []*elastictranscoder.PresetWatermark) []map[string]interface{} { +func flattenETWatermarks(watermarks []awstypes.PresetWatermark) []map[string]interface{} { var watermarkSet []map[string]interface{} for _, w := range watermarks { watermark := map[string]interface{}{ - "horizontal_align": aws.StringValue(w.HorizontalAlign), - "horizontal_offset": aws.StringValue(w.HorizontalOffset), - names.AttrID: aws.StringValue(w.Id), - "max_height": aws.StringValue(w.MaxHeight), - "max_width": aws.StringValue(w.MaxWidth), - "opacity": aws.StringValue(w.Opacity), - "sizing_policy": aws.StringValue(w.SizingPolicy), - names.AttrTarget: aws.StringValue(w.Target), - "vertical_align": aws.StringValue(w.VerticalAlign), - "vertical_offset": aws.StringValue(w.VerticalOffset), + "horizontal_align": aws.ToString(w.HorizontalAlign), + "horizontal_offset": aws.ToString(w.HorizontalOffset), + names.AttrID: aws.ToString(w.Id), + "max_height": aws.ToString(w.MaxHeight), + "max_width": aws.ToString(w.MaxWidth), + "opacity": aws.ToString(w.Opacity), + "sizing_policy": aws.ToString(w.SizingPolicy), + names.AttrTarget: aws.ToString(w.Target), + "vertical_align": aws.ToString(w.VerticalAlign), + "vertical_offset": aws.ToString(w.VerticalOffset), } watermarkSet = append(watermarkSet, watermark) @@ -922,10 +923,10 @@ func flattenETWatermarks(watermarks []*elastictranscoder.PresetWatermark) []map[ func resourcePresetDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).ElasticTranscoderConn(ctx) + conn := meta.(*conns.AWSClient).ElasticTranscoderClient(ctx) log.Printf("[DEBUG] Elastic Transcoder Delete Preset: %s", d.Id()) - _, err := conn.DeletePresetWithContext(ctx, &elastictranscoder.DeletePresetInput{ + _, err := conn.DeletePreset(ctx, &elastictranscoder.DeletePresetInput{ Id: aws.String(d.Id()), }) diff --git a/internal/service/elastictranscoder/preset_test.go b/internal/service/elastictranscoder/preset_test.go index 5516d461cea..b24bfb343c0 100644 --- a/internal/service/elastictranscoder/preset_test.go +++ b/internal/service/elastictranscoder/preset_test.go @@ -9,21 +9,22 @@ import ( "testing" "github.com/YakDriver/regexache" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/elastictranscoder" - "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/service/elastictranscoder" + awstypes "github.com/aws/aws-sdk-go-v2/service/elastictranscoder/types" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" + "github.com/hashicorp/terraform-provider-aws/internal/errs" tfet "github.com/hashicorp/terraform-provider-aws/internal/service/elastictranscoder" "github.com/hashicorp/terraform-provider-aws/names" ) func TestAccElasticTranscoderPreset_basic(t *testing.T) { ctx := acctest.Context(t) - var preset elastictranscoder.Preset + var preset awstypes.Preset resourceName := "aws_elastictranscoder_preset.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -51,7 +52,7 @@ func TestAccElasticTranscoderPreset_basic(t *testing.T) { func TestAccElasticTranscoderPreset_video_noCodec(t *testing.T) { ctx := acctest.Context(t) - var preset elastictranscoder.Preset + var preset awstypes.Preset resourceName := "aws_elastictranscoder_preset.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -79,7 +80,7 @@ func TestAccElasticTranscoderPreset_video_noCodec(t *testing.T) { // https://github.com/terraform-providers/terraform-provider-aws/issues/14090 func TestAccElasticTranscoderPreset_audio_noBitRate(t *testing.T) { ctx := acctest.Context(t) - var preset elastictranscoder.Preset + var preset awstypes.Preset resourceName := "aws_elastictranscoder_preset.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -106,7 +107,7 @@ func TestAccElasticTranscoderPreset_audio_noBitRate(t *testing.T) { func TestAccElasticTranscoderPreset_disappears(t *testing.T) { ctx := acctest.Context(t) - var preset elastictranscoder.Preset + var preset awstypes.Preset resourceName := "aws_elastictranscoder_preset.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -131,7 +132,7 @@ func TestAccElasticTranscoderPreset_disappears(t *testing.T) { // Reference: https://github.com/hashicorp/terraform-provider-aws/issues/14087 func TestAccElasticTranscoderPreset_AudioCodecOptions_empty(t *testing.T) { ctx := acctest.Context(t) - var preset elastictranscoder.Preset + var preset awstypes.Preset resourceName := "aws_elastictranscoder_preset.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -159,7 +160,7 @@ func TestAccElasticTranscoderPreset_AudioCodecOptions_empty(t *testing.T) { func TestAccElasticTranscoderPreset_description(t *testing.T) { ctx := acctest.Context(t) - var preset elastictranscoder.Preset + var preset awstypes.Preset resourceName := "aws_elastictranscoder_preset.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -188,7 +189,7 @@ func TestAccElasticTranscoderPreset_description(t *testing.T) { // Tests all configuration blocks func TestAccElasticTranscoderPreset_full(t *testing.T) { ctx := acctest.Context(t) - var preset elastictranscoder.Preset + var preset awstypes.Preset resourceName := "aws_elastictranscoder_preset.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -239,7 +240,7 @@ func TestAccElasticTranscoderPreset_full(t *testing.T) { // Reference: https://github.com/hashicorp/terraform-provider-aws/issues/695 func TestAccElasticTranscoderPreset_Video_frameRate(t *testing.T) { ctx := acctest.Context(t) - var preset elastictranscoder.Preset + var preset awstypes.Preset resourceName := "aws_elastictranscoder_preset.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -265,9 +266,9 @@ func TestAccElasticTranscoderPreset_Video_frameRate(t *testing.T) { }) } -func testAccCheckPresetExists(ctx context.Context, name string, preset *elastictranscoder.Preset) resource.TestCheckFunc { +func testAccCheckPresetExists(ctx context.Context, name string, preset *awstypes.Preset) resource.TestCheckFunc { return func(s *terraform.State) error { - conn := acctest.Provider.Meta().(*conns.AWSClient).ElasticTranscoderConn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).ElasticTranscoderClient(ctx) rs, ok := s.RootModule().Resources[name] if !ok { @@ -277,7 +278,7 @@ func testAccCheckPresetExists(ctx context.Context, name string, preset *elastict return fmt.Errorf("No Preset ID is set") } - out, err := conn.ReadPresetWithContext(ctx, &elastictranscoder.ReadPresetInput{ + out, err := conn.ReadPreset(ctx, &elastictranscoder.ReadPresetInput{ Id: aws.String(rs.Primary.ID), }) @@ -293,24 +294,24 @@ func testAccCheckPresetExists(ctx context.Context, name string, preset *elastict func testAccCheckPresetDestroy(ctx context.Context) resource.TestCheckFunc { return func(s *terraform.State) error { - conn := acctest.Provider.Meta().(*conns.AWSClient).ElasticTranscoderConn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).ElasticTranscoderClient(ctx) for _, rs := range s.RootModule().Resources { if rs.Type != "aws_elastictranscoder_preset" { continue } - out, err := conn.ReadPresetWithContext(ctx, &elastictranscoder.ReadPresetInput{ + out, err := conn.ReadPreset(ctx, &elastictranscoder.ReadPresetInput{ Id: aws.String(rs.Primary.ID), }) if err == nil { - if out.Preset != nil && aws.StringValue(out.Preset.Id) == rs.Primary.ID { + if out.Preset != nil && aws.ToString(out.Preset.Id) == rs.Primary.ID { return fmt.Errorf("Elastic Transcoder Preset still exists") } } - if !tfawserr.ErrCodeEquals(err, elastictranscoder.ErrCodeResourceNotFoundException) { + if !errs.IsA[*awstypes.ResourceNotFoundException](err) { return fmt.Errorf("unexpected error: %s", err) } } diff --git a/internal/service/elastictranscoder/service_endpoints_gen_test.go b/internal/service/elastictranscoder/service_endpoints_gen_test.go index 6ad3a92103e..adce04cf928 100644 --- a/internal/service/elastictranscoder/service_endpoints_gen_test.go +++ b/internal/service/elastictranscoder/service_endpoints_gen_test.go @@ -4,17 +4,20 @@ package elastictranscoder_test import ( "context" + "errors" "fmt" "maps" - "net/url" "os" "path/filepath" + "reflect" "strings" "testing" - aws_sdkv1 "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/endpoints" - elastictranscoder_sdkv1 "github.com/aws/aws-sdk-go/service/elastictranscoder" + aws_sdkv2 "github.com/aws/aws-sdk-go-v2/aws" + awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" + elastictranscoder_sdkv2 "github.com/aws/aws-sdk-go-v2/service/elastictranscoder" + "github.com/aws/smithy-go/middleware" + smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -239,54 +242,63 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S } func defaultEndpoint(region string) string { - r := endpoints.DefaultResolver() + r := elastictranscoder_sdkv2.NewDefaultEndpointResolverV2() - ep, err := r.EndpointFor(elastictranscoder_sdkv1.EndpointsID, region) + ep, err := r.ResolveEndpoint(context.Background(), elastictranscoder_sdkv2.EndpointParameters{ + Region: aws_sdkv2.String(region), + }) if err != nil { return err.Error() } - url, _ := url.Parse(ep.URL) - - if url.Path == "" { - url.Path = "/" + if ep.URI.Path == "" { + ep.URI.Path = "/" } - return url.String() + return ep.URI.String() } func defaultFIPSEndpoint(region string) string { - r := endpoints.DefaultResolver() + r := elastictranscoder_sdkv2.NewDefaultEndpointResolverV2() - ep, err := r.EndpointFor(elastictranscoder_sdkv1.EndpointsID, region, func(opt *endpoints.Options) { - opt.UseFIPSEndpoint = endpoints.FIPSEndpointStateEnabled + ep, err := r.ResolveEndpoint(context.Background(), elastictranscoder_sdkv2.EndpointParameters{ + Region: aws_sdkv2.String(region), + UseFIPS: aws_sdkv2.Bool(true), }) if err != nil { return err.Error() } - url, _ := url.Parse(ep.URL) - - if url.Path == "" { - url.Path = "/" + if ep.URI.Path == "" { + ep.URI.Path = "/" } - return url.String() + return ep.URI.String() } func callService(ctx context.Context, t *testing.T, meta *conns.AWSClient) apiCallParams { t.Helper() - client := meta.ElasticTranscoderConn(ctx) + client := meta.ElasticTranscoderClient(ctx) - req, _ := client.ListPipelinesRequest(&elastictranscoder_sdkv1.ListPipelinesInput{}) + var result apiCallParams - req.HTTPRequest.URL.Path = "/" - - return apiCallParams{ - endpoint: req.HTTPRequest.URL.String(), - region: aws_sdkv1.StringValue(client.Config.Region), + _, err := client.ListPipelines(ctx, &elastictranscoder_sdkv2.ListPipelinesInput{}, + func(opts *elastictranscoder_sdkv2.Options) { + opts.APIOptions = append(opts.APIOptions, + addRetrieveEndpointURLMiddleware(t, &result.endpoint), + addRetrieveRegionMiddleware(&result.region), + addCancelRequestMiddleware(), + ) + }, + ) + if err == nil { + t.Fatal("Expected an error, got none") + } else if !errors.Is(err, errCancelOperation) { + t.Fatalf("Unexpected error: %s", err) } + + return result } func withNoConfig(_ *caseSetup) { @@ -443,6 +455,89 @@ func testEndpointCase(t *testing.T, region string, testcase endpointTestCase, ca } } +func addRetrieveEndpointURLMiddleware(t *testing.T, endpoint *string) func(*middleware.Stack) error { + return func(stack *middleware.Stack) error { + return stack.Finalize.Add( + retrieveEndpointURLMiddleware(t, endpoint), + middleware.After, + ) + } +} + +func retrieveEndpointURLMiddleware(t *testing.T, endpoint *string) middleware.FinalizeMiddleware { + return middleware.FinalizeMiddlewareFunc( + "Test: Retrieve Endpoint", + func(ctx context.Context, in middleware.FinalizeInput, next middleware.FinalizeHandler) (middleware.FinalizeOutput, middleware.Metadata, error) { + t.Helper() + + request, ok := in.Request.(*smithyhttp.Request) + if !ok { + t.Fatalf("Expected *github.com/aws/smithy-go/transport/http.Request, got %s", fullTypeName(in.Request)) + } + + url := request.URL + url.RawQuery = "" + url.Path = "/" + + *endpoint = url.String() + + return next.HandleFinalize(ctx, in) + }) +} + +func addRetrieveRegionMiddleware(region *string) func(*middleware.Stack) error { + return func(stack *middleware.Stack) error { + return stack.Serialize.Add( + retrieveRegionMiddleware(region), + middleware.After, + ) + } +} + +func retrieveRegionMiddleware(region *string) middleware.SerializeMiddleware { + return middleware.SerializeMiddlewareFunc( + "Test: Retrieve Region", + func(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) (middleware.SerializeOutput, middleware.Metadata, error) { + *region = awsmiddleware.GetRegion(ctx) + + return next.HandleSerialize(ctx, in) + }, + ) +} + +var errCancelOperation = fmt.Errorf("Test: Canceling request") + +func addCancelRequestMiddleware() func(*middleware.Stack) error { + return func(stack *middleware.Stack) error { + return stack.Finalize.Add( + cancelRequestMiddleware(), + middleware.After, + ) + } +} + +// cancelRequestMiddleware creates a Smithy middleware that intercepts the request before sending and cancels it +func cancelRequestMiddleware() middleware.FinalizeMiddleware { + return middleware.FinalizeMiddlewareFunc( + "Test: Cancel Requests", + func(_ context.Context, in middleware.FinalizeInput, next middleware.FinalizeHandler) (middleware.FinalizeOutput, middleware.Metadata, error) { + return middleware.FinalizeOutput{}, middleware.Metadata{}, errCancelOperation + }) +} + +func fullTypeName(i interface{}) string { + return fullValueTypeName(reflect.ValueOf(i)) +} + +func fullValueTypeName(v reflect.Value) string { + if v.Kind() == reflect.Ptr { + return "*" + fullValueTypeName(reflect.Indirect(v)) + } + + requestType := v.Type() + return fmt.Sprintf("%s.%s", requestType.PkgPath(), requestType.Name()) +} + func generateSharedConfigFile(config configFile) string { var buf strings.Builder diff --git a/internal/service/elastictranscoder/service_package_gen.go b/internal/service/elastictranscoder/service_package_gen.go index 632576761a2..d7ed700dd53 100644 --- a/internal/service/elastictranscoder/service_package_gen.go +++ b/internal/service/elastictranscoder/service_package_gen.go @@ -5,10 +5,8 @@ package elastictranscoder import ( "context" - aws_sdkv1 "github.com/aws/aws-sdk-go/aws" - endpoints_sdkv1 "github.com/aws/aws-sdk-go/aws/endpoints" - session_sdkv1 "github.com/aws/aws-sdk-go/aws/session" - elastictranscoder_sdkv1 "github.com/aws/aws-sdk-go/service/elastictranscoder" + aws_sdkv2 "github.com/aws/aws-sdk-go-v2/aws" + elastictranscoder_sdkv2 "github.com/aws/aws-sdk-go-v2/service/elastictranscoder" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-provider-aws/internal/conns" "github.com/hashicorp/terraform-provider-aws/internal/types" @@ -46,25 +44,23 @@ func (p *servicePackage) ServicePackageName() string { return names.ElasticTranscoder } -// NewConn returns a new AWS SDK for Go v1 client for this service package's AWS API. -func (p *servicePackage) NewConn(ctx context.Context, config map[string]any) (*elastictranscoder_sdkv1.ElasticTranscoder, error) { - sess := config[names.AttrSession].(*session_sdkv1.Session) +// NewClient returns a new AWS SDK for Go v2 client for this service package's AWS API. +func (p *servicePackage) NewClient(ctx context.Context, config map[string]any) (*elastictranscoder_sdkv2.Client, error) { + cfg := *(config["aws_sdkv2_config"].(*aws_sdkv2.Config)) - cfg := aws_sdkv1.Config{} + return elastictranscoder_sdkv2.NewFromConfig(cfg, func(o *elastictranscoder_sdkv2.Options) { + if endpoint := config[names.AttrEndpoint].(string); endpoint != "" { + tflog.Debug(ctx, "setting endpoint", map[string]any{ + "tf_aws.endpoint": endpoint, + }) + o.BaseEndpoint = aws_sdkv2.String(endpoint) - if endpoint := config[names.AttrEndpoint].(string); endpoint != "" { - tflog.Debug(ctx, "setting endpoint", map[string]any{ - "tf_aws.endpoint": endpoint, - }) - cfg.Endpoint = aws_sdkv1.String(endpoint) - - if sess.Config.UseFIPSEndpoint == endpoints_sdkv1.FIPSEndpointStateEnabled { - tflog.Debug(ctx, "endpoint set, ignoring UseFIPSEndpoint setting") - cfg.UseFIPSEndpoint = endpoints_sdkv1.FIPSEndpointStateDisabled + if o.EndpointOptions.UseFIPSEndpoint == aws_sdkv2.FIPSEndpointStateEnabled { + tflog.Debug(ctx, "endpoint set, ignoring UseFIPSEndpoint setting") + o.EndpointOptions.UseFIPSEndpoint = aws_sdkv2.FIPSEndpointStateDisabled + } } - } - - return elastictranscoder_sdkv1.New(sess.Copy(&cfg)), nil + }), nil } func ServicePackage(ctx context.Context) conns.ServicePackage { diff --git a/names/data/names_data.hcl b/names/data/names_data.hcl index 0168a7dc585..35d92c6e4fc 100644 --- a/names/data/names_data.hcl +++ b/names/data/names_data.hcl @@ -3339,7 +3339,7 @@ service "elastictranscoder" { sdk { id = "Elastic Transcoder" - client_version = [1] + client_version = [2] } names { @@ -3347,10 +3347,6 @@ service "elastictranscoder" { human_friendly = "Elastic Transcoder" } - client { - go_v1_client_typename = "ElasticTranscoder" - } - endpoint_info { endpoint_api_call = "ListPipelines" } diff --git a/names/names.go b/names/names.go index 39923e10b49..75dcd8c677a 100644 --- a/names/names.go +++ b/names/names.go @@ -64,6 +64,7 @@ const ( ECREndpointID = "api.ecr" EKSEndpointID = "eks" EMREndpointID = "elasticmapreduce" + ElasticTranscoderEndpointID = "elastictranscoder" EventsEndpointID = "events" EvidentlyEndpointID = "evidently" FMSEndpointID = "fms" From d9ad2b72c9f014010ac4ad9bfad60169c9f5d642 Mon Sep 17 00:00:00 2001 From: Matt Burgess <549318+mattburgess@users.noreply.github.com> Date: Tue, 18 Jun 2024 17:07:43 +0100 Subject: [PATCH 2/3] Fix lint --- internal/service/elastictranscoder/pipeline.go | 2 +- internal/service/elastictranscoder/preset.go | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/internal/service/elastictranscoder/pipeline.go b/internal/service/elastictranscoder/pipeline.go index 89ed029398a..d380e6f2786 100644 --- a/internal/service/elastictranscoder/pipeline.go +++ b/internal/service/elastictranscoder/pipeline.go @@ -265,7 +265,7 @@ func resourcePipelineCreate(ctx context.Context, d *schema.ResourceData, meta in return sdkdiag.AppendErrorf(diags, "you must specify only one of output_bucket or content_config.bucket") } - log.Printf("[DEBUG] Elastic Transcoder Pipeline create opts: %s", req) + log.Printf("[DEBUG] Elastic Transcoder Pipeline create opts: %+v", req) resp, err := conn.CreatePipeline(ctx, req) if err != nil { return sdkdiag.AppendErrorf(diags, "creating Elastic Transcoder Pipeline: %s", err) diff --git a/internal/service/elastictranscoder/preset.go b/internal/service/elastictranscoder/preset.go index c87833fa3e7..de6cd7f6322 100644 --- a/internal/service/elastictranscoder/preset.go +++ b/internal/service/elastictranscoder/preset.go @@ -527,7 +527,7 @@ func resourcePresetCreate(ctx context.Context, d *schema.ResourceData, meta inte req.Name = aws.String(name) } - log.Printf("[DEBUG] Elastic Transcoder Preset create opts: %s", req) + log.Printf("[DEBUG] Elastic Transcoder Preset create opts: %+v", req) resp, err := conn.CreatePreset(ctx, req) if err != nil { return sdkdiag.AppendErrorf(diags, "creating Elastic Transcoder Preset: %s", err) @@ -805,10 +805,8 @@ func resourcePresetRead(ctx context.Context, d *schema.ResourceData, meta interf return sdkdiag.AppendErrorf(diags, "reading Elastic Transcoder Preset (%s): setting video: %s", d.Id(), err) } - if preset.Video.CodecOptions != nil { - if err := d.Set("video_codec_options", preset.Video.CodecOptions); err != nil { - return sdkdiag.AppendErrorf(diags, "reading Elastic Transcoder Preset (%s): setting video_codec_options: %s", d.Id(), err) - } + if err := d.Set("video_codec_options", preset.Video.CodecOptions); err != nil { + return sdkdiag.AppendErrorf(diags, "reading Elastic Transcoder Preset (%s): setting video_codec_options: %s", d.Id(), err) } if preset.Video.Watermarks != nil { From 11f8df3f8b37b0f8ae334d7d61159965db94b37f Mon Sep 17 00:00:00 2001 From: Jared Baker Date: Fri, 19 Jul 2024 11:12:17 -0400 Subject: [PATCH 3/3] r/aws_elastictranscoder_[pipeline|preset]: handle NotFound errors on delete ```console % make testacc PKG=elastictranscoder make: Verifying source code with gofmt... ==> Checking that code complies with gofmt requirements... TF_ACC=1 go1.22.5 test ./internal/service/elastictranscoder/... -v -count 1 -parallel 20 -timeout 360m --- PASS: TestEndpointConfiguration (0.66s) --- PASS: TestEndpointConfiguration/no_config (0.03s) --- PASS: TestEndpointConfiguration/package_name_endpoint_config (0.04s) --- PASS: TestEndpointConfiguration/package_name_endpoint_config_overrides_base_envvar (0.04s) --- PASS: TestEndpointConfiguration/service_aws_envvar_overrides_service_config_file (0.03s) --- PASS: TestEndpointConfiguration/use_fips_config_with_package_name_endpoint_config (0.04s) --- PASS: TestEndpointConfiguration/package_name_endpoint_config_overrides_service_config_file (0.04s) --- PASS: TestEndpointConfiguration/package_name_endpoint_config_overrides_base_config_file (0.05s) --- PASS: TestEndpointConfiguration/service_aws_envvar_overrides_base_envvar (0.03s) --- PASS: TestEndpointConfiguration/base_endpoint_envvar (0.03s) --- PASS: TestEndpointConfiguration/base_endpoint_config_file (0.03s) --- PASS: TestEndpointConfiguration/package_name_endpoint_config_overrides_aws_service_envvar (0.04s) --- PASS: TestEndpointConfiguration/service_aws_envvar_overrides_base_config_file (0.03s) --- PASS: TestEndpointConfiguration/base_endpoint_envvar_overrides_service_config_file (0.03s) --- PASS: TestEndpointConfiguration/use_fips_config (0.03s) --- PASS: TestEndpointConfiguration/service_aws_envvar (0.03s) --- PASS: TestEndpointConfiguration/base_endpoint_envvar_overrides_base_config_file (0.03s) --- PASS: TestEndpointConfiguration/service_config_file (0.03s) --- PASS: TestEndpointConfiguration/service_config_file_overrides_base_config_file (0.03s) === CONT TestAccElasticTranscoderPipeline_basic === CONT TestAccElasticTranscoderPreset_video_noCodec === CONT TestAccElasticTranscoderPipeline_withPermissions === CONT TestAccElasticTranscoderPreset_Video_frameRate === CONT TestAccElasticTranscoderPreset_full === CONT TestAccElasticTranscoderPipeline_notifications === CONT TestAccElasticTranscoderPreset_description === CONT TestAccElasticTranscoderPreset_AudioCodecOptions_empty === CONT TestAccElasticTranscoderPreset_disappears === CONT TestAccElasticTranscoderPreset_audio_noBitRate === CONT TestAccElasticTranscoderPipeline_withContent === CONT TestAccElasticTranscoderPreset_basic === CONT TestAccElasticTranscoderPipeline_kmsKey === CONT TestAccElasticTranscoderPipeline_disappears --- PASS: TestAccElasticTranscoderPreset_disappears (18.36s) --- PASS: TestAccElasticTranscoderPreset_Video_frameRate (21.60s) --- PASS: TestAccElasticTranscoderPreset_description (23.73s) --- PASS: TestAccElasticTranscoderPreset_basic (23.86s) --- PASS: TestAccElasticTranscoderPreset_audio_noBitRate (23.93s) --- PASS: TestAccElasticTranscoderPipeline_disappears (25.19s) --- PASS: TestAccElasticTranscoderPipeline_basic (26.98s) --- PASS: TestAccElasticTranscoderPipeline_withPermissions (28.32s) --- PASS: TestAccElasticTranscoderPreset_AudioCodecOptions_empty (28.55s) --- PASS: TestAccElasticTranscoderPreset_video_noCodec (30.26s) --- PASS: TestAccElasticTranscoderPreset_full (34.48s) --- PASS: TestAccElasticTranscoderPipeline_notifications (37.32s) --- PASS: TestAccElasticTranscoderPipeline_withContent (37.32s) --- PASS: TestAccElasticTranscoderPipeline_kmsKey (48.26s) PASS ok github.com/hashicorp/terraform-provider-aws/internal/service/elastictranscoder 54.746s ``` --- .changelog/38018.txt | 6 ++++++ internal/service/elastictranscoder/pipeline.go | 3 +++ internal/service/elastictranscoder/preset.go | 3 +++ 3 files changed, 12 insertions(+) create mode 100644 .changelog/38018.txt diff --git a/.changelog/38018.txt b/.changelog/38018.txt new file mode 100644 index 00000000000..4e061ce95b4 --- /dev/null +++ b/.changelog/38018.txt @@ -0,0 +1,6 @@ +```release-note:bug +resource/aws_elastictranscoder_pipeline: Properly handle NotFound exceptions during deletion +``` +```release-note:bug +resource/aws_elastictranscoder_preset: Properly handle NotFound exceptions during deletion +``` diff --git a/internal/service/elastictranscoder/pipeline.go b/internal/service/elastictranscoder/pipeline.go index d380e6f2786..9e88687992e 100644 --- a/internal/service/elastictranscoder/pipeline.go +++ b/internal/service/elastictranscoder/pipeline.go @@ -537,6 +537,9 @@ func resourcePipelineDelete(ctx context.Context, d *schema.ResourceData, meta in Id: aws.String(d.Id()), }) if err != nil { + if errs.IsA[*awstypes.ResourceNotFoundException](err) { + return diags + } return sdkdiag.AppendErrorf(diags, "deleting Elastic Transcoder Pipeline: %s", err) } return diags diff --git a/internal/service/elastictranscoder/preset.go b/internal/service/elastictranscoder/preset.go index de6cd7f6322..5cfe8fec701 100644 --- a/internal/service/elastictranscoder/preset.go +++ b/internal/service/elastictranscoder/preset.go @@ -929,6 +929,9 @@ func resourcePresetDelete(ctx context.Context, d *schema.ResourceData, meta inte }) if err != nil { + if errs.IsA[*awstypes.ResourceNotFoundException](err) { + return diags + } return sdkdiag.AppendErrorf(diags, "deleting Elastic Transcoder Preset: %s", err) }