From 2bd7727008f120324d1f3b58ffbc4020fead4ed8 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Sat, 8 Jun 2024 16:11:18 -0400 Subject: [PATCH 1/5] r/aws_route53_zone: Use 'zone_id' as transparent tagging identifier. --- internal/service/route53/service_package_gen.go | 2 +- internal/service/route53/zone.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/service/route53/service_package_gen.go b/internal/service/route53/service_package_gen.go index e14f694d2e2..89baf108686 100644 --- a/internal/service/route53/service_package_gen.go +++ b/internal/service/route53/service_package_gen.go @@ -103,7 +103,7 @@ func (p *servicePackage) SDKResources(ctx context.Context) []*types.ServicePacka TypeName: "aws_route53_zone", Name: "Hosted Zone", Tags: &types.ServicePackageResourceTags{ - IdentifierAttribute: names.AttrID, + IdentifierAttribute: "zone_id", ResourceType: "hostedzone", }, }, diff --git a/internal/service/route53/zone.go b/internal/service/route53/zone.go index 10dc7c543b6..d573bb6b014 100644 --- a/internal/service/route53/zone.go +++ b/internal/service/route53/zone.go @@ -33,7 +33,7 @@ import ( ) // @SDKResource("aws_route53_zone", name="Hosted Zone") -// @Tags(identifierAttribute="id", resourceType="hostedzone") +// @Tags(identifierAttribute="zone_id", resourceType="hostedzone") func resourceZone() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceZoneCreate, From 850cbf2caeb2ca5c674cc9de5e7fca388debf0cf Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Sat, 8 Jun 2024 16:27:45 -0400 Subject: [PATCH 2/5] Add CHANGELOG entry. --- .changelog/#####.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/#####.txt diff --git a/.changelog/#####.txt b/.changelog/#####.txt new file mode 100644 index 00000000000..9a3aefaa769 --- /dev/null +++ b/.changelog/#####.txt @@ -0,0 +1,3 @@ +```release-note:bug +resource/aws_route53_zone: Fix `InvalidInput: 1 validation error detected: Value '...' at 'resourceId' failed to satisfy constraint: Member must have length less than or equal to 32` errors for resources imported with a `/hostedzone/` prefix +``` \ No newline at end of file From 31b6f2c57647fb75b63c4e25958fc9b27b55b850 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Sat, 8 Jun 2024 16:43:50 -0400 Subject: [PATCH 3/5] Correct CHANGELOG entry file name. --- .changelog/{#####.txt => 37893.txt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .changelog/{#####.txt => 37893.txt} (100%) diff --git a/.changelog/#####.txt b/.changelog/37893.txt similarity index 100% rename from .changelog/#####.txt rename to .changelog/37893.txt From 067a53f1acd645451a871c011aadb51395eb2be7 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 10 Jun 2024 06:07:30 -0700 Subject: [PATCH 4/5] Test import with '/hostedzone/' prefix. --- internal/service/route53/zone.go | 5 +++-- internal/service/route53/zone_test.go | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/internal/service/route53/zone.go b/internal/service/route53/zone.go index d573bb6b014..15edc9f2afb 100644 --- a/internal/service/route53/zone.go +++ b/internal/service/route53/zone.go @@ -191,10 +191,11 @@ func resourceZoneRead(ctx context.Context, d *schema.ResourceData, meta interfac return sdkdiag.AppendErrorf(diags, "reading Route53 Hosted Zone (%s): %s", d.Id(), err) } + zoneID := cleanZoneID(aws.ToString(output.HostedZone.Id)) arn := arn.ARN{ Partition: meta.(*conns.AWSClient).Partition, Service: "route53", - Resource: fmt.Sprintf("hostedzone/%s", d.Id()), + Resource: "hostedzone/" + zoneID, }.String() d.Set(names.AttrARN, arn) d.Set(names.AttrComment, "") @@ -202,7 +203,7 @@ func resourceZoneRead(ctx context.Context, d *schema.ResourceData, meta interfac // To be consistent with other AWS services (e.g. ACM) that do not accept a trailing period, // we remove the suffix from the Hosted Zone Name returned from the API. d.Set(names.AttrName, normalizeZoneName(aws.ToString(output.HostedZone.Name))) - d.Set("zone_id", cleanZoneID(aws.ToString(output.HostedZone.Id))) + d.Set("zone_id", zoneID) var nameServers []string diff --git a/internal/service/route53/zone_test.go b/internal/service/route53/zone_test.go index f0f8e9691b5..00cdf55ae6a 100644 --- a/internal/service/route53/zone_test.go +++ b/internal/service/route53/zone_test.go @@ -52,6 +52,20 @@ func TestAccRoute53Zone_basic(t *testing.T) { ImportStateVerify: true, ImportStateVerifyIgnore: []string{names.AttrForceDestroy}, }, + // Test import using an ID with "/hosrtezone/" prefix. + // https://github.com/hashicorp/terraform-provider-aws/issues/37817. + { + ResourceName: resourceName, + ImportState: true, + ImportStateIdFunc: func(v *route53.GetHostedZoneOutput) resource.ImportStateIdFunc { + return func(s *terraform.State) (string, error) { + return aws.ToString(v.HostedZone.Id), nil + } + }(&zone), + ImportStateVerify: true, + ImportStateVerifyIdentifierAttribute: "zone_id", + ImportStateVerifyIgnore: []string{names.AttrForceDestroy, names.AttrID}, + }, }, }) } From 20220a74bdbbc5dbf6a9118a2e5fb9461700be8d Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 10 Jun 2024 06:17:14 -0700 Subject: [PATCH 5/5] Acceptance test output: % make testacc TESTARGS='-run=TestAccRoute53Zone_basic' PKG=route53 make: Verifying source code with gofmt... ==> Checking that code complies with gofmt requirements... TF_ACC=1 go1.22.2 test ./internal/service/route53/... -v -count 1 -parallel 20 -run=TestAccRoute53Zone_basic -timeout 360m === RUN TestAccRoute53Zone_basic === PAUSE TestAccRoute53Zone_basic === CONT TestAccRoute53Zone_basic --- PASS: TestAccRoute53Zone_basic (107.35s) PASS ok github.com/hashicorp/terraform-provider-aws/internal/service/route53 111.787s