From 8c0320ff97f25c52b06a2b9f0c00600410b2f468 Mon Sep 17 00:00:00 2001 From: Shiv Lakshminarayan Date: Wed, 22 Apr 2020 21:09:47 -0700 Subject: [PATCH 1/2] fix(route53) cannot add tags to `HostedZone` 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 --- .../aws-route53/test/test.hosted-zone.ts | 32 +++++++++++++++++++ .../@aws-cdk/cfnspec/lib/schema/property.ts | 6 ++-- .../cfnspec/lib/schema/resource-type.ts | 1 + 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/packages/@aws-cdk/aws-route53/test/test.hosted-zone.ts b/packages/@aws-cdk/aws-route53/test/test.hosted-zone.ts index f9491ca00c30a..45eaed8e8cafb 100644 --- a/packages/@aws-cdk/aws-route53/test/test.hosted-zone.ts +++ b/packages/@aws-cdk/aws-route53/test/test.hosted-zone.ts @@ -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'; @@ -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(); + }, }; diff --git a/packages/@aws-cdk/cfnspec/lib/schema/property.ts b/packages/@aws-cdk/cfnspec/lib/schema/property.ts index 21de42c059640..a5d8bc602347f 100644 --- a/packages/@aws-cdk/cfnspec/lib/schema/property.ts +++ b/packages/@aws-cdk/cfnspec/lib/schema/property.ts @@ -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'; } @@ -224,6 +224,7 @@ export function isPropertyScrutinyType(str: string): str is PropertyScrutinyType const tagPropertyNames = { FileSystemTags: '', + HostedZoneTags: '', Tags: '', UserPoolTags: '', }; @@ -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' ); } diff --git a/packages/@aws-cdk/cfnspec/lib/schema/resource-type.ts b/packages/@aws-cdk/cfnspec/lib/schema/resource-type.ts index 6150c9bdd3dce..200465a98f064 100644 --- a/packages/@aws-cdk/cfnspec/lib/schema/resource-type.ts +++ b/packages/@aws-cdk/cfnspec/lib/schema/resource-type.ts @@ -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; From 2b58a7d01efe7d501e30e72633088bdd4d56d3a8 Mon Sep 17 00:00:00 2001 From: Shiv Lakshminarayan Date: Wed, 22 Apr 2020 22:18:18 -0700 Subject: [PATCH 2/2] fix casing --- packages/@aws-cdk/cfnspec/lib/schema/resource-type.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@aws-cdk/cfnspec/lib/schema/resource-type.ts b/packages/@aws-cdk/cfnspec/lib/schema/resource-type.ts index 200465a98f064..aeccfaa04d86f 100644 --- a/packages/@aws-cdk/cfnspec/lib/schema/resource-type.ts +++ b/packages/@aws-cdk/cfnspec/lib/schema/resource-type.ts @@ -31,7 +31,7 @@ export interface ResourceType extends Documented { export interface TaggableResource extends ResourceType { Properties: { FileSystemTags: TagProperty; - HostedzoneTags: TagProperty; + HostedZoneTags: TagProperty; Tags: TagProperty; UserPoolTags: TagProperty; [name: string]: Property;