CDK: How to set the TTL of the NS record for a Route53 PublicHostedZone?

1

Problem

I created a Route 53 zone with the following code:

this.apiV2Zone = new PublicHostedZone(this, "ApiV2", {
  zoneName: "api-v2.example.com"
});

The zone was created as expected, but I noticed the TTL attribute for the NS record was set to 172800 (2 days). This is a bit high at the moment, because I'm just experimenting - setting the TTL lower won't cost me much for now.

But, how do I go about seting the TTL of the NS record with the CDK?


What I've tried

I tried to force the NS record myself with:

let target = RecordTarget.fromValues(
  ...this.apiV2Zone.hostedZoneNameServers ?? [] );
const recordSet = new RecordSet(this, 'ApiV2Ns', {
  recordType: RecordType.NS,
  target,
  zone: this.apiV2Zone,
  deleteExisting: true,
  recordName: this.apiV2Zone.zoneName,
  ttl: cdk.Duration.minutes(10),
});

But that failed on deploy with:

 Received response status [FAILED] from custom resource. Message returned: InvalidChangeBatch
: [A HostedZone must contain at least one NS record for the zone itself.]

Also tried with deleteExisting: false but that failed too because it was duplicating the existing NS record.


Workaround

Set it manually in the AWS console. Doesn't seem to cause any change to be reported when I do a CDK diff.


https://stackoverflow.com/questions/75217593/cdk-how-to-set-the-ttl-of-the-ns-record-for-a-route53-publichostedzone

답변 없음

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

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

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

관련 콘텐츠