Skip to content

CloudFormation: Ref on AWS::Route53::HostedZone answers /hostedzone/Z…, so a RecordSet naming its zone by Ref is refused — and a RecordSetGroup hides it #1256

Closed

Description

@scttfrdmn

What is wrong

deployRoute53HostedZone (emulator/cfn_deployer.go:3851-3856) records the hosted zone's physical ID
as the raw Id member of the CreateHostedZone response:

dr.ARN = extractXMLField(resp.Body, "Id")
dr.PhysicalID = dr.ARN

Route 53's CreateHostedZone answers that member in the path form — /hostedzone/Z23ABC4XYZL05B —
and AWS::Route53::HostedZone is not in cfnRefValue's ARN arm, so Ref resolves to that prefixed
string. AWS publishes the opposite:

When you pass the logical ID of this resource to the intrinsic Ref function, Ref returns the
hosted zone ID, such as Z23ABC4XYZL05B.

So a record set that names its zone the way AWS's own examples do —
"HostedZoneId": {"Ref": "MyZone"} — builds

POST /2013-04-01/hostedzone//hostedzone/Z6FF97E5B413C/rrset

and is refused with InvalidAction: The action ... is not valid for this endpoint. The /hostedzone/
segment appears twice: once from deployRoute53RecordSet's own path and once from the Ref.

Two further consequences of the same two lines:

  • dr.ARN is not an ARN. It is set to the same /hostedzone/Z… string. A hosted zone's ARN is
    arn:aws:route53:::hostedzone/Z23ABC4XYZL05B, so DescribeStackResources reports a resource whose
    ARN is a path.
  • Fn::GetAtt Id is published by the same page ("The ID that Amazon Route 53 assigned to the
    hosted zone when you created it") and resolves from the same physical ID, so it carries the prefix
    too.

And the failure is invisible

deployRoute53RecordSetGroup (emulator/cfn_deployer.go:3903-3916) calls
deployRoute53RecordSet per element and keeps only the Go error:

_, cost, err := d.deployRoute53RecordSet(ctx, childID, rsProps, streamID, cctx)
if err != nil { return DeployedResource{}, totalCost, ... }

deployRoute53RecordSet never returns a Go error — a refusal goes into the child's
DeployedResource.Error, which is discarded here. So a RecordSetGroup whose every record set was
refused reports a clean resource with a physical ID, which is #1192's class ("a failure no caller can
see") reached through a different route.

How it was found

A sweep for #1123: every test that calls StackDeployer.Deploy was run alone against an instrumented
cfnFailedResources, and TestCFN_Route53RecordSetGroup (emulator/v016_extra_test.go:592) turned
out to deploy a record set that fails. The test asserts only require.NoError(t, err) and
assert.Len(t, result.Resources, 3), neither of which a failed resource disturbs — which is why the
divergence has been green.

Acceptance criteria

  • Ref on AWS::Route53::HostedZone answers the bare hosted zone ID, as the page publishes it.
  • Fn::GetAtt Id answers the same bare ID.
  • The deployed resource's ARN is arn:aws:route53:::hostedzone/<id>, or is left empty if the
    creating operation yields no ARN — not a path masquerading as one.
  • A RecordSet naming its zone by {"Ref": "MyZone"} deploys cleanly, asserted per resource with
    an empty DeployedResource.Error.
  • deployRoute53RecordSetGroup reports a child record set's refusal on the group's own
    DeployedResource.Error rather than discarding it, and a test asserts it.
  • Whether the Route 53 plugin itself should accept the prefixed form on ChangeResourceRecordSets
    (real Route 53 accepts both Z… and /hostedzone/Z… as a zone ID in the SDK) is decided either
    way and recorded — that is a separate question from what Ref answers.

Provenance

Ref's return value and the Id/NameServers attributes verified 2026-09-20 against
https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-route53-hostedzone.html
The /hostedzone/Z… form of the Id member comes from
https://docs.aws.amazon.com/Route53/latest/APIReference/API_CreateHostedZone.html — substrate's value
is the API's, and the defect is that it is published as the CloudFormation Ref unchanged.

Activity

  1. added
    area: cloudformation
    on Sep 20, 2026
  2. added this to the v0.124.0 milestone on Sep 20, 2026
  3. scttfrdmn commented on Sep 20, 2026

    @scttfrdmn
    OwnerAuthor

    #1123 (PR #1257) does not change any of this, but it stops the divergence being invisible:
    TestCFN_Route53RecordSetGroup (emulator/v016_extra_test.go) now asserts today's behaviour
    per resource rather than only require.NoError and assert.Len(…, 3) —

    • MyZone.PhysicalID matches ^/hostedzone/Z[0-9A-Z]+$ and MyZone.ARN equals it,
    • MyRecordSet.Error contains InvalidAction and the doubled /hostedzone//hostedzone/ segment,
      so the assertion pins the cause and not merely a refusal,
    • MyRecordSetGroup.Error is empty although its child was refused identically, which is the
      discarded-refusal half,
    • the stack's status is ROLLBACK_FAILED.

    Each assertion carries the value this issue is expected to change, and the test has a
    TODO(#1256). So fixing this turns that test red with a message naming what moved, rather than
    leaving it green in either state.

  4. added a commit that references this issue on Sep 20, 2026
  5. added a commit that references this issue on Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: cloudformationarea: route53

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions