Skip to content

Commit

Permalink
fix(route53): cannot set TTL to 0 (aws#14060)
Browse files Browse the repository at this point in the history
Closes aws#14039


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
jogold authored Apr 9, 2021
1 parent ad326da commit ecc9bf3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-route53/lib/record-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ export class RecordSet extends Resource implements IRecordSet {
constructor(scope: Construct, id: string, props: RecordSetProps) {
super(scope, id);

const ttl = props.target.aliasTarget ? undefined : ((props.ttl && props.ttl.toSeconds()) || 1800).toString();
const ttl = props.target.aliasTarget ? undefined : ((props.ttl && props.ttl.toSeconds()) ?? 1800).toString();

const recordSet = new CfnRecordSet(this, 'Resource', {
hostedZoneId: props.zone.hostedZoneId,
Expand Down
24 changes: 24 additions & 0 deletions packages/@aws-cdk/aws-route53/test/record-set.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,30 @@ nodeunitShim({
test.done();
},

'with ttl of 0'(test: Test) {
// GIVEN
const stack = new Stack();

const zone = new route53.HostedZone(stack, 'HostedZone', {
zoneName: 'myzone',
});

// WHEN
new route53.RecordSet(stack, 'Basic', {
zone,
recordName: 'aa',
recordType: route53.RecordType.CNAME,
target: route53.RecordTarget.fromValues('bbb'),
ttl: Duration.seconds(0),
});

// THEN
expect(stack).to(haveResource('AWS::Route53::RecordSet', {
TTL: '0',
}));
test.done();
},

'defaults to zone root'(test: Test) {
// GIVEN
const stack = new Stack();
Expand Down

0 comments on commit ecc9bf3

Please sign in to comment.