Skip to content

Commit

Permalink
fix(route53): cannot add tags to HostedZone (#7531)
Browse files Browse the repository at this point in the history
We don't classify `HostedZoneTags` as the tagging property
since it follows a naming convention where it's not called `Tags`.

`HostedZoneTags` are also an array of type `HostedZoneTag` objects that
enforce the `{Key: "...", Value: "..."}` convention.

This is similar to `FileSystemTags` property for `EFS`

Closes #7445
  • Loading branch information
shivlaks committed Apr 23, 2020
1 parent cbe735e commit 2729804
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
32 changes: 32 additions & 0 deletions packages/@aws-cdk/aws-route53/test/test.hosted-zone.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { expect } from '@aws-cdk/assert';
import * as cdk from '@aws-cdk/core';
import { Test } from 'nodeunit';
import { HostedZone } from '../lib';
Expand Down Expand Up @@ -29,4 +30,35 @@ export = {
test.done();
},
},

'Supports tags'(test: Test) {
// GIVEN
const stack = new cdk.Stack();

// WHEN
const hostedZone = new HostedZone(stack, 'HostedZone', {
zoneName: 'test.zone',
});
cdk.Tag.add(hostedZone, 'zoneTag', 'inMyZone');

// THEN
expect(stack).toMatch({
Resources: {
HostedZoneDB99F866: {
Type: 'AWS::Route53::HostedZone',
Properties: {
Name: 'test.zone.',
HostedZoneTags: [
{
Key: 'zoneTag',
Value: 'inMyZone',
},
],
},
},
},
});

test.done();
},
};
6 changes: 4 additions & 2 deletions packages/@aws-cdk/cfnspec/lib/schema/property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export interface ComplexMapProperty extends MapPropertyBase {
}

export interface TagPropertyStandard extends PropertyBase {
ItemType: 'Tag' | 'TagsEntry' | 'TagRef' | 'ElasticFileSystemTag';
ItemType: 'Tag' | 'TagsEntry' | 'TagRef' | 'ElasticFileSystemTag' | 'HostedZoneTag';
Type: 'Tags';
}

Expand Down Expand Up @@ -224,6 +224,7 @@ export function isPropertyScrutinyType(str: string): str is PropertyScrutinyType

const tagPropertyNames = {
FileSystemTags: '',
HostedZoneTags: '',
Tags: '',
UserPoolTags: '',
};
Expand Down Expand Up @@ -257,7 +258,8 @@ export function isTagPropertyStandard(prop: Property): prop is TagPropertyStanda
(prop as TagPropertyStandard).ItemType === 'TagsEntry' ||
(prop as TagPropertyStandard).Type === 'Tags' ||
(prop as TagPropertyStandard).ItemType === 'TagRef' ||
(prop as TagPropertyStandard).ItemType === 'ElasticFileSystemTag'
(prop as TagPropertyStandard).ItemType === 'ElasticFileSystemTag' ||
(prop as TagPropertyStandard).ItemType === 'HostedZoneTag'
);

}
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/cfnspec/lib/schema/resource-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export interface ResourceType extends Documented {
export interface TaggableResource extends ResourceType {
Properties: {
FileSystemTags: TagProperty;
HostedZoneTags: TagProperty;
Tags: TagProperty;
UserPoolTags: TagProperty;
[name: string]: Property;
Expand Down

0 comments on commit 2729804

Please sign in to comment.