Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r/aws_route53_zone: Use zone_id for transparent tagging identifier #37893

Merged
merged 5 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/37893.txt
Original file line number Diff line number Diff line change
@@ -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
```
2 changes: 1 addition & 1 deletion internal/service/route53/service_package_gen.go

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

7 changes: 4 additions & 3 deletions internal/service/route53/zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -191,18 +191,19 @@ 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, "")
d.Set("delegation_set_id", "")
// 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

Expand Down
14 changes: 14 additions & 0 deletions internal/service/route53/zone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
},
},
})
}
Expand Down
Loading