aws / aws/aws-cdk

(@aws-cdk/aws-route53): ARecord with ApiGatewayv2DomainProperties to subdomain not working

Open
#17,244 4 comments 8 reactions 0 assignees View on GitHub
@aws-cdk/aws-route53 bug effort/small p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### What is the problem?

Hello,

when trying to create an ARecord with an HTTP API alias on a subdomain, the record is created with the general domain instead.

### Reproduction Steps

```
const apiSubDomain = `api.${this.domain}`;

const hostedZone = HostedZone.fromLookup(this, "HostedZone", {
domainName: this.domain,
});

const certificate = new Certificate(this, "Certificate", {
domainName: this.domain,
subjectAlternativeNames: [apiSubDomain],
validation: CertificateValidation.fromDns(hostedZone),
});

const domainName = new DomainName(this, "DomainName", {
// > Note that this is using the subdomain
domainName: apiSubDomain,
certificate: certificate,
});

const httpApi = new HttpApi(this, "HttpApi", {
disableExecuteApiEndpoint: false,
defaultDomainMapping: {
// > Note that this is using the subdomain
domainName,
},
});

new ARecord(this, "HttpApiAliasRecord", {
zone: hostedZone,
target: RecordTarget.fromAlias(
new ApiGatewayv2DomainProperties(
domainName.regionalDomainName,
domainName.regionalHostedZoneId
)
),
});
```

### What did you expect to happen?

I expected an A Record like this in Route53:
`api.example.com | A | Simple | - | alias.....`

### What actually happened?

An A Record to the general domain was created:
`example.com | A | Simple | - | alias.....`

### CDK CLI Version

1.130.0 (build 9c094ae)

### Framework Version

_No response_

### Node.js Version

v14.18.0

### OS

Windows

### Language

Typescript

### Language Version

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the example with the Route53 ARecord, ApiGatewayv2DomainProperties, DomainName, and HttpApi constructs, checking the generated record name against the requested api.example.com subdomain. Trace how the alias target is converted into the record and add coverage for a subdomain case; done means the generated A record uses the subdomain rather than the hosted zone's general domain.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
api, cloud, infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.