Why do the CDK APIGWV2/Route53 docs say generate an A record rather than CNAME?

0

Why in the example from @aws-cdk-aws-route53-targets does the apigwv2 sample generate an A record rather than a CNAME record?

/* Example from @aws-cdk-aws-route53-targets, doesn't work - makes CDK hang */
import * as apigwv2 from '@aws-cdk/aws-apigatewayv2';

declare const zone: route53.HostedZone;
declare const domainName: apigwv2.DomainName;

new route53.ARecord(this, 'AliasRecord', {
    zone,
    target: route53.RecordTarget.fromAlias(
        new targets.ApiGatewayv2DomainProperties(domainName.regionalDomainName, domainName.regionalHostedZoneId)
    )
});

What I have always done (manually) is create a CNAME record to the API Gateway domain name listed under API Gateway / Custom Domain names in the console. I am not following this example or why you would want it to be an ARecord.

I changed the above code to this for my own and it seems to work:

/* my version, which works */
return new CnameRecord(this, `autofrog-phone-api-cname`, {
    recordName: 'phone',
    zone: this.zone,
    domainName: this.apiGatewayDomainName.regionalDomainName, /* instance of @aws-cdk/aws-apigatewayv2-alpha:IDomain */
    deleteExisting: false,
    comment: "added by cdk"
});
1개 답변
0
수락된 답변

I didn't know what an Alias record was until a few minutes ago.

Now I understand what they were doing.

profile picture
wz2b
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠