From 43b035ca3d411cc8cea665d0213ad04acc06308d Mon Sep 17 00:00:00 2001 From: Daniel Rieske Date: Thu, 8 Aug 2024 20:33:08 +0200 Subject: [PATCH 01/17] feat: generate `v2` client --- go.mod | 1 + go.sum | 2 + internal/conns/awsclient_gen.go | 6 +- .../cluster_test.go | 2 +- .../service_endpoint_resolver_gen.go | 66 ++++---- .../service_endpoints_gen_test.go | 146 +++++++++++++++--- names/data/names_data.hcl | 2 +- 7 files changed, 165 insertions(+), 60 deletions(-) diff --git a/go.mod b/go.mod index b24791085b0..ff8dd19470c 100644 --- a/go.mod +++ b/go.mod @@ -292,6 +292,7 @@ require ( github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.9.16 // indirect github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.17 // indirect github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.17.15 // indirect + github.com/aws/aws-sdk-go-v2/service/route53recoverycontrolconfig v1.23.3 // indirect github.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.4 // indirect github.com/bgentry/speakeasy v0.1.0 // indirect github.com/boombuler/barcode v1.0.1 // indirect diff --git a/go.sum b/go.sum index 950561b512f..f30b0b56686 100644 --- a/go.sum +++ b/go.sum @@ -404,6 +404,8 @@ github.com/aws/aws-sdk-go-v2/service/route53domains v1.25.3 h1:VGLIgiClxmwxBpGzH github.com/aws/aws-sdk-go-v2/service/route53domains v1.25.3/go.mod h1:Kgq5O7ZaDk0mTZmX6YCL+ZtZ1YcJHtGsVubp0OT77MA= github.com/aws/aws-sdk-go-v2/service/route53profiles v1.2.3 h1:N4f5sliNiWcp3abC+8YpcaVjXuaNJIlz/dBd+saimm0= github.com/aws/aws-sdk-go-v2/service/route53profiles v1.2.3/go.mod h1:r2B4BvTn3zSMK+BFHGl0q63B/nJMOk9/NukLZzqO8sY= +github.com/aws/aws-sdk-go-v2/service/route53recoverycontrolconfig v1.23.3 h1:apYav6exfbLJ+kRGPa27GTrUuCS4ctI0mJEeiDxSeDE= +github.com/aws/aws-sdk-go-v2/service/route53recoverycontrolconfig v1.23.3/go.mod h1:citOcziml/EM6I2ycb7XHuBw0whC8jVD2y+vU7wQD4k= github.com/aws/aws-sdk-go-v2/service/rum v1.19.3 h1:DR+GYJRPL7eEZknnGdwm+lH686LmUBB/X2YVQDHLNY4= github.com/aws/aws-sdk-go-v2/service/rum v1.19.3/go.mod h1:5jFxbuc05P/+BbJvVbBspMbzDR2IFU0LegQG3iUvj8g= github.com/aws/aws-sdk-go-v2/service/s3 v1.58.3 h1:hT8ZAZRIfqBqHbzKTII+CIiY8G2oC9OpLedkZ51DWl8= diff --git a/internal/conns/awsclient_gen.go b/internal/conns/awsclient_gen.go index 0ccd9c8093e..7407cb7320c 100644 --- a/internal/conns/awsclient_gen.go +++ b/internal/conns/awsclient_gen.go @@ -179,6 +179,7 @@ import ( route53_sdkv2 "github.com/aws/aws-sdk-go-v2/service/route53" route53domains_sdkv2 "github.com/aws/aws-sdk-go-v2/service/route53domains" route53profiles_sdkv2 "github.com/aws/aws-sdk-go-v2/service/route53profiles" + route53recoverycontrolconfig_sdkv2 "github.com/aws/aws-sdk-go-v2/service/route53recoverycontrolconfig" rum_sdkv2 "github.com/aws/aws-sdk-go-v2/service/rum" s3_sdkv2 "github.com/aws/aws-sdk-go-v2/service/s3" s3control_sdkv2 "github.com/aws/aws-sdk-go-v2/service/s3control" @@ -241,7 +242,6 @@ import ( rds_sdkv1 "github.com/aws/aws-sdk-go/service/rds" redshift_sdkv1 "github.com/aws/aws-sdk-go/service/redshift" redshiftserverless_sdkv1 "github.com/aws/aws-sdk-go/service/redshiftserverless" - route53recoverycontrolconfig_sdkv1 "github.com/aws/aws-sdk-go/service/route53recoverycontrolconfig" route53recoveryreadiness_sdkv1 "github.com/aws/aws-sdk-go/service/route53recoveryreadiness" route53resolver_sdkv1 "github.com/aws/aws-sdk-go/service/route53resolver" s3outposts_sdkv1 "github.com/aws/aws-sdk-go/service/s3outposts" @@ -1037,8 +1037,8 @@ func (c *AWSClient) Route53ProfilesClient(ctx context.Context) *route53profiles_ return errs.Must(client[*route53profiles_sdkv2.Client](ctx, c, names.Route53Profiles, make(map[string]any))) } -func (c *AWSClient) Route53RecoveryControlConfigConn(ctx context.Context) *route53recoverycontrolconfig_sdkv1.Route53RecoveryControlConfig { - return errs.Must(conn[*route53recoverycontrolconfig_sdkv1.Route53RecoveryControlConfig](ctx, c, names.Route53RecoveryControlConfig, make(map[string]any))) +func (c *AWSClient) Route53RecoveryControlConfigClient(ctx context.Context) *route53recoverycontrolconfig_sdkv2.Client { + return errs.Must(client[*route53recoverycontrolconfig_sdkv2.Client](ctx, c, names.Route53RecoveryControlConfig, make(map[string]any))) } func (c *AWSClient) Route53RecoveryReadinessConn(ctx context.Context) *route53recoveryreadiness_sdkv1.Route53RecoveryReadiness { diff --git a/internal/service/route53recoverycontrolconfig/cluster_test.go b/internal/service/route53recoverycontrolconfig/cluster_test.go index 80a62a93c34..cada9af18b5 100644 --- a/internal/service/route53recoverycontrolconfig/cluster_test.go +++ b/internal/service/route53recoverycontrolconfig/cluster_test.go @@ -8,7 +8,7 @@ import ( "fmt" "testing" - "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go-v2/aws" r53rcc "github.com/aws/aws-sdk-go/service/route53recoverycontrolconfig" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/internal/service/route53recoverycontrolconfig/service_endpoint_resolver_gen.go b/internal/service/route53recoverycontrolconfig/service_endpoint_resolver_gen.go index a217e0f1660..7c86edfea6e 100644 --- a/internal/service/route53recoverycontrolconfig/service_endpoint_resolver_gen.go +++ b/internal/service/route53recoverycontrolconfig/service_endpoint_resolver_gen.go @@ -6,65 +6,63 @@ import ( "context" "fmt" "net" - "net/url" - endpoints_sdkv1 "github.com/aws/aws-sdk-go/aws/endpoints" + aws_sdkv2 "github.com/aws/aws-sdk-go-v2/aws" + route53recoverycontrolconfig_sdkv2 "github.com/aws/aws-sdk-go-v2/service/route53recoverycontrolconfig" + smithyendpoints "github.com/aws/smithy-go/endpoints" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-provider-aws/internal/errs" ) -var _ endpoints_sdkv1.Resolver = resolverSDKv1{} +var _ route53recoverycontrolconfig_sdkv2.EndpointResolverV2 = resolverSDKv2{} -type resolverSDKv1 struct { - ctx context.Context +type resolverSDKv2 struct { + defaultResolver route53recoverycontrolconfig_sdkv2.EndpointResolverV2 } -func newEndpointResolverSDKv1(ctx context.Context) resolverSDKv1 { - return resolverSDKv1{ - ctx: ctx, +func newEndpointResolverSDKv2() resolverSDKv2 { + return resolverSDKv2{ + defaultResolver: route53recoverycontrolconfig_sdkv2.NewDefaultEndpointResolverV2(), } } -func (r resolverSDKv1) EndpointFor(service, region string, opts ...func(*endpoints_sdkv1.Options)) (endpoint endpoints_sdkv1.ResolvedEndpoint, err error) { - ctx := r.ctx +func (r resolverSDKv2) ResolveEndpoint(ctx context.Context, params route53recoverycontrolconfig_sdkv2.EndpointParameters) (endpoint smithyendpoints.Endpoint, err error) { + params = params.WithDefaults() + useFIPS := aws_sdkv2.ToBool(params.UseFIPS) - var opt endpoints_sdkv1.Options - opt.Set(opts...) - - useFIPS := opt.UseFIPSEndpoint == endpoints_sdkv1.FIPSEndpointStateEnabled + if eps := params.Endpoint; aws_sdkv2.ToString(eps) != "" { + tflog.Debug(ctx, "setting endpoint", map[string]any{ + "tf_aws.endpoint": endpoint, + }) - defaultResolver := endpoints_sdkv1.DefaultResolver() + if useFIPS { + tflog.Debug(ctx, "endpoint set, ignoring UseFIPSEndpoint setting") + params.UseFIPS = aws_sdkv2.Bool(false) + } - if useFIPS { + return r.defaultResolver.ResolveEndpoint(ctx, params) + } else if useFIPS { ctx = tflog.SetField(ctx, "tf_aws.use_fips", useFIPS) - endpoint, err = defaultResolver.EndpointFor(service, region, opts...) + endpoint, err = r.defaultResolver.ResolveEndpoint(ctx, params) if err != nil { return endpoint, err } tflog.Debug(ctx, "endpoint resolved", map[string]any{ - "tf_aws.endpoint": endpoint.URL, + "tf_aws.endpoint": endpoint.URI.String(), }) - var endpointURL *url.URL - endpointURL, err = url.Parse(endpoint.URL) - if err != nil { - return endpoint, err - } - - hostname := endpointURL.Hostname() + hostname := endpoint.URI.Hostname() _, err = net.LookupHost(hostname) if err != nil { if dnsErr, ok := errs.As[*net.DNSError](err); ok && dnsErr.IsNotFound { tflog.Debug(ctx, "default endpoint host not found, disabling FIPS", map[string]any{ "tf_aws.hostname": hostname, }) - opts = append(opts, func(o *endpoints_sdkv1.Options) { - o.UseFIPSEndpoint = endpoints_sdkv1.FIPSEndpointStateDisabled - }) + params.UseFIPS = aws_sdkv2.Bool(false) } else { - err = fmt.Errorf("looking up accessanalyzer endpoint %q: %s", hostname, err) + err = fmt.Errorf("looking up route53recoverycontrolconfig endpoint %q: %s", hostname, err) return } } else { @@ -72,5 +70,13 @@ func (r resolverSDKv1) EndpointFor(service, region string, opts ...func(*endpoin } } - return defaultResolver.EndpointFor(service, region, opts...) + return r.defaultResolver.ResolveEndpoint(ctx, params) +} + +func withBaseEndpoint(endpoint string) func(*route53recoverycontrolconfig_sdkv2.Options) { + return func(o *route53recoverycontrolconfig_sdkv2.Options) { + if endpoint != "" { + o.BaseEndpoint = aws_sdkv2.String(endpoint) + } + } } diff --git a/internal/service/route53recoverycontrolconfig/service_endpoints_gen_test.go b/internal/service/route53recoverycontrolconfig/service_endpoints_gen_test.go index 3ebc393f0df..fdfb9782b76 100644 --- a/internal/service/route53recoverycontrolconfig/service_endpoints_gen_test.go +++ b/internal/service/route53recoverycontrolconfig/service_endpoints_gen_test.go @@ -4,18 +4,22 @@ package route53recoverycontrolconfig_test import ( "context" + "errors" "fmt" "maps" "net" "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" - route53recoverycontrolconfig_sdkv1 "github.com/aws/aws-sdk-go/service/route53recoverycontrolconfig" + aws_sdkv2 "github.com/aws/aws-sdk-go-v2/aws" + awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" + route53recoverycontrolconfig_sdkv2 "github.com/aws/aws-sdk-go-v2/service/route53recoverycontrolconfig" + "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" @@ -240,54 +244,63 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S } func defaultEndpoint(region string) (url.URL, error) { - r := endpoints.DefaultResolver() + r := route53recoverycontrolconfig_sdkv2.NewDefaultEndpointResolverV2() - ep, err := r.EndpointFor(route53recoverycontrolconfig_sdkv1.EndpointsID, region) + ep, err := r.ResolveEndpoint(context.Background(), route53recoverycontrolconfig_sdkv2.EndpointParameters{ + Region: aws_sdkv2.String(region), + }) if err != nil { return url.URL{}, err } - url, _ := url.Parse(ep.URL) - - if url.Path == "" { - url.Path = "/" + if ep.URI.Path == "" { + ep.URI.Path = "/" } - return *url, nil + return ep.URI, nil } func defaultFIPSEndpoint(region string) (url.URL, error) { - r := endpoints.DefaultResolver() + r := route53recoverycontrolconfig_sdkv2.NewDefaultEndpointResolverV2() - ep, err := r.EndpointFor(route53recoverycontrolconfig_sdkv1.EndpointsID, region, func(opt *endpoints.Options) { - opt.UseFIPSEndpoint = endpoints.FIPSEndpointStateEnabled + ep, err := r.ResolveEndpoint(context.Background(), route53recoverycontrolconfig_sdkv2.EndpointParameters{ + Region: aws_sdkv2.String(region), + UseFIPS: aws_sdkv2.Bool(true), }) if err != nil { return url.URL{}, err } - url, _ := url.Parse(ep.URL) - - if url.Path == "" { - url.Path = "/" + if ep.URI.Path == "" { + ep.URI.Path = "/" } - return *url, nil + return ep.URI, nil } func callService(ctx context.Context, t *testing.T, meta *conns.AWSClient) apiCallParams { t.Helper() - client := meta.Route53RecoveryControlConfigConn(ctx) + client := meta.Route53RecoveryControlConfigClient(ctx) - req, _ := client.ListClustersRequest(&route53recoverycontrolconfig_sdkv1.ListClustersInput{}) + var result apiCallParams - req.HTTPRequest.URL.Path = "/" - - return apiCallParams{ - endpoint: req.HTTPRequest.URL.String(), - region: aws_sdkv1.StringValue(client.Config.Region), + _, err := client.ListClusters(ctx, &route53recoverycontrolconfig_sdkv2.ListClustersInput{}, + func(opts *route53recoverycontrolconfig_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) { @@ -466,6 +479,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/names/data/names_data.hcl b/names/data/names_data.hcl index bbfa266f174..4ebae8a5fef 100644 --- a/names/data/names_data.hcl +++ b/names/data/names_data.hcl @@ -7799,7 +7799,7 @@ service "route53recoverycontrolconfig" { sdk { id = "Route53 Recovery Control Config" - client_version = [1] + client_version = [2] } names { From 6ba597930be5990d314d4b2be4e1dd535bdee902 Mon Sep 17 00:00:00 2001 From: Daniel Rieske Date: Thu, 8 Aug 2024 22:12:42 +0200 Subject: [PATCH 02/17] feat: migrate r/cluster to sdkv2 --- .../route53recoverycontrolconfig/cluster.go | 89 ++++++++++--------- .../cluster_test.go | 53 +++++------ 2 files changed, 77 insertions(+), 65 deletions(-) diff --git a/internal/service/route53recoverycontrolconfig/cluster.go b/internal/service/route53recoverycontrolconfig/cluster.go index 7218156eee9..39cf0af362b 100644 --- a/internal/service/route53recoverycontrolconfig/cluster.go +++ b/internal/service/route53recoverycontrolconfig/cluster.go @@ -7,19 +7,22 @@ import ( "context" "log" - "github.com/aws/aws-sdk-go/aws" - r53rcc "github.com/aws/aws-sdk-go/service/route53recoverycontrolconfig" - "github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr" + "github.com/aws/aws-sdk-go-v2/aws" + r53rcc "github.com/aws/aws-sdk-go-v2/service/route53recoverycontrolconfig" + awstypes "github.com/aws/aws-sdk-go-v2/service/route53recoverycontrolconfig/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/retry" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "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/tfresource" "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_route53recoverycontrolconfig_cluster") -func ResourceCluster() *schema.Resource { +// @SDKResource("aws_route53recoverycontrolconfig_cluster", name="Cluster") +func resourceCluster() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceClusterCreate, ReadWithoutTimeout: resourceClusterRead, @@ -64,14 +67,14 @@ func ResourceCluster() *schema.Resource { func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).Route53RecoveryControlConfigConn(ctx) + conn := meta.(*conns.AWSClient).Route53RecoveryControlConfigClient(ctx) input := &r53rcc.CreateClusterInput{ ClientToken: aws.String(id.UniqueId()), ClusterName: aws.String(d.Get(names.AttrName).(string)), } - output, err := conn.CreateClusterWithContext(ctx, input) + output, err := conn.CreateCluster(ctx, input) if err != nil { return sdkdiag.AppendErrorf(diags, "creating Route53 Recovery Control Config Cluster: %s", err) @@ -82,7 +85,7 @@ func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta int } result := output.Cluster - d.SetId(aws.StringValue(result.ClusterArn)) + d.SetId(aws.ToString(result.ClusterArn)) if _, err := waitClusterCreated(ctx, conn, d.Id()); err != nil { return sdkdiag.AppendErrorf(diags, "waiting for Route53 Recovery Control Config Cluster (%s) to be Deployed: %s", d.Id(), err) @@ -93,15 +96,11 @@ func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta int func resourceClusterRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).Route53RecoveryControlConfigConn(ctx) + conn := meta.(*conns.AWSClient).Route53RecoveryControlConfigClient(ctx) - input := &r53rcc.DescribeClusterInput{ - ClusterArn: aws.String(d.Id()), - } - - output, err := conn.DescribeClusterWithContext(ctx, input) + output, err := findClusterByARN(ctx, conn, d.Id()) - if !d.IsNewResource() && tfawserr.ErrCodeEquals(err, r53rcc.ErrCodeResourceNotFoundException) { + if !d.IsNewResource() && tfresource.NotFound(err) { log.Printf("[WARN] Route53 Recovery Control Config Cluster (%s) not found, removing from state", d.Id()) d.SetId("") return diags @@ -111,16 +110,11 @@ func resourceClusterRead(ctx context.Context, d *schema.ResourceData, meta inter return sdkdiag.AppendErrorf(diags, "describing Route53 Recovery Control Config Cluster: %s", err) } - if output == nil || output.Cluster == nil { - return sdkdiag.AppendErrorf(diags, "describing Route53 Recovery Control Config Cluster: %s", "empty response") - } + d.Set(names.AttrARN, output.ClusterArn) + d.Set(names.AttrName, output.Name) + d.Set(names.AttrStatus, output.Status) - result := output.Cluster - d.Set(names.AttrARN, result.ClusterArn) - d.Set(names.AttrName, result.Name) - d.Set(names.AttrStatus, result.Status) - - if err := d.Set("cluster_endpoints", flattenClusterEndpoints(result.ClusterEndpoints)); err != nil { + if err := d.Set("cluster_endpoints", flattenClusterEndpoints(output.ClusterEndpoints)); err != nil { return sdkdiag.AppendErrorf(diags, "setting cluster_endpoints: %s", err) } @@ -129,14 +123,14 @@ func resourceClusterRead(ctx context.Context, d *schema.ResourceData, meta inter func resourceClusterDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).Route53RecoveryControlConfigConn(ctx) + conn := meta.(*conns.AWSClient).Route53RecoveryControlConfigClient(ctx) log.Printf("[INFO] Deleting Route53 Recovery Control Config Cluster: %s", d.Id()) - _, err := conn.DeleteClusterWithContext(ctx, &r53rcc.DeleteClusterInput{ + _, err := conn.DeleteCluster(ctx, &r53rcc.DeleteClusterInput{ ClusterArn: aws.String(d.Id()), }) - if tfawserr.ErrCodeEquals(err, r53rcc.ErrCodeResourceNotFoundException) { + if errs.IsA[*awstypes.ResourceNotFoundException](err) { return diags } @@ -146,7 +140,7 @@ func resourceClusterDelete(ctx context.Context, d *schema.ResourceData, meta int _, err = waitClusterDeleted(ctx, conn, d.Id()) - if tfawserr.ErrCodeEquals(err, r53rcc.ErrCodeResourceNotFoundException) { + if errs.IsA[*awstypes.ResourceNotFoundException](err) { return diags } @@ -157,7 +151,30 @@ func resourceClusterDelete(ctx context.Context, d *schema.ResourceData, meta int return diags } -func flattenClusterEndpoints(endpoints []*r53rcc.ClusterEndpoint) []interface{} { +func findClusterByARN(ctx context.Context, conn *r53rcc.Client, arn string) (*awstypes.Cluster, error) { + input := &r53rcc.DescribeClusterInput{ + ClusterArn: aws.String(arn), + } + + output, err := conn.DescribeCluster(ctx, input) + if errs.IsA[*awstypes.ResourceNotFoundException](err) { + return nil, &retry.NotFoundError{ + LastError: err, + LastRequest: input, + } + } + if err != nil { + return nil, err + } + + if output == nil || output.Cluster == nil { + return nil, tfresource.NewEmptyResultError(input) + } + + return output.Cluster, nil +} + +func flattenClusterEndpoints(endpoints []awstypes.ClusterEndpoint) []interface{} { if len(endpoints) == 0 { return nil } @@ -165,29 +182,21 @@ func flattenClusterEndpoints(endpoints []*r53rcc.ClusterEndpoint) []interface{} var tfList []interface{} for _, endpoint := range endpoints { - if endpoint == nil { - continue - } - tfList = append(tfList, flattenClusterEndpoint(endpoint)) } return tfList } -func flattenClusterEndpoint(ce *r53rcc.ClusterEndpoint) map[string]interface{} { - if ce == nil { - return nil - } - +func flattenClusterEndpoint(ce awstypes.ClusterEndpoint) map[string]interface{} { tfMap := map[string]interface{}{} if v := ce.Endpoint; v != nil { - tfMap[names.AttrEndpoint] = aws.StringValue(v) + tfMap[names.AttrEndpoint] = aws.ToString(v) } if v := ce.Region; v != nil { - tfMap[names.AttrRegion] = aws.StringValue(v) + tfMap[names.AttrRegion] = aws.ToString(v) } return tfMap diff --git a/internal/service/route53recoverycontrolconfig/cluster_test.go b/internal/service/route53recoverycontrolconfig/cluster_test.go index cada9af18b5..81a2444a42a 100644 --- a/internal/service/route53recoverycontrolconfig/cluster_test.go +++ b/internal/service/route53recoverycontrolconfig/cluster_test.go @@ -8,14 +8,13 @@ import ( "fmt" "testing" - "github.com/aws/aws-sdk-go-v2/aws" - r53rcc "github.com/aws/aws-sdk-go/service/route53recoverycontrolconfig" 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" tfroute53recoverycontrolconfig "github.com/hashicorp/terraform-provider-aws/internal/service/route53recoverycontrolconfig" + "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -25,7 +24,10 @@ func testAccCluster_basic(t *testing.T) { resourceName := "aws_route53recoverycontrolconfig_cluster.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionHasService(t, r53rcc.EndpointsID) }, + PreCheck: func() { + acctest.PreCheck(ctx, t) + acctest.PreCheckPartitionHasService(t, names.Route53RecoveryControlConfigEndpointID) + }, ErrorCheck: acctest.ErrorCheck(t, names.Route53RecoveryControlConfigServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckClusterDestroy(ctx), @@ -55,7 +57,10 @@ func testAccCluster_disappears(t *testing.T) { resourceName := "aws_route53recoverycontrolconfig_cluster.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionHasService(t, r53rcc.EndpointsID) }, + PreCheck: func() { + acctest.PreCheck(ctx, t) + acctest.PreCheckPartitionHasService(t, names.Route53RecoveryControlConfigEndpointID) + }, ErrorCheck: acctest.ErrorCheck(t, names.Route53RecoveryControlConfigServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckClusterDestroy(ctx), @@ -74,36 +79,30 @@ func testAccCluster_disappears(t *testing.T) { func testAccCheckClusterDestroy(ctx context.Context) resource.TestCheckFunc { return func(s *terraform.State) error { - conn := acctest.Provider.Meta().(*conns.AWSClient).Route53RecoveryControlConfigConn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).Route53RecoveryControlConfigClient(ctx) for _, rs := range s.RootModule().Resources { if rs.Type != "aws_route53recoverycontrolconfig_cluster" { continue } - input := &r53rcc.DescribeClusterInput{ - ClusterArn: aws.String(rs.Primary.ID), - } + _, err := tfroute53recoverycontrolconfig.FindClusterByARN(ctx, conn, rs.Primary.ID) - _, err := conn.DescribeClusterWithContext(ctx, input) + if tfresource.NotFound(err) { + continue + } - if err == nil { - return fmt.Errorf("Route53RecoveryControlConfig cluster (%s) not deleted", rs.Primary.ID) + if err != nil { + return err } + + return fmt.Errorf("Route53RecoveryControlConfig Cluster (%s) not deleted", rs.Primary.ID) } return nil } } -func testAccClusterConfig_basic(rName string) string { - return fmt.Sprintf(` -resource "aws_route53recoverycontrolconfig_cluster" "test" { - name = %[1]q -} -`, rName) -} - func testAccCheckClusterExists(ctx context.Context, name string) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[name] @@ -111,14 +110,18 @@ func testAccCheckClusterExists(ctx context.Context, name string) resource.TestCh return fmt.Errorf("Not found: %s", name) } - conn := acctest.Provider.Meta().(*conns.AWSClient).Route53RecoveryControlConfigConn(ctx) - - input := &r53rcc.DescribeClusterInput{ - ClusterArn: aws.String(rs.Primary.ID), - } + conn := acctest.Provider.Meta().(*conns.AWSClient).Route53RecoveryControlConfigClient(ctx) - _, err := conn.DescribeClusterWithContext(ctx, input) + _, err := tfroute53recoverycontrolconfig.FindClusterByARN(ctx, conn, rs.Primary.ID) return err } } + +func testAccClusterConfig_basic(rName string) string { + return fmt.Sprintf(` +resource "aws_route53recoverycontrolconfig_cluster" "test" { + name = %[1]q +} +`, rName) +} From 45ed73d4e1fb90ccd08119a018fc88d918bc3351 Mon Sep 17 00:00:00 2001 From: Daniel Rieske Date: Thu, 8 Aug 2024 22:13:06 +0200 Subject: [PATCH 03/17] feat: migrate r/control_panel to sdkv2 --- .../control_panel.go | 81 +++++++++++-------- .../control_panel_test.go | 63 ++++++++------- 2 files changed, 82 insertions(+), 62 deletions(-) diff --git a/internal/service/route53recoverycontrolconfig/control_panel.go b/internal/service/route53recoverycontrolconfig/control_panel.go index 4eda619afef..0f06028732f 100644 --- a/internal/service/route53recoverycontrolconfig/control_panel.go +++ b/internal/service/route53recoverycontrolconfig/control_panel.go @@ -7,19 +7,22 @@ import ( "context" "log" - "github.com/aws/aws-sdk-go/aws" - r53rcc "github.com/aws/aws-sdk-go/service/route53recoverycontrolconfig" - "github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr" + "github.com/aws/aws-sdk-go-v2/aws" + r53rcc "github.com/aws/aws-sdk-go-v2/service/route53recoverycontrolconfig" + awstypes "github.com/aws/aws-sdk-go-v2/service/route53recoverycontrolconfig/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/retry" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "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/tfresource" "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_route53recoverycontrolconfig_control_panel") -func ResourceControlPanel() *schema.Resource { +// @SDKResource("aws_route53recoverycontrolconfig_control_panel", name="Control Panel") +func resourceControlPanel() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceControlPanelCreate, ReadWithoutTimeout: resourceControlPanelRead, @@ -60,7 +63,7 @@ func ResourceControlPanel() *schema.Resource { func resourceControlPanelCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).Route53RecoveryControlConfigConn(ctx) + conn := meta.(*conns.AWSClient).Route53RecoveryControlConfigClient(ctx) input := &r53rcc.CreateControlPanelInput{ ClientToken: aws.String(id.UniqueId()), @@ -68,7 +71,7 @@ func resourceControlPanelCreate(ctx context.Context, d *schema.ResourceData, met ControlPanelName: aws.String(d.Get(names.AttrName).(string)), } - output, err := conn.CreateControlPanelWithContext(ctx, input) + output, err := conn.CreateControlPanel(ctx, input) result := output.ControlPanel if err != nil { @@ -79,7 +82,7 @@ func resourceControlPanelCreate(ctx context.Context, d *schema.ResourceData, met return sdkdiag.AppendErrorf(diags, "creating Route53 Recovery Control Config Control Panel: empty response") } - d.SetId(aws.StringValue(result.ControlPanelArn)) + d.SetId(aws.ToString(result.ControlPanelArn)) if _, err := waitControlPanelCreated(ctx, conn, d.Id()); err != nil { return sdkdiag.AppendErrorf(diags, "waiting for Route53 Recovery Control Config Control Panel (%s) to be Deployed: %s", d.Id(), err) @@ -90,15 +93,11 @@ func resourceControlPanelCreate(ctx context.Context, d *schema.ResourceData, met func resourceControlPanelRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).Route53RecoveryControlConfigConn(ctx) + conn := meta.(*conns.AWSClient).Route53RecoveryControlConfigClient(ctx) - input := &r53rcc.DescribeControlPanelInput{ - ControlPanelArn: aws.String(d.Id()), - } + output, err := findControlPanelByARN(ctx, conn, d.Id()) - output, err := conn.DescribeControlPanelWithContext(ctx, input) - - if !d.IsNewResource() && tfawserr.ErrCodeEquals(err, r53rcc.ErrCodeResourceNotFoundException) { + if !d.IsNewResource() && tfresource.NotFound(err) { log.Printf("[WARN] Route53 Recovery Control Config Control Panel (%s) not found, removing from state", d.Id()) d.SetId("") return diags @@ -108,31 +107,26 @@ func resourceControlPanelRead(ctx context.Context, d *schema.ResourceData, meta return sdkdiag.AppendErrorf(diags, "describing Route53 Recovery Control Config Control Panel: %s", err) } - if output == nil || output.ControlPanel == nil { - return sdkdiag.AppendErrorf(diags, "describing Route53 Recovery Control Config Control Panel: %s", "empty response") - } - - result := output.ControlPanel - d.Set(names.AttrARN, result.ControlPanelArn) - d.Set("cluster_arn", result.ClusterArn) - d.Set("default_control_panel", result.DefaultControlPanel) - d.Set(names.AttrName, result.Name) - d.Set("routing_control_count", result.RoutingControlCount) - d.Set(names.AttrStatus, result.Status) + d.Set(names.AttrARN, output.ControlPanelArn) + d.Set("cluster_arn", output.ClusterArn) + d.Set("default_control_panel", output.DefaultControlPanel) + d.Set(names.AttrName, output.Name) + d.Set("routing_control_count", output.RoutingControlCount) + d.Set(names.AttrStatus, output.Status) return diags } func resourceControlPanelUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).Route53RecoveryControlConfigConn(ctx) + conn := meta.(*conns.AWSClient).Route53RecoveryControlConfigClient(ctx) input := &r53rcc.UpdateControlPanelInput{ ControlPanelName: aws.String(d.Get(names.AttrName).(string)), ControlPanelArn: aws.String(d.Get(names.AttrARN).(string)), } - _, err := conn.UpdateControlPanelWithContext(ctx, input) + _, err := conn.UpdateControlPanel(ctx, input) if err != nil { return sdkdiag.AppendErrorf(diags, "updating Route53 Recovery Control Config Control Panel: %s", err) @@ -143,14 +137,14 @@ func resourceControlPanelUpdate(ctx context.Context, d *schema.ResourceData, met func resourceControlPanelDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).Route53RecoveryControlConfigConn(ctx) + conn := meta.(*conns.AWSClient).Route53RecoveryControlConfigClient(ctx) log.Printf("[INFO] Deleting Route53 Recovery Control Config Control Panel: %s", d.Id()) - _, err := conn.DeleteControlPanelWithContext(ctx, &r53rcc.DeleteControlPanelInput{ + _, err := conn.DeleteControlPanel(ctx, &r53rcc.DeleteControlPanelInput{ ControlPanelArn: aws.String(d.Id()), }) - if tfawserr.ErrCodeEquals(err, r53rcc.ErrCodeResourceNotFoundException) { + if errs.IsA[*awstypes.ResourceNotFoundException](err) { return diags } @@ -160,7 +154,7 @@ func resourceControlPanelDelete(ctx context.Context, d *schema.ResourceData, met _, err = waitControlPanelDeleted(ctx, conn, d.Id()) - if tfawserr.ErrCodeEquals(err, r53rcc.ErrCodeResourceNotFoundException) { + if errs.IsA[*awstypes.ResourceNotFoundException](err) { return diags } @@ -170,3 +164,26 @@ func resourceControlPanelDelete(ctx context.Context, d *schema.ResourceData, met return diags } + +func findControlPanelByARN(ctx context.Context, conn *r53rcc.Client, arn string) (*awstypes.ControlPanel, error) { + input := &r53rcc.DescribeControlPanelInput{ + ControlPanelArn: aws.String(arn), + } + + output, err := conn.DescribeControlPanel(ctx, input) + if errs.IsA[*awstypes.ResourceNotFoundException](err) { + return nil, &retry.NotFoundError{ + LastError: err, + LastRequest: input, + } + } + if err != nil { + return nil, err + } + + if output == nil || output.ControlPanel == nil { + return nil, tfresource.NewEmptyResultError(input) + } + + return output.ControlPanel, nil +} diff --git a/internal/service/route53recoverycontrolconfig/control_panel_test.go b/internal/service/route53recoverycontrolconfig/control_panel_test.go index 4975695102e..80d0c93e774 100644 --- a/internal/service/route53recoverycontrolconfig/control_panel_test.go +++ b/internal/service/route53recoverycontrolconfig/control_panel_test.go @@ -8,14 +8,13 @@ import ( "fmt" "testing" - "github.com/aws/aws-sdk-go/aws" - r53rcc "github.com/aws/aws-sdk-go/service/route53recoverycontrolconfig" 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" tfroute53recoverycontrolconfig "github.com/hashicorp/terraform-provider-aws/internal/service/route53recoverycontrolconfig" + "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -25,7 +24,10 @@ func testAccControlPanel_basic(t *testing.T) { resourceName := "aws_route53recoverycontrolconfig_control_panel.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionHasService(t, r53rcc.EndpointsID) }, + PreCheck: func() { + acctest.PreCheck(ctx, t) + acctest.PreCheckPartitionHasService(t, names.Route53RecoveryControlConfigEndpointID) + }, ErrorCheck: acctest.ErrorCheck(t, names.Route53RecoveryControlConfigServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckControlPanelDestroy(ctx), @@ -55,7 +57,10 @@ func testAccControlPanel_disappears(t *testing.T) { resourceName := "aws_route53recoverycontrolconfig_control_panel.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionHasService(t, r53rcc.EndpointsID) }, + PreCheck: func() { + acctest.PreCheck(ctx, t) + acctest.PreCheckPartitionHasService(t, names.Route53RecoveryControlConfigEndpointID) + }, ErrorCheck: acctest.ErrorCheck(t, names.Route53RecoveryControlConfigServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckControlPanelDestroy(ctx), @@ -74,28 +79,45 @@ func testAccControlPanel_disappears(t *testing.T) { func testAccCheckControlPanelDestroy(ctx context.Context) resource.TestCheckFunc { return func(s *terraform.State) error { - conn := acctest.Provider.Meta().(*conns.AWSClient).Route53RecoveryControlConfigConn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).Route53RecoveryControlConfigClient(ctx) for _, rs := range s.RootModule().Resources { if rs.Type != "aws_route53recoverycontrolconfig_control_panel" { continue } - input := &r53rcc.DescribeControlPanelInput{ - ControlPanelArn: aws.String(rs.Primary.ID), - } + _, err := tfroute53recoverycontrolconfig.FindControlPanelByARN(ctx, conn, rs.Primary.ID) - _, err := conn.DescribeControlPanelWithContext(ctx, input) + if tfresource.NotFound(err) { + continue + } - if err == nil { - return fmt.Errorf("Route53RecoveryControlConfig Control Panel (%s) not deleted", rs.Primary.ID) + if err != nil { + return err } + + return fmt.Errorf("Route53RecoveryControlConfig Control Panel (%s) not deleted", rs.Primary.ID) } return nil } } +func testAccCheckControlPanelExists(ctx context.Context, name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + rs, ok := s.RootModule().Resources[name] + if !ok { + return fmt.Errorf("Not found: %s", name) + } + + conn := acctest.Provider.Meta().(*conns.AWSClient).Route53RecoveryControlConfigClient(ctx) + + _, err := tfroute53recoverycontrolconfig.FindControlPanelByARN(ctx, conn, rs.Primary.ID) + + return err + } +} + func testAccClusterSetUp(rName string) string { return fmt.Sprintf(` resource "aws_route53recoverycontrolconfig_cluster" "test" { @@ -112,22 +134,3 @@ resource "aws_route53recoverycontrolconfig_control_panel" "test" { } `, rName)) } - -func testAccCheckControlPanelExists(ctx context.Context, name string) resource.TestCheckFunc { - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[name] - if !ok { - return fmt.Errorf("Not found: %s", name) - } - - conn := acctest.Provider.Meta().(*conns.AWSClient).Route53RecoveryControlConfigConn(ctx) - - input := &r53rcc.DescribeControlPanelInput{ - ControlPanelArn: aws.String(rs.Primary.ID), - } - - _, err := conn.DescribeControlPanelWithContext(ctx, input) - - return err - } -} From 9ebd18d145c6469505b099291e77831d167d2001 Mon Sep 17 00:00:00 2001 From: Daniel Rieske Date: Thu, 8 Aug 2024 22:13:16 +0200 Subject: [PATCH 04/17] feat: migrate r/routing_control to sdkv2 --- .../routing_control.go | 77 +++++++++++-------- .../routing_control_test.go | 42 +++++----- 2 files changed, 71 insertions(+), 48 deletions(-) diff --git a/internal/service/route53recoverycontrolconfig/routing_control.go b/internal/service/route53recoverycontrolconfig/routing_control.go index 9f73a27b81e..a5bd40734b8 100644 --- a/internal/service/route53recoverycontrolconfig/routing_control.go +++ b/internal/service/route53recoverycontrolconfig/routing_control.go @@ -7,19 +7,22 @@ import ( "context" "log" - "github.com/aws/aws-sdk-go/aws" - r53rcc "github.com/aws/aws-sdk-go/service/route53recoverycontrolconfig" - "github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr" + "github.com/aws/aws-sdk-go-v2/aws" + r53rcc "github.com/aws/aws-sdk-go-v2/service/route53recoverycontrolconfig" + awstypes "github.com/aws/aws-sdk-go-v2/service/route53recoverycontrolconfig/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/retry" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "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/tfresource" "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_route53recoverycontrolconfig_routing_control") -func ResourceRoutingControl() *schema.Resource { +// @SDKResource("aws_route53recoverycontrolconfig_routing_control", name="Routing Control") +func resourceRoutingControl() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceRoutingControlCreate, ReadWithoutTimeout: resourceRoutingControlRead, @@ -57,7 +60,7 @@ func ResourceRoutingControl() *schema.Resource { func resourceRoutingControlCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).Route53RecoveryControlConfigConn(ctx) + conn := meta.(*conns.AWSClient).Route53RecoveryControlConfigClient(ctx) input := &r53rcc.CreateRoutingControlInput{ ClientToken: aws.String(id.UniqueId()), @@ -69,7 +72,7 @@ func resourceRoutingControlCreate(ctx context.Context, d *schema.ResourceData, m input.ControlPanelArn = aws.String(v.(string)) } - output, err := conn.CreateRoutingControlWithContext(ctx, input) + output, err := conn.CreateRoutingControl(ctx, input) result := output.RoutingControl if err != nil { @@ -80,7 +83,7 @@ func resourceRoutingControlCreate(ctx context.Context, d *schema.ResourceData, m return sdkdiag.AppendErrorf(diags, "creating Route53 Recovery Control Config Routing Control: empty response") } - d.SetId(aws.StringValue(result.RoutingControlArn)) + d.SetId(aws.ToString(result.RoutingControlArn)) if _, err := waitRoutingControlCreated(ctx, conn, d.Id()); err != nil { return sdkdiag.AppendErrorf(diags, "waiting for Route53 Recovery Control Config Routing Control (%s) to be Deployed: %s", d.Id(), err) @@ -91,15 +94,11 @@ func resourceRoutingControlCreate(ctx context.Context, d *schema.ResourceData, m func resourceRoutingControlRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).Route53RecoveryControlConfigConn(ctx) + conn := meta.(*conns.AWSClient).Route53RecoveryControlConfigClient(ctx) - input := &r53rcc.DescribeRoutingControlInput{ - RoutingControlArn: aws.String(d.Id()), - } + output, err := findRoutingControlByARN(ctx, conn, d.Id()) - output, err := conn.DescribeRoutingControlWithContext(ctx, input) - - if !d.IsNewResource() && tfawserr.ErrCodeEquals(err, r53rcc.ErrCodeResourceNotFoundException) { + if !d.IsNewResource() && tfresource.NotFound(err) { log.Printf("[WARN] Route53 Recovery Control Config Routing Control (%s) not found, removing from state", d.Id()) d.SetId("") return diags @@ -109,29 +108,24 @@ func resourceRoutingControlRead(ctx context.Context, d *schema.ResourceData, met return sdkdiag.AppendErrorf(diags, "describing Route53 Recovery Control Config Routing Control: %s", err) } - if output == nil || output.RoutingControl == nil { - return sdkdiag.AppendErrorf(diags, "describing Route53 Recovery Control Config Routing Control: %s", "empty response") - } - - result := output.RoutingControl - d.Set(names.AttrARN, result.RoutingControlArn) - d.Set("control_panel_arn", result.ControlPanelArn) - d.Set(names.AttrName, result.Name) - d.Set(names.AttrStatus, result.Status) + d.Set(names.AttrARN, output.RoutingControlArn) + d.Set("control_panel_arn", output.ControlPanelArn) + d.Set(names.AttrName, output.Name) + d.Set(names.AttrStatus, output.Status) return diags } func resourceRoutingControlUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).Route53RecoveryControlConfigConn(ctx) + conn := meta.(*conns.AWSClient).Route53RecoveryControlConfigClient(ctx) input := &r53rcc.UpdateRoutingControlInput{ RoutingControlName: aws.String(d.Get(names.AttrName).(string)), RoutingControlArn: aws.String(d.Get(names.AttrARN).(string)), } - _, err := conn.UpdateRoutingControlWithContext(ctx, input) + _, err := conn.UpdateRoutingControl(ctx, input) if err != nil { return sdkdiag.AppendErrorf(diags, "updating Route53 Recovery Control Config Routing Control: %s", err) @@ -142,14 +136,14 @@ func resourceRoutingControlUpdate(ctx context.Context, d *schema.ResourceData, m func resourceRoutingControlDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).Route53RecoveryControlConfigConn(ctx) + conn := meta.(*conns.AWSClient).Route53RecoveryControlConfigClient(ctx) log.Printf("[INFO] Deleting Route53 Recovery Control Config Routing Control: %s", d.Id()) - _, err := conn.DeleteRoutingControlWithContext(ctx, &r53rcc.DeleteRoutingControlInput{ + _, err := conn.DeleteRoutingControl(ctx, &r53rcc.DeleteRoutingControlInput{ RoutingControlArn: aws.String(d.Id()), }) - if tfawserr.ErrCodeEquals(err, r53rcc.ErrCodeResourceNotFoundException) { + if errs.IsA[*awstypes.ResourceNotFoundException](err) { return diags } @@ -159,7 +153,7 @@ func resourceRoutingControlDelete(ctx context.Context, d *schema.ResourceData, m _, err = waitRoutingControlDeleted(ctx, conn, d.Id()) - if tfawserr.ErrCodeEquals(err, r53rcc.ErrCodeResourceNotFoundException) { + if errs.IsA[*awstypes.ResourceNotFoundException](err) { return diags } @@ -169,3 +163,26 @@ func resourceRoutingControlDelete(ctx context.Context, d *schema.ResourceData, m return diags } + +func findRoutingControlByARN(ctx context.Context, conn *r53rcc.Client, arn string) (*awstypes.RoutingControl, error) { + input := &r53rcc.DescribeRoutingControlInput{ + RoutingControlArn: aws.String(arn), + } + + output, err := conn.DescribeRoutingControl(ctx, input) + if errs.IsA[*awstypes.ResourceNotFoundException](err) { + return nil, &retry.NotFoundError{ + LastError: err, + LastRequest: input, + } + } + if err != nil { + return nil, err + } + + if output == nil || output.RoutingControl == nil { + return nil, tfresource.NewEmptyResultError(input) + } + + return output.RoutingControl, nil +} diff --git a/internal/service/route53recoverycontrolconfig/routing_control_test.go b/internal/service/route53recoverycontrolconfig/routing_control_test.go index 9a88d4463a0..2f94e5be936 100644 --- a/internal/service/route53recoverycontrolconfig/routing_control_test.go +++ b/internal/service/route53recoverycontrolconfig/routing_control_test.go @@ -8,14 +8,13 @@ import ( "fmt" "testing" - "github.com/aws/aws-sdk-go/aws" - r53rcc "github.com/aws/aws-sdk-go/service/route53recoverycontrolconfig" 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" tfroute53recoverycontrolconfig "github.com/hashicorp/terraform-provider-aws/internal/service/route53recoverycontrolconfig" + "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -25,7 +24,10 @@ func testAccRoutingControl_basic(t *testing.T) { resourceName := "aws_route53recoverycontrolconfig_routing_control.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionHasService(t, r53rcc.EndpointsID) }, + PreCheck: func() { + acctest.PreCheck(ctx, t) + acctest.PreCheckPartitionHasService(t, names.Route53RecoveryControlConfigEndpointID) + }, ErrorCheck: acctest.ErrorCheck(t, names.Route53RecoveryControlConfigServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckRoutingControlDestroy(ctx), @@ -56,7 +58,10 @@ func testAccRoutingControl_disappears(t *testing.T) { resourceName := "aws_route53recoverycontrolconfig_routing_control.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionHasService(t, r53rcc.EndpointsID) }, + PreCheck: func() { + acctest.PreCheck(ctx, t) + acctest.PreCheckPartitionHasService(t, names.Route53RecoveryControlConfigEndpointID) + }, ErrorCheck: acctest.ErrorCheck(t, names.Route53RecoveryControlConfigServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckRoutingControlDestroy(ctx), @@ -79,7 +84,10 @@ func testAccRoutingControl_nonDefaultControlPanel(t *testing.T) { resourceName := "aws_route53recoverycontrolconfig_routing_control.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionHasService(t, r53rcc.EndpointsID) }, + PreCheck: func() { + acctest.PreCheck(ctx, t) + acctest.PreCheckPartitionHasService(t, names.Route53RecoveryControlConfigEndpointID) + }, ErrorCheck: acctest.ErrorCheck(t, names.Route53RecoveryControlConfigServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckRoutingControlDestroy(ctx), @@ -103,13 +111,9 @@ func testAccCheckRoutingControlExists(ctx context.Context, name string) resource return fmt.Errorf("Not found: %s", name) } - conn := acctest.Provider.Meta().(*conns.AWSClient).Route53RecoveryControlConfigConn(ctx) - - input := &r53rcc.DescribeRoutingControlInput{ - RoutingControlArn: aws.String(rs.Primary.ID), - } + conn := acctest.Provider.Meta().(*conns.AWSClient).Route53RecoveryControlConfigClient(ctx) - _, err := conn.DescribeRoutingControlWithContext(ctx, input) + _, err := tfroute53recoverycontrolconfig.FindRoutingControlByARN(ctx, conn, rs.Primary.ID) return err } @@ -117,22 +121,24 @@ func testAccCheckRoutingControlExists(ctx context.Context, name string) resource func testAccCheckRoutingControlDestroy(ctx context.Context) resource.TestCheckFunc { return func(s *terraform.State) error { - conn := acctest.Provider.Meta().(*conns.AWSClient).Route53RecoveryControlConfigConn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).Route53RecoveryControlConfigClient(ctx) for _, rs := range s.RootModule().Resources { if rs.Type != "aws_route53recoverycontrolconfig_routing_control" { continue } - input := &r53rcc.DescribeRoutingControlInput{ - RoutingControlArn: aws.String(rs.Primary.ID), - } + _, err := tfroute53recoverycontrolconfig.FindRoutingControlByARN(ctx, conn, rs.Primary.ID) - _, err := conn.DescribeRoutingControlWithContext(ctx, input) + if tfresource.NotFound(err) { + continue + } - if err == nil { - return fmt.Errorf("Route53RecoveryControlConfig Routing Control (%s) not deleted", rs.Primary.ID) + if err != nil { + return err } + + return fmt.Errorf("Route53RecoveryControlConfig Routing Control (%s) not deleted", rs.Primary.ID) } return nil From 62c57014ba24b671f6cf56f862afa67a6d7274e8 Mon Sep 17 00:00:00 2001 From: Daniel Rieske Date: Thu, 8 Aug 2024 22:13:27 +0200 Subject: [PATCH 05/17] feat: migrate r/safety_rule to sdkv2 --- .../safety_rule.go | 132 ++++++++++-------- .../safety_rule_test.go | 42 +++--- 2 files changed, 98 insertions(+), 76 deletions(-) diff --git a/internal/service/route53recoverycontrolconfig/safety_rule.go b/internal/service/route53recoverycontrolconfig/safety_rule.go index bab44e85d08..5fc8dbc214c 100644 --- a/internal/service/route53recoverycontrolconfig/safety_rule.go +++ b/internal/service/route53recoverycontrolconfig/safety_rule.go @@ -7,21 +7,24 @@ import ( "context" "log" - "github.com/aws/aws-sdk-go/aws" - r53rcc "github.com/aws/aws-sdk-go/service/route53recoverycontrolconfig" - "github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr" + "github.com/aws/aws-sdk-go-v2/aws" + r53rcc "github.com/aws/aws-sdk-go-v2/service/route53recoverycontrolconfig" + awstypes "github.com/aws/aws-sdk-go-v2/service/route53recoverycontrolconfig/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/retry" "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/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" + "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_route53recoverycontrolconfig_safety_rule") -func ResourceSafetyRule() *schema.Resource { +// @SDKResource("aws_route53recoverycontrolconfig_safety_rule", name="Safety Rule") +func resourceSafetyRule() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceSafetyRuleCreate, ReadWithoutTimeout: resourceSafetyRuleRead, @@ -85,9 +88,9 @@ func ResourceSafetyRule() *schema.Resource { Required: true, }, names.AttrType: { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(r53rcc.RuleType_Values(), true), + Type: schema.TypeString, + Required: true, + ValidateDiagFunc: enum.Validate[awstypes.RuleType](), }, }, }, @@ -130,15 +133,11 @@ func resourceSafetyRuleCreate(ctx context.Context, d *schema.ResourceData, meta func resourceSafetyRuleRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).Route53RecoveryControlConfigConn(ctx) + conn := meta.(*conns.AWSClient).Route53RecoveryControlConfigClient(ctx) - input := &r53rcc.DescribeSafetyRuleInput{ - SafetyRuleArn: aws.String(d.Id()), - } + output, err := findSafetyRuleByARN(ctx, conn, d.Id()) - output, err := conn.DescribeSafetyRuleWithContext(ctx, input) - - if !d.IsNewResource() && tfawserr.ErrCodeEquals(err, r53rcc.ErrCodeResourceNotFoundException) { + if !d.IsNewResource() && tfresource.NotFound(err) { log.Printf("[WARN] Route53 Recovery Control Config Safety Rule (%s) not found, removing from state", d.Id()) d.SetId("") return diags @@ -148,10 +147,6 @@ func resourceSafetyRuleRead(ctx context.Context, d *schema.ResourceData, meta in return sdkdiag.AppendErrorf(diags, "describing Route53 Recovery Control Config Safety Rule: %s", err) } - if output == nil { - return sdkdiag.AppendErrorf(diags, "describing Route53 Recovery Control Config Safety Rule: %s", "empty response") - } - if output.AssertionRule != nil { result := output.AssertionRule d.Set(names.AttrARN, result.SafetyRuleArn) @@ -160,7 +155,7 @@ func resourceSafetyRuleRead(ctx context.Context, d *schema.ResourceData, meta in d.Set(names.AttrStatus, result.Status) d.Set("wait_period_ms", result.WaitPeriodMs) - if err := d.Set("asserted_controls", flex.FlattenStringList(result.AssertedControls)); err != nil { + if err := d.Set("asserted_controls", flex.FlattenStringValueList(result.AssertedControls)); err != nil { return sdkdiag.AppendErrorf(diags, "setting asserted_controls: %s", err) } @@ -181,11 +176,11 @@ func resourceSafetyRuleRead(ctx context.Context, d *schema.ResourceData, meta in d.Set(names.AttrStatus, result.Status) d.Set("wait_period_ms", result.WaitPeriodMs) - if err := d.Set("gating_controls", flex.FlattenStringList(result.GatingControls)); err != nil { + if err := d.Set("gating_controls", flex.FlattenStringValueList(result.GatingControls)); err != nil { return sdkdiag.AppendErrorf(diags, "setting gating_controls: %s", err) } - if err := d.Set("target_controls", flex.FlattenStringList(result.TargetControls)); err != nil { + if err := d.Set("target_controls", flex.FlattenStringValueList(result.TargetControls)); err != nil { return sdkdiag.AppendErrorf(diags, "setting target_controls: %s", err) } @@ -214,14 +209,14 @@ func resourceSafetyRuleUpdate(ctx context.Context, d *schema.ResourceData, meta func resourceSafetyRuleDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).Route53RecoveryControlConfigConn(ctx) + conn := meta.(*conns.AWSClient).Route53RecoveryControlConfigClient(ctx) log.Printf("[INFO] Deleting Route53 Recovery Control Config Safety Rule: %s", d.Id()) - _, err := conn.DeleteSafetyRuleWithContext(ctx, &r53rcc.DeleteSafetyRuleInput{ + _, err := conn.DeleteSafetyRule(ctx, &r53rcc.DeleteSafetyRuleInput{ SafetyRuleArn: aws.String(d.Id()), }) - if tfawserr.ErrCodeEquals(err, r53rcc.ErrCodeResourceNotFoundException) { + if errs.IsA[*awstypes.ResourceNotFoundException](err) { return diags } @@ -231,7 +226,7 @@ func resourceSafetyRuleDelete(ctx context.Context, d *schema.ResourceData, meta _, err = waitSafetyRuleDeleted(ctx, conn, d.Id()) - if tfawserr.ErrCodeEquals(err, r53rcc.ErrCodeResourceNotFoundException) { + if errs.IsA[*awstypes.ResourceNotFoundException](err) { return diags } @@ -244,14 +239,14 @@ func resourceSafetyRuleDelete(ctx context.Context, d *schema.ResourceData, meta func createAssertionRule(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).Route53RecoveryControlConfigConn(ctx) + conn := meta.(*conns.AWSClient).Route53RecoveryControlConfigClient(ctx) - assertionRule := &r53rcc.NewAssertionRule{ + assertionRule := &awstypes.NewAssertionRule{ Name: aws.String(d.Get(names.AttrName).(string)), ControlPanelArn: aws.String(d.Get("control_panel_arn").(string)), - WaitPeriodMs: aws.Int64(int64(d.Get("wait_period_ms").(int))), + WaitPeriodMs: aws.Int32(int32(d.Get("wait_period_ms").(int))), RuleConfig: testAccSafetyRuleConfig_expandRule(d.Get("rule_config").([]interface{})[0].(map[string]interface{})), - AssertedControls: flex.ExpandStringList(d.Get("asserted_controls").([]interface{})), + AssertedControls: flex.ExpandStringValueList(d.Get("asserted_controls").([]interface{})), } input := &r53rcc.CreateSafetyRuleInput{ @@ -259,7 +254,7 @@ func createAssertionRule(ctx context.Context, d *schema.ResourceData, meta inter AssertionRule: assertionRule, } - output, err := conn.CreateSafetyRuleWithContext(ctx, input) + output, err := conn.CreateSafetyRule(ctx, input) result := output.AssertionRule if err != nil { @@ -270,7 +265,7 @@ func createAssertionRule(ctx context.Context, d *schema.ResourceData, meta inter return sdkdiag.AppendErrorf(diags, "creating Route53 Recovery Control Config Assertion Rule empty response") } - d.SetId(aws.StringValue(result.SafetyRuleArn)) + d.SetId(aws.ToString(result.SafetyRuleArn)) if _, err := waitSafetyRuleCreated(ctx, conn, d.Id()); err != nil { return sdkdiag.AppendErrorf(diags, "waiting for Route53 Recovery Control Config Assertion Rule (%s) to be Deployed: %s", d.Id(), err) @@ -281,15 +276,15 @@ func createAssertionRule(ctx context.Context, d *schema.ResourceData, meta inter func createGatingRule(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).Route53RecoveryControlConfigConn(ctx) + conn := meta.(*conns.AWSClient).Route53RecoveryControlConfigClient(ctx) - gatingRule := &r53rcc.NewGatingRule{ + gatingRule := &awstypes.NewGatingRule{ Name: aws.String(d.Get(names.AttrName).(string)), ControlPanelArn: aws.String(d.Get("control_panel_arn").(string)), - WaitPeriodMs: aws.Int64(int64(d.Get("wait_period_ms").(int))), + WaitPeriodMs: aws.Int32(int32(d.Get("wait_period_ms").(int))), RuleConfig: testAccSafetyRuleConfig_expandRule(d.Get("rule_config").([]interface{})[0].(map[string]interface{})), - GatingControls: flex.ExpandStringList(d.Get("gating_controls").([]interface{})), - TargetControls: flex.ExpandStringList(d.Get("target_controls").([]interface{})), + GatingControls: flex.ExpandStringValueList(d.Get("gating_controls").([]interface{})), + TargetControls: flex.ExpandStringValueList(d.Get("target_controls").([]interface{})), } input := &r53rcc.CreateSafetyRuleInput{ @@ -297,7 +292,7 @@ func createGatingRule(ctx context.Context, d *schema.ResourceData, meta interfac GatingRule: gatingRule, } - output, err := conn.CreateSafetyRuleWithContext(ctx, input) + output, err := conn.CreateSafetyRule(ctx, input) result := output.GatingRule if err != nil { @@ -308,7 +303,7 @@ func createGatingRule(ctx context.Context, d *schema.ResourceData, meta interfac return sdkdiag.AppendErrorf(diags, "creating Route53 Recovery Control Config Gating Rule empty response") } - d.SetId(aws.StringValue(result.SafetyRuleArn)) + d.SetId(aws.ToString(result.SafetyRuleArn)) if _, err := waitSafetyRuleCreated(ctx, conn, d.Id()); err != nil { return sdkdiag.AppendErrorf(diags, "waiting for Route53 Recovery Control Config Assertion Rule (%s) to be Deployed: %s", d.Id(), err) @@ -319,9 +314,9 @@ func createGatingRule(ctx context.Context, d *schema.ResourceData, meta interfac func updateAssertionRule(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).Route53RecoveryControlConfigConn(ctx) + conn := meta.(*conns.AWSClient).Route53RecoveryControlConfigClient(ctx) - assertionRuleUpdate := &r53rcc.AssertionRuleUpdate{ + assertionRuleUpdate := &awstypes.AssertionRuleUpdate{ SafetyRuleArn: aws.String(d.Get(names.AttrARN).(string)), } @@ -330,14 +325,14 @@ func updateAssertionRule(ctx context.Context, d *schema.ResourceData, meta inter } if d.HasChange("wait_period_ms") { - assertionRuleUpdate.WaitPeriodMs = aws.Int64(int64(d.Get("wait_period_ms").(int))) + assertionRuleUpdate.WaitPeriodMs = aws.Int32(int32(d.Get("wait_period_ms").(int))) } input := &r53rcc.UpdateSafetyRuleInput{ AssertionRuleUpdate: assertionRuleUpdate, } - _, err := conn.UpdateSafetyRuleWithContext(ctx, input) + _, err := conn.UpdateSafetyRule(ctx, input) if err != nil { return sdkdiag.AppendErrorf(diags, "updating Route53 Recovery Control Config Assertion Rule: %s", err) @@ -348,9 +343,9 @@ func updateAssertionRule(ctx context.Context, d *schema.ResourceData, meta inter func updateGatingRule(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).Route53RecoveryControlConfigConn(ctx) + conn := meta.(*conns.AWSClient).Route53RecoveryControlConfigClient(ctx) - gatingRuleUpdate := &r53rcc.GatingRuleUpdate{ + gatingRuleUpdate := &awstypes.GatingRuleUpdate{ SafetyRuleArn: aws.String(d.Get(names.AttrARN).(string)), } @@ -359,14 +354,14 @@ func updateGatingRule(ctx context.Context, d *schema.ResourceData, meta interfac } if d.HasChange("wait_period_ms") { - gatingRuleUpdate.WaitPeriodMs = aws.Int64(int64(d.Get("wait_period_ms").(int))) + gatingRuleUpdate.WaitPeriodMs = aws.Int32(int32(d.Get("wait_period_ms").(int))) } input := &r53rcc.UpdateSafetyRuleInput{ GatingRuleUpdate: gatingRuleUpdate, } - _, err := conn.UpdateSafetyRuleWithContext(ctx, input) + _, err := conn.UpdateSafetyRule(ctx, input) if err != nil { return sdkdiag.AppendErrorf(diags, "updating Route53 Recovery Control Config Gating Rule: %s", err) @@ -375,28 +370,51 @@ func updateGatingRule(ctx context.Context, d *schema.ResourceData, meta interfac return append(diags, sdkdiag.WrapDiagsf(resourceControlPanelRead(ctx, d, meta), "updating Route53 Recovery Control Config Gating Rule")...) } -func testAccSafetyRuleConfig_expandRule(tfMap map[string]interface{}) *r53rcc.RuleConfig { +func findSafetyRuleByARN(ctx context.Context, conn *r53rcc.Client, arn string) (*r53rcc.DescribeSafetyRuleOutput, error) { + input := &r53rcc.DescribeSafetyRuleInput{ + SafetyRuleArn: aws.String(arn), + } + + output, err := conn.DescribeSafetyRule(ctx, input) + if errs.IsA[*awstypes.ResourceNotFoundException](err) { + return nil, &retry.NotFoundError{ + LastError: err, + LastRequest: input, + } + } + if err != nil { + return nil, err + } + + if output == nil { + return nil, tfresource.NewEmptyResultError(input) + } + + return output, nil +} + +func testAccSafetyRuleConfig_expandRule(tfMap map[string]interface{}) *awstypes.RuleConfig { if tfMap == nil { return nil } - apiObject := &r53rcc.RuleConfig{} + apiObject := &awstypes.RuleConfig{} if v, ok := tfMap["inverted"].(bool); ok { apiObject.Inverted = aws.Bool(v) } if v, ok := tfMap["threshold"].(int); ok { - apiObject.Threshold = aws.Int64(int64(v)) + apiObject.Threshold = aws.Int32(int32(v)) } if v, ok := tfMap[names.AttrType].(string); ok && v != "" { - apiObject.Type = aws.String(v) + apiObject.Type = awstypes.RuleType(v) } return apiObject } -func flattenRuleConfig(apiObject *r53rcc.RuleConfig) map[string]interface{} { +func flattenRuleConfig(apiObject *awstypes.RuleConfig) map[string]interface{} { if apiObject == nil { return nil } @@ -404,16 +422,14 @@ func flattenRuleConfig(apiObject *r53rcc.RuleConfig) map[string]interface{} { tfMap := map[string]interface{}{} if v := apiObject.Inverted; v != nil { - tfMap["inverted"] = aws.BoolValue(v) + tfMap["inverted"] = aws.ToBool(v) } if v := apiObject.Threshold; v != nil { - tfMap["threshold"] = aws.Int64Value(v) + tfMap["threshold"] = aws.ToInt32(v) } - if v := apiObject.Type; v != nil { - tfMap[names.AttrType] = aws.StringValue(v) - } + tfMap[names.AttrType] = apiObject.Type return tfMap } diff --git a/internal/service/route53recoverycontrolconfig/safety_rule_test.go b/internal/service/route53recoverycontrolconfig/safety_rule_test.go index a2f65f46593..ba49f1fb452 100644 --- a/internal/service/route53recoverycontrolconfig/safety_rule_test.go +++ b/internal/service/route53recoverycontrolconfig/safety_rule_test.go @@ -8,14 +8,13 @@ import ( "fmt" "testing" - "github.com/aws/aws-sdk-go/aws" - r53rcc "github.com/aws/aws-sdk-go/service/route53recoverycontrolconfig" 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" tfroute53recoverycontrolconfig "github.com/hashicorp/terraform-provider-aws/internal/service/route53recoverycontrolconfig" + "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -25,7 +24,10 @@ func testAccSafetyRule_assertionRule(t *testing.T) { resourceName := "aws_route53recoverycontrolconfig_safety_rule.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionHasService(t, r53rcc.EndpointsID) }, + PreCheck: func() { + acctest.PreCheck(ctx, t) + acctest.PreCheckPartitionHasService(t, names.Route53RecoveryControlConfigEndpointID) + }, ErrorCheck: acctest.ErrorCheck(t, names.Route53RecoveryControlConfigServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckSafetyRuleDestroy(ctx), @@ -56,7 +58,10 @@ func testAccSafetyRule_disappears(t *testing.T) { resourceName := "aws_route53recoverycontrolconfig_safety_rule.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionHasService(t, r53rcc.EndpointsID) }, + PreCheck: func() { + acctest.PreCheck(ctx, t) + acctest.PreCheckPartitionHasService(t, names.Route53RecoveryControlConfigEndpointID) + }, ErrorCheck: acctest.ErrorCheck(t, names.Route53RecoveryControlConfigServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckSafetyRuleDestroy(ctx), @@ -79,7 +84,10 @@ func testAccSafetyRule_gatingRule(t *testing.T) { resourceName := "aws_route53recoverycontrolconfig_safety_rule.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionHasService(t, r53rcc.EndpointsID) }, + PreCheck: func() { + acctest.PreCheck(ctx, t) + acctest.PreCheckPartitionHasService(t, names.Route53RecoveryControlConfigEndpointID) + }, ErrorCheck: acctest.ErrorCheck(t, names.Route53RecoveryControlConfigServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckSafetyRuleDestroy(ctx), @@ -107,22 +115,24 @@ func testAccSafetyRule_gatingRule(t *testing.T) { func testAccCheckSafetyRuleDestroy(ctx context.Context) resource.TestCheckFunc { return func(s *terraform.State) error { - conn := acctest.Provider.Meta().(*conns.AWSClient).Route53RecoveryControlConfigConn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).Route53RecoveryControlConfigClient(ctx) for _, rs := range s.RootModule().Resources { if rs.Type != "aws_route53recoverycontrolconfig_safety_rule" { continue } - input := &r53rcc.DescribeSafetyRuleInput{ - SafetyRuleArn: aws.String(rs.Primary.ID), - } + _, err := tfroute53recoverycontrolconfig.FindSafetyRuleByARN(ctx, conn, rs.Primary.ID) - _, err := conn.DescribeSafetyRuleWithContext(ctx, input) + if tfresource.NotFound(err) { + continue + } - if err == nil { - return fmt.Errorf("Route53RecoveryControlConfig Safety Rule (%s) not deleted", rs.Primary.ID) + if err != nil { + return err } + + return fmt.Errorf("Route53RecoveryControlConfig Safety Rule (%s) not deleted", rs.Primary.ID) } return nil @@ -136,13 +146,9 @@ func testAccCheckSafetyRuleExists(ctx context.Context, name string) resource.Tes return fmt.Errorf("Not found: %s", name) } - conn := acctest.Provider.Meta().(*conns.AWSClient).Route53RecoveryControlConfigConn(ctx) - - input := &r53rcc.DescribeSafetyRuleInput{ - SafetyRuleArn: aws.String(rs.Primary.ID), - } + conn := acctest.Provider.Meta().(*conns.AWSClient).Route53RecoveryControlConfigClient(ctx) - _, err := conn.DescribeSafetyRuleWithContext(ctx, input) + _, err := tfroute53recoverycontrolconfig.FindSafetyRuleByARN(ctx, conn, rs.Primary.ID) return err } From 96207a6bcaa82aef835c8d11e96cbd31d4604c99 Mon Sep 17 00:00:00 2001 From: Daniel Rieske Date: Thu, 8 Aug 2024 22:13:38 +0200 Subject: [PATCH 06/17] feat: migrate sweepers --- .../route53recoverycontrolconfig/sweep.go | 249 ++++++++---------- 1 file changed, 111 insertions(+), 138 deletions(-) diff --git a/internal/service/route53recoverycontrolconfig/sweep.go b/internal/service/route53recoverycontrolconfig/sweep.go index 225e8fd826f..3acfc46dde7 100644 --- a/internal/service/route53recoverycontrolconfig/sweep.go +++ b/internal/service/route53recoverycontrolconfig/sweep.go @@ -7,12 +7,12 @@ import ( "fmt" "log" - "github.com/aws/aws-sdk-go/aws" - r53rcc "github.com/aws/aws-sdk-go/service/route53recoverycontrolconfig" + "github.com/aws/aws-sdk-go-v2/aws" + r53rcc "github.com/aws/aws-sdk-go-v2/service/route53recoverycontrolconfig" multierror "github.com/hashicorp/go-multierror" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-provider-aws/internal/sweep" - "github.com/hashicorp/terraform-provider-aws/internal/sweep/awsv1" + "github.com/hashicorp/terraform-provider-aws/internal/sweep/awsv2" ) func RegisterSweepers() { @@ -50,33 +50,30 @@ func sweepClusters(region string) error { if err != nil { return fmt.Errorf("error getting client: %w", err) } - conn := client.Route53RecoveryControlConfigConn(ctx) + conn := client.Route53RecoveryControlConfigClient(ctx) input := &r53rcc.ListClustersInput{} sweepResources := make([]sweep.Sweepable, 0) - err = conn.ListClustersPagesWithContext(ctx, input, func(page *r53rcc.ListClustersOutput, lastPage bool) bool { - if page == nil { - return !lastPage + pages := r53rcc.NewListClustersPaginator(conn, input) + for pages.HasMorePages() { + page, err := pages.NextPage(ctx) + + if awsv2.SkipSweepError(err) { + log.Printf("[WARN] Skipping Route53 Recovery Control Config Cluster sweep for %s: %s", region, err) + return nil + } + + if err != nil { + return fmt.Errorf("error listing Route53 Recovery Control Config Clusters (%s): %w", region, err) } for _, v := range page.Clusters { - r := ResourceCluster() + r := resourceCluster() d := r.Data(nil) - d.SetId(aws.StringValue(v.ClusterArn)) + d.SetId(aws.ToString(v.ClusterArn)) sweepResources = append(sweepResources, sweep.NewSweepResource(r, d, client)) } - - return !lastPage - }) - - if awsv1.SkipSweepError(err) { - log.Printf("[WARN] Skipping Route53 Recovery Control Config Cluster sweep for %s: %s", region, err) - return nil - } - - if err != nil { - return fmt.Errorf("error listing Route53 Recovery Control Config Clusters (%s): %w", region, err) } err = sweep.SweepOrchestrator(ctx, sweepResources) @@ -94,14 +91,22 @@ func sweepControlPanels(region string) error { if err != nil { return fmt.Errorf("error getting client: %w", err) } - conn := client.Route53RecoveryControlConfigConn(ctx) + conn := client.Route53RecoveryControlConfigClient(ctx) input := &r53rcc.ListClustersInput{} var sweeperErrs *multierror.Error sweepResources := make([]sweep.Sweepable, 0) - err = conn.ListClustersPagesWithContext(ctx, input, func(page *r53rcc.ListClustersOutput, lastPage bool) bool { - if page == nil { - return !lastPage + pages := r53rcc.NewListClustersPaginator(conn, input) + for pages.HasMorePages() { + page, err := pages.NextPage(ctx) + + if awsv2.SkipSweepError(err) { + log.Printf("[WARN] Skipping Route53 Recovery Control Config Control Panel sweep for %s: %s", region, err) + return sweeperErrs.ErrorOrNil() + } + + if err != nil { + sweeperErrs = multierror.Append(sweeperErrs, fmt.Errorf("error listing Route53 Recovery Control Config Clusters (%s): %w", region, err)) } for _, v := range page.Clusters { @@ -109,45 +114,31 @@ func sweepControlPanels(region string) error { ClusterArn: v.ClusterArn, } - err := conn.ListControlPanelsPagesWithContext(ctx, input, func(page *r53rcc.ListControlPanelsOutput, lastPage bool) bool { - if page == nil { - return !lastPage + pages := r53rcc.NewListControlPanelsPaginator(conn, input) + for pages.HasMorePages() { + page, err := pages.NextPage(ctx) + + if awsv2.SkipSweepError(err) { + continue + } + + if err != nil { + sweeperErrs = multierror.Append(sweeperErrs, fmt.Errorf("error listing Route53 Recovery Control Config Control Panels (%s): %w", region, err)) } for _, v := range page.ControlPanels { - if aws.BoolValue(v.DefaultControlPanel) { + if aws.ToBool(v.DefaultControlPanel) { continue } - r := ResourceControlPanel() + r := resourceControlPanel() d := r.Data(nil) - d.SetId(aws.StringValue(v.ControlPanelArn)) + d.SetId(aws.ToString(v.ControlPanelArn)) sweepResources = append(sweepResources, sweep.NewSweepResource(r, d, client)) } - - return !lastPage - }) - - if awsv1.SkipSweepError(err) { - continue - } - - if err != nil { - sweeperErrs = multierror.Append(sweeperErrs, fmt.Errorf("error listing Route53 Recovery Control Config Control Panels (%s): %w", region, err)) } } - - return !lastPage - }) - - if awsv1.SkipSweepError(err) { - log.Printf("[WARN] Skipping Route53 Recovery Control Config Control Panel sweep for %s: %s", region, err) - return sweeperErrs.ErrorOrNil() // In case we have completed some pages, but had errors - } - - if err != nil { - sweeperErrs = multierror.Append(sweeperErrs, fmt.Errorf("error listing Route53 Recovery Control Config Clusters (%s): %w", region, err)) } err = sweep.SweepOrchestrator(ctx, sweepResources) @@ -165,14 +156,22 @@ func sweepRoutingControls(region string) error { if err != nil { return fmt.Errorf("error getting client: %w", err) } - conn := client.Route53RecoveryControlConfigConn(ctx) + conn := client.Route53RecoveryControlConfigClient(ctx) input := &r53rcc.ListClustersInput{} var sweeperErrs *multierror.Error sweepResources := make([]sweep.Sweepable, 0) - err = conn.ListClustersPagesWithContext(ctx, input, func(page *r53rcc.ListClustersOutput, lastPage bool) bool { - if page == nil { - return !lastPage + pages := r53rcc.NewListClustersPaginator(conn, input) + for pages.HasMorePages() { + page, err := pages.NextPage(ctx) + + if awsv2.SkipSweepError(err) { + log.Printf("[WARN] Skipping Route53 Recovery Control Config Routing Control sweep for %s: %s", region, err) + return sweeperErrs.ErrorOrNil() + } + + if err != nil { + sweeperErrs = multierror.Append(sweeperErrs, fmt.Errorf("error listing Route53 Recovery Control Config Clusters (%s): %w", region, err)) } for _, v := range page.Clusters { @@ -180,9 +179,16 @@ func sweepRoutingControls(region string) error { ClusterArn: v.ClusterArn, } - err := conn.ListControlPanelsPagesWithContext(ctx, input, func(page *r53rcc.ListControlPanelsOutput, lastPage bool) bool { - if page == nil { - return !lastPage + pages := r53rcc.NewListControlPanelsPaginator(conn, input) + for pages.HasMorePages() { + page, err := pages.NextPage(ctx) + + if awsv2.SkipSweepError(err) { + continue + } + + if err != nil { + sweeperErrs = multierror.Append(sweeperErrs, fmt.Errorf("error listing Route53 Recovery Control Config Control Panels (%s): %w", region, err)) } for _, v := range page.ControlPanels { @@ -190,53 +196,29 @@ func sweepRoutingControls(region string) error { ControlPanelArn: v.ControlPanelArn, } - err := conn.ListRoutingControlsPagesWithContext(ctx, input, func(page *r53rcc.ListRoutingControlsOutput, lastPage bool) bool { - if page == nil { - return !lastPage + pages := r53rcc.NewListRoutingControlsPaginator(conn, input) + for pages.HasMorePages() { + page, err := pages.NextPage(ctx) + + if awsv2.SkipSweepError(err) { + continue + } + + if err != nil { + sweeperErrs = multierror.Append(sweeperErrs, fmt.Errorf("error listing Route53 Recovery Control Config Routing Controls (%s): %w", region, err)) } for _, v := range page.RoutingControls { - r := ResourceRoutingControl() + r := resourceRoutingControl() d := r.Data(nil) - d.SetId(aws.StringValue(v.RoutingControlArn)) + d.SetId(aws.ToString(v.RoutingControlArn)) sweepResources = append(sweepResources, sweep.NewSweepResource(r, d, client)) } - - return !lastPage - }) - - if awsv1.SkipSweepError(err) { - continue - } - - if err != nil { - sweeperErrs = multierror.Append(sweeperErrs, fmt.Errorf("error listing Route53 Recovery Control Config Routing Controls (%s): %w", region, err)) } } - - return !lastPage - }) - - if awsv1.SkipSweepError(err) { - continue - } - - if err != nil { - sweeperErrs = multierror.Append(sweeperErrs, fmt.Errorf("error listing Route53 Recovery Control Config Control Panels (%s): %w", region, err)) } } - - return !lastPage - }) - - if awsv1.SkipSweepError(err) { - log.Printf("[WARN] Skipping Route53 Recovery Control Config Routing Control sweep for %s: %s", region, err) - return sweeperErrs.ErrorOrNil() // In case we have completed some pages, but had errors - } - - if err != nil { - sweeperErrs = multierror.Append(sweeperErrs, fmt.Errorf("error listing Route53 Recovery Control Config Clusters (%s): %w", region, err)) } err = sweep.SweepOrchestrator(ctx, sweepResources) @@ -254,14 +236,22 @@ func sweepSafetyRules(region string) error { if err != nil { return fmt.Errorf("error getting client: %w", err) } - conn := client.Route53RecoveryControlConfigConn(ctx) + conn := client.Route53RecoveryControlConfigClient(ctx) input := &r53rcc.ListClustersInput{} var sweeperErrs *multierror.Error sweepResources := make([]sweep.Sweepable, 0) - err = conn.ListClustersPagesWithContext(ctx, input, func(page *r53rcc.ListClustersOutput, lastPage bool) bool { - if page == nil { - return !lastPage + pages := r53rcc.NewListClustersPaginator(conn, input) + for pages.HasMorePages() { + page, err := pages.NextPage(ctx) + + if awsv2.SkipSweepError(err) { + log.Printf("[WARN] Skipping Route53 Recovery Control Config Safety Rule sweep for %s: %s", region, err) + return sweeperErrs.ErrorOrNil() + } + + if err != nil { + sweeperErrs = multierror.Append(sweeperErrs, fmt.Errorf("error listing Route53 Recovery Control Config Clusters (%s): %w", region, err)) } for _, v := range page.Clusters { @@ -269,9 +259,16 @@ func sweepSafetyRules(region string) error { ClusterArn: v.ClusterArn, } - err := conn.ListControlPanelsPagesWithContext(ctx, input, func(page *r53rcc.ListControlPanelsOutput, lastPage bool) bool { - if page == nil { - return !lastPage + pages := r53rcc.NewListControlPanelsPaginator(conn, input) + for pages.HasMorePages() { + page, err := pages.NextPage(ctx) + + if awsv2.SkipSweepError(err) { + continue + } + + if err != nil { + sweeperErrs = multierror.Append(sweeperErrs, fmt.Errorf("error listing Route53 Recovery Control Config Control Panels (%s): %w", region, err)) } for _, v := range page.ControlPanels { @@ -279,59 +276,35 @@ func sweepSafetyRules(region string) error { ControlPanelArn: v.ControlPanelArn, } - err := conn.ListSafetyRulesPagesWithContext(ctx, input, func(page *r53rcc.ListSafetyRulesOutput, lastPage bool) bool { - if page == nil { - return !lastPage + pages := r53rcc.NewListSafetyRulesPaginator(conn, input) + for pages.HasMorePages() { + page, err := pages.NextPage(ctx) + + if awsv2.SkipSweepError(err) { + continue + } + + if err != nil { + sweeperErrs = multierror.Append(sweeperErrs, fmt.Errorf("error listing Route53 Recovery Control Config Safety Rules (%s): %w", region, err)) } for _, v := range page.SafetyRules { - r := ResourceSafetyRule() + r := resourceSafetyRule() d := r.Data(nil) if v.ASSERTION != nil { - d.SetId(aws.StringValue(v.ASSERTION.SafetyRuleArn)) + d.SetId(aws.ToString(v.ASSERTION.SafetyRuleArn)) } else if v.GATING != nil { - d.SetId(aws.StringValue(v.GATING.SafetyRuleArn)) + d.SetId(aws.ToString(v.GATING.SafetyRuleArn)) } else { continue } sweepResources = append(sweepResources, sweep.NewSweepResource(r, d, client)) } - - return !lastPage - }) - - if awsv1.SkipSweepError(err) { - continue - } - - if err != nil { - sweeperErrs = multierror.Append(sweeperErrs, fmt.Errorf("error listing Route53 Recovery Control Config Safety Rules (%s): %w", region, err)) } } - - return !lastPage - }) - - if awsv1.SkipSweepError(err) { - continue - } - - if err != nil { - sweeperErrs = multierror.Append(sweeperErrs, fmt.Errorf("error listing Route53 Recovery Control Config Control Panels (%s): %w", region, err)) } } - - return !lastPage - }) - - if awsv1.SkipSweepError(err) { - log.Printf("[WARN] Skipping Route53 Recovery Control Config Safety Rule sweep for %s: %s", region, err) - return sweeperErrs.ErrorOrNil() // In case we have completed some pages, but had errors - } - - if err != nil { - sweeperErrs = multierror.Append(sweeperErrs, fmt.Errorf("error listing Route53 Recovery Control Config Clusters (%s): %w", region, err)) } err = sweep.SweepOrchestrator(ctx, sweepResources) From 3bf03b0752c6f3650545750ecc188f237d45a57a Mon Sep 17 00:00:00 2001 From: Daniel Rieske Date: Thu, 8 Aug 2024 22:13:56 +0200 Subject: [PATCH 07/17] chore: add endpoints id --- names/names.go | 209 +++++++++++++++++++++++++------------------------ 1 file changed, 105 insertions(+), 104 deletions(-) diff --git a/names/names.go b/names/names.go index 48a54a31486..fe69436f2db 100644 --- a/names/names.go +++ b/names/names.go @@ -26,110 +26,111 @@ import ( // Endpoint constants defined by the AWS SDK v1 but not defined in the AWS SDK v2. const ( - ACMPCAEndpointID = "acm-pca" - AMPEndpointID = "aps" - APIGatewayID = "apigateway" - APIGatewayV2EndpointID = "apigateway" - AccessAnalyzerEndpointID = "access-analyzer" - AmplifyEndpointID = "amplify" - AppConfigEndpointID = "appconfig" - AppFabricEndpointID = "appfabric" - AppIntegrationsEndpointID = "app-integrations" - AppMeshEndpointID = "appmesh" - AppStreamEndpointID = "appstream2" - AppSyncEndpointID = "appsync" - ApplicationAutoscalingEndpointID = "application-autoscaling" - ApplicationInsightsEndpointID = "applicationinsights" - AthenaEndpointID = "athena" - AuditManagerEndpointID = "auditmanager" - AutoScalingPlansEndpointID = "autoscaling-plans" - BCMDataExportsEndpointID = "bcm-data-exports" - BackupEndpointID = "backup" - BatchEndpointID = "batch" - BedrockAgentEndpointID = "bedrockagent" - BedrockEndpointID = "bedrock" - BudgetsEndpointID = "budgets" - ChimeEndpointID = "chime" - ChimeSDKMediaPipelinesEndpointID = "media-pipelines-chime" - ChimeSDKVoiceEndpointID = "voice-chime" - Cloud9EndpointID = "cloud9" - CloudFormationEndpointID = "cloudformation" - CloudFrontEndpointID = "cloudfront" - CloudSearchEndpointID = "cloudsearch" - CloudWatchEndpointID = "monitoring" - CodeArtifactEndpointID = "codeartifact" - CodeGuruReviewerEndpointID = "codeguru-reviewer" - CodeStarConnectionsEndpointID = "codestar-connections" - CognitoIdentityEndpointID = "cognito-identity" - ComprehendEndpointID = "comprehend" - ConfigServiceEndpointID = "config" - DataExchangeEndpointID = "dataexchange" - DataPipelineEndpointID = "datapipeline" - DetectiveEndpointID = "api.detective" - DeviceFarmEndpointID = "devicefarm" - DevOpsGuruEndpointID = "devops-guru" - DirectConnectEndpointID = "directconnect" - DLMEndpointID = "dlm" - ECREndpointID = "api.ecr" - ECSEndpointID = "ecs" - EFSEndpointID = "elasticfilesystem" - EKSEndpointID = "eks" - ELBEndpointID = "elasticloadbalancing" - EMREndpointID = "elasticmapreduce" - ElasticTranscoderEndpointID = "elastictranscoder" - ElastiCacheEndpointID = "elasticache" - EventsEndpointID = "events" - EvidentlyEndpointID = "evidently" - FMSEndpointID = "fms" - FSxEndpointID = "fsx" - GrafanaEndpointID = "grafana" - GlueEndpointID = "glue" - IVSEndpointID = "ivs" - IVSChatEndpointID = "ivschat" - IdentityStoreEndpointID = "identitystore" - Inspector2EndpointID = "inspector2" - KMSEndpointID = "kms" - KafkaConnectEndpointID = "kafkaconnect" - KendraEndpointID = "kendra" - LambdaEndpointID = "lambda" - LexV2ModelsEndpointID = "models-v2-lex" - LocationEndpointID = "location" - M2EndpointID = "m2" - MQEndpointID = "mq" - MediaConvertEndpointID = "mediaconvert" - MediaLiveEndpointID = "medialive" - ObservabilityAccessManagerEndpointID = "oam" - OpenSearchIngestionEndpointID = "osis" - OpenSearchServerlessEndpointID = "aoss" - PaymentCryptographyEndpointID = "paymentcryptography" - PipesEndpointID = "pipes" - PollyEndpointID = "polly" - QLDBEndpointID = "qldb" - RUMEndpointID = "rum" - RedshiftEndpointID = "redshift" - RedshiftServerlessEndpointID = "redshift-serverless" - RekognitionEndpointID = "rekognition" - ResourceExplorer2EndpointID = "resource-explorer-2" - RolesAnywhereEndpointID = "rolesanywhere" - Route53DomainsEndpointID = "route53domains" - SSMEndpointID = "ssm" - SSMIncidentsEndpointID = "ssm-incidents" - SSOAdminEndpointID = "sso" - STSEndpointID = "sts" - SchedulerEndpointID = "scheduler" - SchemasEndpointID = "schemas" - ServiceCatalogAppRegistryEndpointID = "servicecatalog-appregistry" - ServiceDiscoveryEndpointID = "servicediscovery" - ServiceQuotasEndpointID = "servicequotas" - SESEndpointID = "email" - ShieldEndpointID = "shield" - TranscribeEndpointID = "transcribe" - TransferEndpointID = "transfer" - VPCLatticeEndpointID = "vpc-lattice" - VerifiedPermissionsEndpointID = "verifiedpermissions" - WAFEndpointID = "waf" - WAFRegionalEndpointID = "waf-regional" - DataZoneEndpointID = "datazone" + ACMPCAEndpointID = "acm-pca" + AMPEndpointID = "aps" + APIGatewayID = "apigateway" + APIGatewayV2EndpointID = "apigateway" + AccessAnalyzerEndpointID = "access-analyzer" + AmplifyEndpointID = "amplify" + AppConfigEndpointID = "appconfig" + AppFabricEndpointID = "appfabric" + AppIntegrationsEndpointID = "app-integrations" + AppMeshEndpointID = "appmesh" + AppStreamEndpointID = "appstream2" + AppSyncEndpointID = "appsync" + ApplicationAutoscalingEndpointID = "application-autoscaling" + ApplicationInsightsEndpointID = "applicationinsights" + AthenaEndpointID = "athena" + AuditManagerEndpointID = "auditmanager" + AutoScalingPlansEndpointID = "autoscaling-plans" + BCMDataExportsEndpointID = "bcm-data-exports" + BackupEndpointID = "backup" + BatchEndpointID = "batch" + BedrockAgentEndpointID = "bedrockagent" + BedrockEndpointID = "bedrock" + BudgetsEndpointID = "budgets" + ChimeEndpointID = "chime" + ChimeSDKMediaPipelinesEndpointID = "media-pipelines-chime" + ChimeSDKVoiceEndpointID = "voice-chime" + Cloud9EndpointID = "cloud9" + CloudFormationEndpointID = "cloudformation" + CloudFrontEndpointID = "cloudfront" + CloudSearchEndpointID = "cloudsearch" + CloudWatchEndpointID = "monitoring" + CodeArtifactEndpointID = "codeartifact" + CodeGuruReviewerEndpointID = "codeguru-reviewer" + CodeStarConnectionsEndpointID = "codestar-connections" + CognitoIdentityEndpointID = "cognito-identity" + ComprehendEndpointID = "comprehend" + ConfigServiceEndpointID = "config" + DataExchangeEndpointID = "dataexchange" + DataPipelineEndpointID = "datapipeline" + DetectiveEndpointID = "api.detective" + DeviceFarmEndpointID = "devicefarm" + DevOpsGuruEndpointID = "devops-guru" + DirectConnectEndpointID = "directconnect" + DLMEndpointID = "dlm" + ECREndpointID = "api.ecr" + ECSEndpointID = "ecs" + EFSEndpointID = "elasticfilesystem" + EKSEndpointID = "eks" + ELBEndpointID = "elasticloadbalancing" + EMREndpointID = "elasticmapreduce" + ElasticTranscoderEndpointID = "elastictranscoder" + ElastiCacheEndpointID = "elasticache" + EventsEndpointID = "events" + EvidentlyEndpointID = "evidently" + FMSEndpointID = "fms" + FSxEndpointID = "fsx" + GrafanaEndpointID = "grafana" + GlueEndpointID = "glue" + IVSEndpointID = "ivs" + IVSChatEndpointID = "ivschat" + IdentityStoreEndpointID = "identitystore" + Inspector2EndpointID = "inspector2" + KMSEndpointID = "kms" + KafkaConnectEndpointID = "kafkaconnect" + KendraEndpointID = "kendra" + LambdaEndpointID = "lambda" + LexV2ModelsEndpointID = "models-v2-lex" + LocationEndpointID = "location" + M2EndpointID = "m2" + MQEndpointID = "mq" + MediaConvertEndpointID = "mediaconvert" + MediaLiveEndpointID = "medialive" + ObservabilityAccessManagerEndpointID = "oam" + OpenSearchIngestionEndpointID = "osis" + OpenSearchServerlessEndpointID = "aoss" + PaymentCryptographyEndpointID = "paymentcryptography" + PipesEndpointID = "pipes" + PollyEndpointID = "polly" + QLDBEndpointID = "qldb" + RUMEndpointID = "rum" + RedshiftEndpointID = "redshift" + RedshiftServerlessEndpointID = "redshift-serverless" + RekognitionEndpointID = "rekognition" + ResourceExplorer2EndpointID = "resource-explorer-2" + RolesAnywhereEndpointID = "rolesanywhere" + Route53DomainsEndpointID = "route53domains" + Route53RecoveryControlConfigEndpointID = "route53recoverycontrolconfig" + SSMEndpointID = "ssm" + SSMIncidentsEndpointID = "ssm-incidents" + SSOAdminEndpointID = "sso" + STSEndpointID = "sts" + SchedulerEndpointID = "scheduler" + SchemasEndpointID = "schemas" + ServiceCatalogAppRegistryEndpointID = "servicecatalog-appregistry" + ServiceDiscoveryEndpointID = "servicediscovery" + ServiceQuotasEndpointID = "servicequotas" + SESEndpointID = "email" + ShieldEndpointID = "shield" + TranscribeEndpointID = "transcribe" + TransferEndpointID = "transfer" + VPCLatticeEndpointID = "vpc-lattice" + VerifiedPermissionsEndpointID = "verifiedpermissions" + WAFEndpointID = "waf" + WAFRegionalEndpointID = "waf-regional" + DataZoneEndpointID = "datazone" ) // These should move to aws-sdk-go-base. From f8105c8701b213c54128f0e38f2593496a1e8738 Mon Sep 17 00:00:00 2001 From: Daniel Rieske Date: Thu, 8 Aug 2024 22:14:15 +0200 Subject: [PATCH 08/17] chore: regenerate service and remove v1 conn --- .../service_package.go | 44 ------------------- .../service_package_gen.go | 12 +++-- 2 files changed, 8 insertions(+), 48 deletions(-) delete mode 100644 internal/service/route53recoverycontrolconfig/service_package.go diff --git a/internal/service/route53recoverycontrolconfig/service_package.go b/internal/service/route53recoverycontrolconfig/service_package.go deleted file mode 100644 index 40b80654f04..00000000000 --- a/internal/service/route53recoverycontrolconfig/service_package.go +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package route53recoverycontrolconfig - -import ( - "context" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/endpoints" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/route53recoverycontrolconfig" - "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/hashicorp/terraform-provider-aws/names" -) - -// 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) (*route53recoverycontrolconfig.Route53RecoveryControlConfig, error) { - sess := config[names.AttrSession].(*session.Session) - - cfg := aws.Config{} - - if endpoint := config[names.AttrEndpoint].(string); endpoint != "" { - tflog.Debug(ctx, "setting endpoint", map[string]any{ - "tf_aws.endpoint": endpoint, - }) - cfg.Endpoint = aws.String(endpoint) - } else { - cfg.EndpointResolver = newEndpointResolverSDKv1(ctx) - } - - // Force "global" services to correct Regions. - if config["partition"].(string) == endpoints.AwsPartitionID { - if aws.StringValue(cfg.Region) != endpoints.UsWest2RegionID { - tflog.Info(ctx, "overriding region", map[string]any{ - "original_region": aws.StringValue(cfg.Region), - "override_region": endpoints.UsWest2RegionID, - }) - cfg.Region = aws.String(endpoints.UsWest2RegionID) - } - } - - return route53recoverycontrolconfig.New(sess.Copy(&cfg)), nil -} diff --git a/internal/service/route53recoverycontrolconfig/service_package_gen.go b/internal/service/route53recoverycontrolconfig/service_package_gen.go index 3fd3a00e12f..91538a17f90 100644 --- a/internal/service/route53recoverycontrolconfig/service_package_gen.go +++ b/internal/service/route53recoverycontrolconfig/service_package_gen.go @@ -27,20 +27,24 @@ func (p *servicePackage) SDKDataSources(ctx context.Context) []*types.ServicePac func (p *servicePackage) SDKResources(ctx context.Context) []*types.ServicePackageSDKResource { return []*types.ServicePackageSDKResource{ { - Factory: ResourceCluster, + Factory: resourceCluster, TypeName: "aws_route53recoverycontrolconfig_cluster", + Name: "Cluster", }, { - Factory: ResourceControlPanel, + Factory: resourceControlPanel, TypeName: "aws_route53recoverycontrolconfig_control_panel", + Name: "Control Panel", }, { - Factory: ResourceRoutingControl, + Factory: resourceRoutingControl, TypeName: "aws_route53recoverycontrolconfig_routing_control", + Name: "Routing Control", }, { - Factory: ResourceSafetyRule, + Factory: resourceSafetyRule, TypeName: "aws_route53recoverycontrolconfig_safety_rule", + Name: "Safety Rule", }, } } From 7ff0df14dce4569633baca9a07894c803433452e Mon Sep 17 00:00:00 2001 From: Daniel Rieske Date: Thu, 8 Aug 2024 22:14:26 +0200 Subject: [PATCH 09/17] feat: exports --- .../exports_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 internal/service/route53recoverycontrolconfig/exports_test.go diff --git a/internal/service/route53recoverycontrolconfig/exports_test.go b/internal/service/route53recoverycontrolconfig/exports_test.go new file mode 100644 index 00000000000..5af15d1257b --- /dev/null +++ b/internal/service/route53recoverycontrolconfig/exports_test.go @@ -0,0 +1,17 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package route53recoverycontrolconfig + +// Exports for use in tests only. +var ( + ResourceCluster = resourceCluster + ResourceControlPanel = resourceControlPanel + ResourceRoutingControl = resourceRoutingControl + ResourceSafetyRule = resourceSafetyRule + + FindClusterByARN = findClusterByARN + FindControlPanelByARN = findControlPanelByARN + FindRoutingControlByARN = findRoutingControlByARN + FindSafetyRuleByARN = findSafetyRuleByARN +) From 6cd167f17cbea17ac5ac51278ce62119a37a5d78 Mon Sep 17 00:00:00 2001 From: Daniel Rieske Date: Thu, 8 Aug 2024 22:14:38 +0200 Subject: [PATCH 10/17] feat: migrate `status` and `wait` --- .../route53recoverycontrolconfig/status.go | 54 +++++++++--------- .../route53recoverycontrolconfig/wait.go | 56 ++++++++++--------- 2 files changed, 56 insertions(+), 54 deletions(-) diff --git a/internal/service/route53recoverycontrolconfig/status.go b/internal/service/route53recoverycontrolconfig/status.go index c86024308d4..9de777ff6f3 100644 --- a/internal/service/route53recoverycontrolconfig/status.go +++ b/internal/service/route53recoverycontrolconfig/status.go @@ -6,77 +6,77 @@ package route53recoverycontrolconfig import ( "context" - "github.com/aws/aws-sdk-go/aws" - r53rcc "github.com/aws/aws-sdk-go/service/route53recoverycontrolconfig" + r53rcc "github.com/aws/aws-sdk-go-v2/service/route53recoverycontrolconfig" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" + "github.com/hashicorp/terraform-provider-aws/internal/tfresource" ) -func statusCluster(ctx context.Context, conn *r53rcc.Route53RecoveryControlConfig, clusterArn string) retry.StateRefreshFunc { +func statusCluster(ctx context.Context, conn *r53rcc.Client, clusterArn string) retry.StateRefreshFunc { return func() (interface{}, string, error) { - input := &r53rcc.DescribeClusterInput{ - ClusterArn: aws.String(clusterArn), - } + output, err := findClusterByARN(ctx, conn, clusterArn) - output, err := conn.DescribeClusterWithContext(ctx, input) + if tfresource.NotFound(err) { + return nil, "", nil + } if err != nil { return output, "", err } - return output, aws.StringValue(output.Cluster.Status), nil + return output, string(output.Status), nil } } -func statusRoutingControl(ctx context.Context, conn *r53rcc.Route53RecoveryControlConfig, routingControlArn string) retry.StateRefreshFunc { +func statusRoutingControl(ctx context.Context, conn *r53rcc.Client, routingControlArn string) retry.StateRefreshFunc { return func() (interface{}, string, error) { - input := &r53rcc.DescribeRoutingControlInput{ - RoutingControlArn: aws.String(routingControlArn), - } + output, err := findRoutingControlByARN(ctx, conn, routingControlArn) - output, err := conn.DescribeRoutingControlWithContext(ctx, input) + if tfresource.NotFound(err) { + return nil, "", nil + } if err != nil { return output, "", err } - return output, aws.StringValue(output.RoutingControl.Status), nil + return output, string(output.Status), nil } } -func statusControlPanel(ctx context.Context, conn *r53rcc.Route53RecoveryControlConfig, controlPanelArn string) retry.StateRefreshFunc { +func statusControlPanel(ctx context.Context, conn *r53rcc.Client, controlPanelArn string) retry.StateRefreshFunc { return func() (interface{}, string, error) { - input := &r53rcc.DescribeControlPanelInput{ - ControlPanelArn: aws.String(controlPanelArn), - } + output, err := findControlPanelByARN(ctx, conn, controlPanelArn) - output, err := conn.DescribeControlPanelWithContext(ctx, input) + if tfresource.NotFound(err) { + return nil, "", nil + } if err != nil { return output, "", err } - return output, aws.StringValue(output.ControlPanel.Status), nil + return output, string(output.Status), nil } } -func statusSafetyRule(ctx context.Context, conn *r53rcc.Route53RecoveryControlConfig, safetyRuleArn string) retry.StateRefreshFunc { +func statusSafetyRule(ctx context.Context, conn *r53rcc.Client, safetyRuleArn string) retry.StateRefreshFunc { return func() (interface{}, string, error) { - input := &r53rcc.DescribeSafetyRuleInput{ - SafetyRuleArn: aws.String(safetyRuleArn), - } + output, err := findSafetyRuleByARN(ctx, conn, safetyRuleArn) - output, err := conn.DescribeSafetyRuleWithContext(ctx, input) + if tfresource.NotFound(err) { + return nil, "", nil + } if err != nil { return output, "", err } if output.AssertionRule != nil { - return output, aws.StringValue(output.AssertionRule.Status), nil + return output, string(output.AssertionRule.Status), nil } if output.GatingRule != nil { - return output, aws.StringValue(output.GatingRule.Status), nil + return output, string(output.GatingRule.Status), nil } return output, "", nil diff --git a/internal/service/route53recoverycontrolconfig/wait.go b/internal/service/route53recoverycontrolconfig/wait.go index 621f023d227..10ecdcf3a13 100644 --- a/internal/service/route53recoverycontrolconfig/wait.go +++ b/internal/service/route53recoverycontrolconfig/wait.go @@ -7,8 +7,10 @@ import ( "context" "time" - r53rcc "github.com/aws/aws-sdk-go/service/route53recoverycontrolconfig" + r53rcc "github.com/aws/aws-sdk-go-v2/service/route53recoverycontrolconfig" + awstypes "github.com/aws/aws-sdk-go-v2/service/route53recoverycontrolconfig/types" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" + "github.com/hashicorp/terraform-provider-aws/internal/enum" ) const ( @@ -16,10 +18,10 @@ const ( minTimeout = 5 * time.Second ) -func waitClusterCreated(ctx context.Context, conn *r53rcc.Route53RecoveryControlConfig, clusterArn string) (*r53rcc.DescribeClusterOutput, error) { +func waitClusterCreated(ctx context.Context, conn *r53rcc.Client, clusterArn string) (*awstypes.Cluster, error) { stateConf := &retry.StateChangeConf{ - Pending: []string{r53rcc.StatusPending}, - Target: []string{r53rcc.StatusDeployed}, + Pending: enum.Slice(awstypes.StatusPending), + Target: enum.Slice(awstypes.StatusDeployed), Refresh: statusCluster(ctx, conn, clusterArn), Timeout: timeout, MinTimeout: minTimeout, @@ -27,16 +29,16 @@ func waitClusterCreated(ctx context.Context, conn *r53rcc.Route53RecoveryControl outputRaw, err := stateConf.WaitForStateContext(ctx) - if output, ok := outputRaw.(*r53rcc.DescribeClusterOutput); ok { + if output, ok := outputRaw.(*awstypes.Cluster); ok { return output, err } return nil, err } -func waitClusterDeleted(ctx context.Context, conn *r53rcc.Route53RecoveryControlConfig, clusterArn string) (*r53rcc.DescribeClusterOutput, error) { +func waitClusterDeleted(ctx context.Context, conn *r53rcc.Client, clusterArn string) (*awstypes.Cluster, error) { stateConf := &retry.StateChangeConf{ - Pending: []string{r53rcc.StatusPendingDeletion}, + Pending: enum.Slice(awstypes.StatusPendingDeletion), Target: []string{}, Refresh: statusCluster(ctx, conn, clusterArn), Timeout: timeout, @@ -46,17 +48,17 @@ func waitClusterDeleted(ctx context.Context, conn *r53rcc.Route53RecoveryControl outputRaw, err := stateConf.WaitForStateContext(ctx) - if output, ok := outputRaw.(*r53rcc.DescribeClusterOutput); ok { + if output, ok := outputRaw.(*awstypes.Cluster); ok { return output, err } return nil, err } -func waitRoutingControlCreated(ctx context.Context, conn *r53rcc.Route53RecoveryControlConfig, routingControlArn string) (*r53rcc.DescribeRoutingControlOutput, error) { +func waitRoutingControlCreated(ctx context.Context, conn *r53rcc.Client, routingControlArn string) (*awstypes.RoutingControl, error) { stateConf := &retry.StateChangeConf{ - Pending: []string{r53rcc.StatusPending}, - Target: []string{r53rcc.StatusDeployed}, + Pending: enum.Slice(awstypes.StatusPending), + Target: enum.Slice(awstypes.StatusDeployed), Refresh: statusRoutingControl(ctx, conn, routingControlArn), Timeout: timeout, MinTimeout: minTimeout, @@ -64,16 +66,16 @@ func waitRoutingControlCreated(ctx context.Context, conn *r53rcc.Route53Recovery outputRaw, err := stateConf.WaitForStateContext(ctx) - if output, ok := outputRaw.(*r53rcc.DescribeRoutingControlOutput); ok { + if output, ok := outputRaw.(*awstypes.RoutingControl); ok { return output, err } return nil, err } -func waitRoutingControlDeleted(ctx context.Context, conn *r53rcc.Route53RecoveryControlConfig, routingControlArn string) (*r53rcc.DescribeRoutingControlOutput, error) { +func waitRoutingControlDeleted(ctx context.Context, conn *r53rcc.Client, routingControlArn string) (*awstypes.RoutingControl, error) { stateConf := &retry.StateChangeConf{ - Pending: []string{r53rcc.StatusPendingDeletion}, + Pending: enum.Slice(awstypes.StatusPendingDeletion), Target: []string{}, Refresh: statusRoutingControl(ctx, conn, routingControlArn), Timeout: timeout, @@ -83,17 +85,17 @@ func waitRoutingControlDeleted(ctx context.Context, conn *r53rcc.Route53Recovery outputRaw, err := stateConf.WaitForStateContext(ctx) - if output, ok := outputRaw.(*r53rcc.DescribeRoutingControlOutput); ok { + if output, ok := outputRaw.(*awstypes.RoutingControl); ok { return output, err } return nil, err } -func waitControlPanelCreated(ctx context.Context, conn *r53rcc.Route53RecoveryControlConfig, controlPanelArn string) (*r53rcc.DescribeControlPanelOutput, error) { +func waitControlPanelCreated(ctx context.Context, conn *r53rcc.Client, controlPanelArn string) (*awstypes.ControlPanel, error) { stateConf := &retry.StateChangeConf{ - Pending: []string{r53rcc.StatusPending}, - Target: []string{r53rcc.StatusDeployed}, + Pending: enum.Slice(awstypes.StatusPending), + Target: enum.Slice(awstypes.StatusDeployed), Refresh: statusControlPanel(ctx, conn, controlPanelArn), Timeout: timeout, MinTimeout: minTimeout, @@ -101,16 +103,16 @@ func waitControlPanelCreated(ctx context.Context, conn *r53rcc.Route53RecoveryCo outputRaw, err := stateConf.WaitForStateContext(ctx) - if output, ok := outputRaw.(*r53rcc.DescribeControlPanelOutput); ok { + if output, ok := outputRaw.(*awstypes.ControlPanel); ok { return output, err } return nil, err } -func waitControlPanelDeleted(ctx context.Context, conn *r53rcc.Route53RecoveryControlConfig, controlPanelArn string) (*r53rcc.DescribeControlPanelOutput, error) { +func waitControlPanelDeleted(ctx context.Context, conn *r53rcc.Client, controlPanelArn string) (*awstypes.ControlPanel, error) { stateConf := &retry.StateChangeConf{ - Pending: []string{r53rcc.StatusPendingDeletion}, + Pending: enum.Slice(awstypes.StatusPendingDeletion), Target: []string{}, Refresh: statusControlPanel(ctx, conn, controlPanelArn), Timeout: timeout, @@ -120,17 +122,17 @@ func waitControlPanelDeleted(ctx context.Context, conn *r53rcc.Route53RecoveryCo outputRaw, err := stateConf.WaitForStateContext(ctx) - if output, ok := outputRaw.(*r53rcc.DescribeControlPanelOutput); ok { + if output, ok := outputRaw.(*awstypes.ControlPanel); ok { return output, err } return nil, err } -func waitSafetyRuleCreated(ctx context.Context, conn *r53rcc.Route53RecoveryControlConfig, safetyRuleArn string) (*r53rcc.DescribeSafetyRuleOutput, error) { //nolint:unparam +func waitSafetyRuleCreated(ctx context.Context, conn *r53rcc.Client, safetyRuleArn string) (*r53rcc.DescribeSafetyRuleOutput, error) { //nolint:unparam stateConf := &retry.StateChangeConf{ - Pending: []string{r53rcc.StatusPending}, - Target: []string{r53rcc.StatusDeployed}, + Pending: enum.Slice(awstypes.StatusPending), + Target: enum.Slice(awstypes.StatusDeployed), Refresh: statusSafetyRule(ctx, conn, safetyRuleArn), Timeout: timeout, MinTimeout: minTimeout, @@ -145,9 +147,9 @@ func waitSafetyRuleCreated(ctx context.Context, conn *r53rcc.Route53RecoveryCont return nil, err } -func waitSafetyRuleDeleted(ctx context.Context, conn *r53rcc.Route53RecoveryControlConfig, safetyRuleArn string) (*r53rcc.DescribeSafetyRuleOutput, error) { +func waitSafetyRuleDeleted(ctx context.Context, conn *r53rcc.Client, safetyRuleArn string) (*r53rcc.DescribeSafetyRuleOutput, error) { stateConf := &retry.StateChangeConf{ - Pending: []string{r53rcc.StatusPendingDeletion}, + Pending: enum.Slice(awstypes.StatusPendingDeletion), Target: []string{}, Refresh: statusSafetyRule(ctx, conn, safetyRuleArn), Timeout: timeout, From 3a6e72e74349cde63ad1f091e8c5414f4a703faa Mon Sep 17 00:00:00 2001 From: Daniel Rieske Date: Thu, 8 Aug 2024 22:21:37 +0200 Subject: [PATCH 11/17] chore: fmt names --- names/names.go | 212 ++++++++++++++++++++++++------------------------- 1 file changed, 106 insertions(+), 106 deletions(-) diff --git a/names/names.go b/names/names.go index a7d37c0bfb0..fcd9f69315a 100644 --- a/names/names.go +++ b/names/names.go @@ -26,112 +26,112 @@ import ( // Endpoint constants defined by the AWS SDK v1 but not defined in the AWS SDK v2. const ( - ACMPCAEndpointID = "acm-pca" - AMPEndpointID = "aps" - APIGatewayID = "apigateway" - APIGatewayV2EndpointID = "apigateway" - AccessAnalyzerEndpointID = "access-analyzer" - AmplifyEndpointID = "amplify" - AppConfigEndpointID = "appconfig" - AppFabricEndpointID = "appfabric" - AppIntegrationsEndpointID = "app-integrations" - AppMeshEndpointID = "appmesh" - AppStreamEndpointID = "appstream2" - AppSyncEndpointID = "appsync" - ApplicationAutoscalingEndpointID = "application-autoscaling" - ApplicationInsightsEndpointID = "applicationinsights" - AthenaEndpointID = "athena" - AuditManagerEndpointID = "auditmanager" - AutoScalingPlansEndpointID = "autoscaling-plans" - BCMDataExportsEndpointID = "bcm-data-exports" - BackupEndpointID = "backup" - BatchEndpointID = "batch" - BedrockAgentEndpointID = "bedrockagent" - BedrockEndpointID = "bedrock" - BudgetsEndpointID = "budgets" - ChimeEndpointID = "chime" - ChimeSDKMediaPipelinesEndpointID = "media-pipelines-chime" - ChimeSDKVoiceEndpointID = "voice-chime" - Cloud9EndpointID = "cloud9" - CloudFormationEndpointID = "cloudformation" - CloudFrontEndpointID = "cloudfront" - CloudSearchEndpointID = "cloudsearch" - CloudWatchEndpointID = "monitoring" - CodeArtifactEndpointID = "codeartifact" - CodeGuruReviewerEndpointID = "codeguru-reviewer" - CodeStarConnectionsEndpointID = "codestar-connections" - CognitoIdentityEndpointID = "cognito-identity" - ComprehendEndpointID = "comprehend" - ConfigServiceEndpointID = "config" - DataExchangeEndpointID = "dataexchange" - DataPipelineEndpointID = "datapipeline" - DetectiveEndpointID = "api.detective" - DeviceFarmEndpointID = "devicefarm" - DevOpsGuruEndpointID = "devops-guru" - DirectConnectEndpointID = "directconnect" - DLMEndpointID = "dlm" - ECREndpointID = "api.ecr" - ECSEndpointID = "ecs" - EFSEndpointID = "elasticfilesystem" - EKSEndpointID = "eks" - ELBEndpointID = "elasticloadbalancing" - EMREndpointID = "elasticmapreduce" - ElasticTranscoderEndpointID = "elastictranscoder" - ElastiCacheEndpointID = "elasticache" - EventsEndpointID = "events" - EvidentlyEndpointID = "evidently" - FMSEndpointID = "fms" - FSxEndpointID = "fsx" - GrafanaEndpointID = "grafana" - GlueEndpointID = "glue" - IVSEndpointID = "ivs" - IVSChatEndpointID = "ivschat" - IdentityStoreEndpointID = "identitystore" - Inspector2EndpointID = "inspector2" - KMSEndpointID = "kms" - KafkaConnectEndpointID = "kafkaconnect" - KendraEndpointID = "kendra" - LambdaEndpointID = "lambda" - LexV2ModelsEndpointID = "models-v2-lex" - LocationEndpointID = "location" - M2EndpointID = "m2" - MQEndpointID = "mq" - MediaConvertEndpointID = "mediaconvert" - MediaLiveEndpointID = "medialive" - ObservabilityAccessManagerEndpointID = "oam" - OpenSearchIngestionEndpointID = "osis" - OpenSearchServerlessEndpointID = "aoss" - PaymentCryptographyEndpointID = "paymentcryptography" - PipesEndpointID = "pipes" - PollyEndpointID = "polly" - QLDBEndpointID = "qldb" - RUMEndpointID = "rum" - RedshiftEndpointID = "redshift" - RedshiftServerlessEndpointID = "redshift-serverless" - RekognitionEndpointID = "rekognition" - ResourceExplorer2EndpointID = "resource-explorer-2" - RolesAnywhereEndpointID = "rolesanywhere" - Route53DomainsEndpointID = "route53domains" - Route53RecoveryControlConfigEndpointID = "route53recoverycontrolconfig" - ServiceCatalogEndpointID = "servicecatalog" - SSMEndpointID = "ssm" - SSMIncidentsEndpointID = "ssm-incidents" - SSOAdminEndpointID = "sso" - STSEndpointID = "sts" - SchedulerEndpointID = "scheduler" - SchemasEndpointID = "schemas" - ServiceCatalogAppRegistryEndpointID = "servicecatalog-appregistry" - ServiceDiscoveryEndpointID = "servicediscovery" - ServiceQuotasEndpointID = "servicequotas" - SESEndpointID = "email" - ShieldEndpointID = "shield" - TranscribeEndpointID = "transcribe" - TransferEndpointID = "transfer" - VPCLatticeEndpointID = "vpc-lattice" - VerifiedPermissionsEndpointID = "verifiedpermissions" - WAFEndpointID = "waf" - WAFRegionalEndpointID = "waf-regional" - DataZoneEndpointID = "datazone" + ACMPCAEndpointID = "acm-pca" + AMPEndpointID = "aps" + APIGatewayID = "apigateway" + APIGatewayV2EndpointID = "apigateway" + AccessAnalyzerEndpointID = "access-analyzer" + AmplifyEndpointID = "amplify" + AppConfigEndpointID = "appconfig" + AppFabricEndpointID = "appfabric" + AppIntegrationsEndpointID = "app-integrations" + AppMeshEndpointID = "appmesh" + AppStreamEndpointID = "appstream2" + AppSyncEndpointID = "appsync" + ApplicationAutoscalingEndpointID = "application-autoscaling" + ApplicationInsightsEndpointID = "applicationinsights" + AthenaEndpointID = "athena" + AuditManagerEndpointID = "auditmanager" + AutoScalingPlansEndpointID = "autoscaling-plans" + BCMDataExportsEndpointID = "bcm-data-exports" + BackupEndpointID = "backup" + BatchEndpointID = "batch" + BedrockAgentEndpointID = "bedrockagent" + BedrockEndpointID = "bedrock" + BudgetsEndpointID = "budgets" + ChimeEndpointID = "chime" + ChimeSDKMediaPipelinesEndpointID = "media-pipelines-chime" + ChimeSDKVoiceEndpointID = "voice-chime" + Cloud9EndpointID = "cloud9" + CloudFormationEndpointID = "cloudformation" + CloudFrontEndpointID = "cloudfront" + CloudSearchEndpointID = "cloudsearch" + CloudWatchEndpointID = "monitoring" + CodeArtifactEndpointID = "codeartifact" + CodeGuruReviewerEndpointID = "codeguru-reviewer" + CodeStarConnectionsEndpointID = "codestar-connections" + CognitoIdentityEndpointID = "cognito-identity" + ComprehendEndpointID = "comprehend" + ConfigServiceEndpointID = "config" + DataExchangeEndpointID = "dataexchange" + DataPipelineEndpointID = "datapipeline" + DetectiveEndpointID = "api.detective" + DeviceFarmEndpointID = "devicefarm" + DevOpsGuruEndpointID = "devops-guru" + DirectConnectEndpointID = "directconnect" + DLMEndpointID = "dlm" + ECREndpointID = "api.ecr" + ECSEndpointID = "ecs" + EFSEndpointID = "elasticfilesystem" + EKSEndpointID = "eks" + ELBEndpointID = "elasticloadbalancing" + EMREndpointID = "elasticmapreduce" + ElasticTranscoderEndpointID = "elastictranscoder" + ElastiCacheEndpointID = "elasticache" + EventsEndpointID = "events" + EvidentlyEndpointID = "evidently" + FMSEndpointID = "fms" + FSxEndpointID = "fsx" + GrafanaEndpointID = "grafana" + GlueEndpointID = "glue" + IVSEndpointID = "ivs" + IVSChatEndpointID = "ivschat" + IdentityStoreEndpointID = "identitystore" + Inspector2EndpointID = "inspector2" + KMSEndpointID = "kms" + KafkaConnectEndpointID = "kafkaconnect" + KendraEndpointID = "kendra" + LambdaEndpointID = "lambda" + LexV2ModelsEndpointID = "models-v2-lex" + LocationEndpointID = "location" + M2EndpointID = "m2" + MQEndpointID = "mq" + MediaConvertEndpointID = "mediaconvert" + MediaLiveEndpointID = "medialive" + ObservabilityAccessManagerEndpointID = "oam" + OpenSearchIngestionEndpointID = "osis" + OpenSearchServerlessEndpointID = "aoss" + PaymentCryptographyEndpointID = "paymentcryptography" + PipesEndpointID = "pipes" + PollyEndpointID = "polly" + QLDBEndpointID = "qldb" + RUMEndpointID = "rum" + RedshiftEndpointID = "redshift" + RedshiftServerlessEndpointID = "redshift-serverless" + RekognitionEndpointID = "rekognition" + ResourceExplorer2EndpointID = "resource-explorer-2" + RolesAnywhereEndpointID = "rolesanywhere" + Route53DomainsEndpointID = "route53domains" + Route53RecoveryControlConfigEndpointID = "route53recoverycontrolconfig" + ServiceCatalogEndpointID = "servicecatalog" + SSMEndpointID = "ssm" + SSMIncidentsEndpointID = "ssm-incidents" + SSOAdminEndpointID = "sso" + STSEndpointID = "sts" + SchedulerEndpointID = "scheduler" + SchemasEndpointID = "schemas" + ServiceCatalogAppRegistryEndpointID = "servicecatalog-appregistry" + ServiceDiscoveryEndpointID = "servicediscovery" + ServiceQuotasEndpointID = "servicequotas" + SESEndpointID = "email" + ShieldEndpointID = "shield" + TranscribeEndpointID = "transcribe" + TransferEndpointID = "transfer" + VPCLatticeEndpointID = "vpc-lattice" + VerifiedPermissionsEndpointID = "verifiedpermissions" + WAFEndpointID = "waf" + WAFRegionalEndpointID = "waf-regional" + DataZoneEndpointID = "datazone" ) // These should move to aws-sdk-go-base. From c95420308029836159db77cfaa248a662d28ad97 Mon Sep 17 00:00:00 2001 From: Daniel Rieske Date: Thu, 8 Aug 2024 22:29:45 +0200 Subject: [PATCH 12/17] fix: endpoint id --- names/names.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/names/names.go b/names/names.go index fcd9f69315a..d5515e9b7b4 100644 --- a/names/names.go +++ b/names/names.go @@ -112,7 +112,7 @@ const ( ResourceExplorer2EndpointID = "resource-explorer-2" RolesAnywhereEndpointID = "rolesanywhere" Route53DomainsEndpointID = "route53domains" - Route53RecoveryControlConfigEndpointID = "route53recoverycontrolconfig" + Route53RecoveryControlConfigEndpointID = "route53-recovery-control-config" ServiceCatalogEndpointID = "servicecatalog" SSMEndpointID = "ssm" SSMIncidentsEndpointID = "ssm-incidents" From 3b5ef20e2652d1f960e5daaaa7e8ad99b82945b6 Mon Sep 17 00:00:00 2001 From: Daniel Rieske Date: Thu, 8 Aug 2024 22:54:30 +0200 Subject: [PATCH 13/17] feat: add service client --- .../service_package.go | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 internal/service/route53recoverycontrolconfig/service_package.go diff --git a/internal/service/route53recoverycontrolconfig/service_package.go b/internal/service/route53recoverycontrolconfig/service_package.go new file mode 100644 index 00000000000..b0cd55431e4 --- /dev/null +++ b/internal/service/route53recoverycontrolconfig/service_package.go @@ -0,0 +1,37 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package route53recoverycontrolconfig + +import ( + "context" + + "github.com/aws/aws-sdk-go-v2/aws" + r53rcc "github.com/aws/aws-sdk-go-v2/service/route53recoverycontrolconfig" + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-provider-aws/names" +) + +// 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) (*r53rcc.Client, error) { + cfg := *(config["aws_sdkv2_config"].(*aws.Config)) + + return r53rcc.NewFromConfig(cfg, + r53rcc.WithEndpointResolverV2(newEndpointResolverSDKv2()), + withBaseEndpoint(config[names.AttrEndpoint].(string)), + func(o *r53rcc.Options) { + // Always override the service region + switch config["partition"].(string) { + case names.StandardPartitionID: + // https://docs.aws.amazon.com/general/latest/gr/r53arc.html Setting default to us-west-2. + if cfg.Region != names.USWest2RegionID { + tflog.Info(ctx, "overriding region", map[string]any{ + "original_region": cfg.Region, + "override_region": names.USWest2RegionID, + }) + } + o.Region = names.USWest2RegionID + } + }, + ), nil +} From 11d5a02be678850b027605509ec6d9b47efc92d3 Mon Sep 17 00:00:00 2001 From: Daniel Rieske Date: Fri, 9 Aug 2024 09:09:51 +0200 Subject: [PATCH 14/17] chore: run `mod tidy` --- go.mod | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 3da4f18025f..7effec9a268 100644 --- a/go.mod +++ b/go.mod @@ -167,6 +167,7 @@ require ( github.com/aws/aws-sdk-go-v2/service/osis v1.12.3 github.com/aws/aws-sdk-go-v2/service/paymentcryptography v1.12.3 github.com/aws/aws-sdk-go-v2/service/pcaconnectorad v1.7.3 + github.com/aws/aws-sdk-go-v2/service/pinpoint v1.32.3 github.com/aws/aws-sdk-go-v2/service/pipes v1.14.3 github.com/aws/aws-sdk-go-v2/service/polly v1.42.3 github.com/aws/aws-sdk-go-v2/service/pricing v1.30.3 @@ -187,6 +188,7 @@ require ( github.com/aws/aws-sdk-go-v2/service/route53 v1.42.3 github.com/aws/aws-sdk-go-v2/service/route53domains v1.25.3 github.com/aws/aws-sdk-go-v2/service/route53profiles v1.2.3 + github.com/aws/aws-sdk-go-v2/service/route53recoverycontrolconfig v1.23.3 github.com/aws/aws-sdk-go-v2/service/rum v1.19.3 github.com/aws/aws-sdk-go-v2/service/s3 v1.58.3 github.com/aws/aws-sdk-go-v2/service/s3control v1.46.3 @@ -293,8 +295,6 @@ require ( github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.9.16 // indirect github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.17 // indirect github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.17.15 // indirect - github.com/aws/aws-sdk-go-v2/service/route53recoverycontrolconfig v1.23.3 // indirect - github.com/aws/aws-sdk-go-v2/service/pinpoint v1.32.3 // indirect github.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.4 // indirect github.com/bgentry/speakeasy v0.1.0 // indirect github.com/boombuler/barcode v1.0.1 // indirect From c8f331cb96c8494cfccdcab364ef234e3e5beda6 Mon Sep 17 00:00:00 2001 From: Daniel Rieske Date: Fri, 9 Aug 2024 10:38:41 +0200 Subject: [PATCH 15/17] chore: run `make clean tidy` --- tools/tfsdk2fw/go.mod | 4 ++++ tools/tfsdk2fw/go.sum | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/tools/tfsdk2fw/go.mod b/tools/tfsdk2fw/go.mod index 41660bf8099..9df6755312f 100644 --- a/tools/tfsdk2fw/go.mod +++ b/tools/tfsdk2fw/go.mod @@ -104,6 +104,7 @@ require ( github.com/aws/aws-sdk-go-v2/service/detective v1.29.3 // indirect github.com/aws/aws-sdk-go-v2/service/devicefarm v1.25.2 // indirect github.com/aws/aws-sdk-go-v2/service/devopsguru v1.32.3 // indirect + github.com/aws/aws-sdk-go-v2/service/directconnect v1.27.5 // indirect github.com/aws/aws-sdk-go-v2/service/directoryservice v1.27.3 // indirect github.com/aws/aws-sdk-go-v2/service/dlm v1.26.3 // indirect github.com/aws/aws-sdk-go-v2/service/docdb v1.36.3 // indirect @@ -188,6 +189,7 @@ require ( github.com/aws/aws-sdk-go-v2/service/osis v1.12.3 // indirect github.com/aws/aws-sdk-go-v2/service/paymentcryptography v1.12.3 // indirect github.com/aws/aws-sdk-go-v2/service/pcaconnectorad v1.7.3 // indirect + github.com/aws/aws-sdk-go-v2/service/pinpoint v1.32.3 // indirect github.com/aws/aws-sdk-go-v2/service/pipes v1.14.3 // indirect github.com/aws/aws-sdk-go-v2/service/polly v1.42.3 // indirect github.com/aws/aws-sdk-go-v2/service/pricing v1.30.3 // indirect @@ -208,6 +210,7 @@ require ( github.com/aws/aws-sdk-go-v2/service/route53 v1.42.3 // indirect github.com/aws/aws-sdk-go-v2/service/route53domains v1.25.3 // indirect github.com/aws/aws-sdk-go-v2/service/route53profiles v1.2.3 // indirect + github.com/aws/aws-sdk-go-v2/service/route53recoverycontrolconfig v1.23.3 // indirect github.com/aws/aws-sdk-go-v2/service/rum v1.19.3 // indirect github.com/aws/aws-sdk-go-v2/service/s3 v1.58.3 // indirect github.com/aws/aws-sdk-go-v2/service/s3control v1.46.3 // indirect @@ -217,6 +220,7 @@ require ( github.com/aws/aws-sdk-go-v2/service/securityhub v1.51.3 // indirect github.com/aws/aws-sdk-go-v2/service/securitylake v1.16.3 // indirect github.com/aws/aws-sdk-go-v2/service/serverlessapplicationrepository v1.22.3 // indirect + github.com/aws/aws-sdk-go-v2/service/servicecatalog v1.30.3 // indirect github.com/aws/aws-sdk-go-v2/service/servicecatalogappregistry v1.28.3 // indirect github.com/aws/aws-sdk-go-v2/service/servicediscovery v1.31.3 // indirect github.com/aws/aws-sdk-go-v2/service/servicequotas v1.23.3 // indirect diff --git a/tools/tfsdk2fw/go.sum b/tools/tfsdk2fw/go.sum index 2b82bdf9e79..5ead3773c74 100644 --- a/tools/tfsdk2fw/go.sum +++ b/tools/tfsdk2fw/go.sum @@ -194,6 +194,8 @@ github.com/aws/aws-sdk-go-v2/service/devicefarm v1.25.2 h1:DSv0r8nKo8+ix2h5Rz/Zl github.com/aws/aws-sdk-go-v2/service/devicefarm v1.25.2/go.mod h1:7Ev/BlW5/zbURomHu/2Ay8l/HAgoQAbaSP2XlMUED9I= github.com/aws/aws-sdk-go-v2/service/devopsguru v1.32.3 h1:dVk+ogfz83rhZLaWSwSbgTQnxno+DIhZ3Q3KFdxTVmA= github.com/aws/aws-sdk-go-v2/service/devopsguru v1.32.3/go.mod h1:Rbgi0LKyAIyWHlqVtgU5wy39omdfHHvlGjrl+Vg41us= +github.com/aws/aws-sdk-go-v2/service/directconnect v1.27.5 h1:waoTf1hh2njzovjQm35YI/NgzBJ6MFh38V1D06m3ZSw= +github.com/aws/aws-sdk-go-v2/service/directconnect v1.27.5/go.mod h1:pPYhajQqE5gRnRVzTE6ptT0BCl603tkBc8YgLxsHMSo= github.com/aws/aws-sdk-go-v2/service/directoryservice v1.27.3 h1:Ua8NLsRNDm/HSotawG9MjeUEdo88uuTsEJ+EQB99G7c= github.com/aws/aws-sdk-go-v2/service/directoryservice v1.27.3/go.mod h1:DeGGGnrVVVNQlfMpAqmIiEndGTlDVbUIzNI4MbyyH68= github.com/aws/aws-sdk-go-v2/service/dlm v1.26.3 h1:LAZoBLsYn4eSTzJlfIu+v/+EHzqLqkPlIIc+y36HgEA= @@ -362,6 +364,8 @@ github.com/aws/aws-sdk-go-v2/service/paymentcryptography v1.12.3 h1:9oQMCF4oLvWS github.com/aws/aws-sdk-go-v2/service/paymentcryptography v1.12.3/go.mod h1:NNyvgUO7XweCVxGTSnllS6XdsD/9Il6Kc63D/stKgiM= github.com/aws/aws-sdk-go-v2/service/pcaconnectorad v1.7.3 h1:xKVSPlN0K1r9VBe6MaKHgUi3EvJotLE9s4etstJq0jw= github.com/aws/aws-sdk-go-v2/service/pcaconnectorad v1.7.3/go.mod h1:4Lk91jzPQQKOzml7LHOR/zAE5FF4+mL0CPrArI8vnCY= +github.com/aws/aws-sdk-go-v2/service/pinpoint v1.32.3 h1:uBukpBpEOhnT/iWfhiunEjbPTWXgurgLUr5NJlk7yJk= +github.com/aws/aws-sdk-go-v2/service/pinpoint v1.32.3/go.mod h1:yv43WVYryFKJFbThuv8mHV3zGt4RfnzB/+Om7iwRyxs= github.com/aws/aws-sdk-go-v2/service/pipes v1.14.3 h1:fYZlFa1OvrgaFODrdf0KVDp4qCRHMZNr8S/F3aGNuno= github.com/aws/aws-sdk-go-v2/service/pipes v1.14.3/go.mod h1:S0g2KF8IpU6Ptn46eSywrS+w1PMUwrf/xWF8szcTZ2Q= github.com/aws/aws-sdk-go-v2/service/polly v1.42.3 h1:MuoVKFJr/TUimLdT6nvio+OehAPM7kILgNLF3rYcaP0= @@ -402,6 +406,8 @@ github.com/aws/aws-sdk-go-v2/service/route53domains v1.25.3 h1:VGLIgiClxmwxBpGzH github.com/aws/aws-sdk-go-v2/service/route53domains v1.25.3/go.mod h1:Kgq5O7ZaDk0mTZmX6YCL+ZtZ1YcJHtGsVubp0OT77MA= github.com/aws/aws-sdk-go-v2/service/route53profiles v1.2.3 h1:N4f5sliNiWcp3abC+8YpcaVjXuaNJIlz/dBd+saimm0= github.com/aws/aws-sdk-go-v2/service/route53profiles v1.2.3/go.mod h1:r2B4BvTn3zSMK+BFHGl0q63B/nJMOk9/NukLZzqO8sY= +github.com/aws/aws-sdk-go-v2/service/route53recoverycontrolconfig v1.23.3 h1:apYav6exfbLJ+kRGPa27GTrUuCS4ctI0mJEeiDxSeDE= +github.com/aws/aws-sdk-go-v2/service/route53recoverycontrolconfig v1.23.3/go.mod h1:citOcziml/EM6I2ycb7XHuBw0whC8jVD2y+vU7wQD4k= github.com/aws/aws-sdk-go-v2/service/rum v1.19.3 h1:DR+GYJRPL7eEZknnGdwm+lH686LmUBB/X2YVQDHLNY4= github.com/aws/aws-sdk-go-v2/service/rum v1.19.3/go.mod h1:5jFxbuc05P/+BbJvVbBspMbzDR2IFU0LegQG3iUvj8g= github.com/aws/aws-sdk-go-v2/service/s3 v1.58.3 h1:hT8ZAZRIfqBqHbzKTII+CIiY8G2oC9OpLedkZ51DWl8= @@ -420,6 +426,8 @@ github.com/aws/aws-sdk-go-v2/service/securitylake v1.16.3 h1:7isk2tSNmVbm2f8epPf github.com/aws/aws-sdk-go-v2/service/securitylake v1.16.3/go.mod h1:X5rHkguK4jCvFOM74tkme3oLUOaR++APKgwhNcIdOW0= github.com/aws/aws-sdk-go-v2/service/serverlessapplicationrepository v1.22.3 h1:E4NzUkgPrKmlbC9OxVUEQnTdPRg3MTTiDwmq5dJfH9U= github.com/aws/aws-sdk-go-v2/service/serverlessapplicationrepository v1.22.3/go.mod h1:/nzQOH+tOGrQVv5QbVN+88HoNYc15s8aKsJmOT9MPJI= +github.com/aws/aws-sdk-go-v2/service/servicecatalog v1.30.3 h1:JwZUGB3DE7Wr+Cp4ak7dkgneOJ0FIjXAle1XqkZmQ1Y= +github.com/aws/aws-sdk-go-v2/service/servicecatalog v1.30.3/go.mod h1:Wfm5srkIuPtidLcAWql6ibqifGEIg28EWK6A14Fei6A= github.com/aws/aws-sdk-go-v2/service/servicecatalogappregistry v1.28.3 h1:l19QC3al5lqQydnJRz1cpduAoL0YoEeSxI5Wb5NUEis= github.com/aws/aws-sdk-go-v2/service/servicecatalogappregistry v1.28.3/go.mod h1:0Em81iN4ZnER1M0XDirgcbsZK3jNghA0YlY2Xw2BDOQ= github.com/aws/aws-sdk-go-v2/service/servicediscovery v1.31.3 h1:EthA93BNgTnk36FoI9DCKtv4S0m63WzdGDYlBp/CvHQ= From 081cc69be89ae3cb3527bae70743d9c4dd2dc92f Mon Sep 17 00:00:00 2001 From: Daniel Rieske Date: Sat, 10 Aug 2024 14:42:06 +0200 Subject: [PATCH 16/17] chore: run `make clean-tidy` --- go.mod | 2 +- tools/tfsdk2fw/go.mod | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index d0a71872ddb..9007489ab9a 100644 --- a/go.mod +++ b/go.mod @@ -189,8 +189,8 @@ require ( github.com/aws/aws-sdk-go-v2/service/route53 v1.42.3 github.com/aws/aws-sdk-go-v2/service/route53domains v1.25.3 github.com/aws/aws-sdk-go-v2/service/route53profiles v1.2.3 - github.com/aws/aws-sdk-go-v2/service/route53recoveryreadiness v1.19.3 github.com/aws/aws-sdk-go-v2/service/route53recoverycontrolconfig v1.23.3 + github.com/aws/aws-sdk-go-v2/service/route53recoveryreadiness v1.19.3 github.com/aws/aws-sdk-go-v2/service/rum v1.19.3 github.com/aws/aws-sdk-go-v2/service/s3 v1.58.3 github.com/aws/aws-sdk-go-v2/service/s3control v1.46.3 diff --git a/tools/tfsdk2fw/go.mod b/tools/tfsdk2fw/go.mod index f5115341ce3..043fbd99d10 100644 --- a/tools/tfsdk2fw/go.mod +++ b/tools/tfsdk2fw/go.mod @@ -211,8 +211,8 @@ require ( github.com/aws/aws-sdk-go-v2/service/route53 v1.42.3 // indirect github.com/aws/aws-sdk-go-v2/service/route53domains v1.25.3 // indirect github.com/aws/aws-sdk-go-v2/service/route53profiles v1.2.3 // indirect - github.com/aws/aws-sdk-go-v2/service/route53recoveryreadiness v1.19.3 // indirect github.com/aws/aws-sdk-go-v2/service/route53recoverycontrolconfig v1.23.3 // indirect + github.com/aws/aws-sdk-go-v2/service/route53recoveryreadiness v1.19.3 // indirect github.com/aws/aws-sdk-go-v2/service/rum v1.19.3 // indirect github.com/aws/aws-sdk-go-v2/service/s3 v1.58.3 // indirect github.com/aws/aws-sdk-go-v2/service/s3control v1.46.3 // indirect From 1213da590b2e36c703ebb7c614165dbb0f89fda4 Mon Sep 17 00:00:00 2001 From: Daniel Rieske Date: Sat, 10 Aug 2024 15:47:45 +0200 Subject: [PATCH 17/17] chore: ran `make gen` --- internal/conns/awsclient_gen.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/conns/awsclient_gen.go b/internal/conns/awsclient_gen.go index f3bdd1a66c4..f4f03d181ca 100644 --- a/internal/conns/awsclient_gen.go +++ b/internal/conns/awsclient_gen.go @@ -181,8 +181,8 @@ import ( route53_sdkv2 "github.com/aws/aws-sdk-go-v2/service/route53" route53domains_sdkv2 "github.com/aws/aws-sdk-go-v2/service/route53domains" route53profiles_sdkv2 "github.com/aws/aws-sdk-go-v2/service/route53profiles" - route53recoveryreadiness_sdkv2 "github.com/aws/aws-sdk-go-v2/service/route53recoveryreadiness" route53recoverycontrolconfig_sdkv2 "github.com/aws/aws-sdk-go-v2/service/route53recoverycontrolconfig" + route53recoveryreadiness_sdkv2 "github.com/aws/aws-sdk-go-v2/service/route53recoveryreadiness" rum_sdkv2 "github.com/aws/aws-sdk-go-v2/service/rum" s3_sdkv2 "github.com/aws/aws-sdk-go-v2/service/s3" s3control_sdkv2 "github.com/aws/aws-sdk-go-v2/service/s3control"