Skip to content

Commit 7a4c189

Browse files
authored
fix(core): a number of resources are not taggable with Tags.of() (#28989)
### Issue # (if applicable) Closes #28862 ### Reason for this change CFN resources that has array format `tags` cannot use `Tags.of()` to add tags. ### Description of changes Enable modern style tags `ITaggableV2` ### Description of how you validated changes The generated looks correct and shouldn't cause breaking changes. *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent aa186ac commit 7a4c189

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

tools/@aws-cdk/spec2cdk/lib/cdk/resource-decider.ts

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ import { TypeConverter } from './type-converter';
77
import { attributePropertyName, cloudFormationDocLink, propertyNameFromCloudFormation } from '../naming';
88
import { splitDocumentation } from '../util';
99

10-
// Depends on https://github.com/aws/aws-cdk/pull/25610
11-
export const HAS_25610 = false;
12-
1310
// This convenience typewriter builder is used all over the place
1411
const $this = $E(expr.this_());
1512

@@ -21,7 +18,7 @@ export class ResourceDecider {
2118
const taggability = resourceTaggabilityStyle(resource);
2219
return taggability?.style === 'legacy'
2320
? [CDK_CORE.ITaggable]
24-
: taggability?.style === 'modern' && HAS_25610
21+
: taggability?.style === 'modern'
2522
? [CDK_CORE.ITaggableV2]
2623
: [];
2724
}
@@ -51,10 +48,8 @@ export class ResourceDecider {
5148
this.handleTagPropertyLegacy(name, prop, this.taggability.variant);
5249
continue;
5350
case 'modern':
54-
if (HAS_25610) {
55-
this.handleTagPropertyModern(name, prop, this.taggability.variant);
56-
continue;
57-
}
51+
this.handleTagPropertyModern(name, prop, this.taggability.variant);
52+
continue;
5853
}
5954
} else {
6055
this.handleTypeHistoryTypes(prop);
@@ -158,15 +153,15 @@ export class ResourceDecider {
158153
summary: 'Tag Manager which manages the tags for this resource',
159154
},
160155
},
161-
initializer: (props: Expression) =>
156+
initializer: (_: Expression) =>
162157
new CDK_CORE.TagManager(
163158
this.tagManagerVariant(variant),
164159
expr.lit(this.resource.cloudFormationType),
165-
HAS_25610 ? expr.UNDEFINED : $E(props)[originalName],
160+
expr.UNDEFINED,
166161
expr.object({ tagPropertyName: expr.lit(originalName) }),
167162
),
168163
cfnValueToRender: {
169-
[originalName]: $this.tags.renderTags(...(HAS_25610 ? [$this[rawTagsPropName]] : [])),
164+
[originalName]: $this.tags.renderTags($this[rawTagsPropName]),
170165
},
171166
},
172167
{
@@ -184,7 +179,7 @@ export class ResourceDecider {
184179

185180
private handleTagPropertyModern(cfnName: string, prop: Property, variant: TagVariant) {
186181
const originalName = propertyNameFromCloudFormation(cfnName);
187-
const originalType = this.converter.makeTypeResolvable(this.converter.typeFromProperty(prop));
182+
const originalType = this.converter.typeFromProperty(prop);
188183

189184
this.propsProperties.push({
190185
propertySpec: {
@@ -213,15 +208,15 @@ export class ResourceDecider {
213208
summary: 'Tag Manager which manages the tags for this resource',
214209
},
215210
},
216-
initializer: (props: Expression) =>
211+
initializer: (_: Expression) =>
217212
new CDK_CORE.TagManager(
218213
this.tagManagerVariant(variant),
219214
expr.lit(this.resource.cloudFormationType),
220-
HAS_25610 ? expr.UNDEFINED : $E(props)[originalName],
215+
expr.UNDEFINED,
221216
expr.object({ tagPropertyName: expr.lit(originalName) }),
222217
),
223218
cfnValueToRender: {
224-
[originalName]: $this.tags.renderTags(...(HAS_25610 ? [$this[originalName]] : [])),
219+
[originalName]: $this.cdkTagManager.renderTags($this[originalName]),
225220
},
226221
},
227222
{

0 commit comments

Comments
 (0)