Skip to content

Commit 0c2f98b

Browse files
authored
fix(cloudformation-include): string arrays inside unknown properties cannot be parsed (#32461)
We are using `this` to refer to static methods, which fails at runtime. Use the class name instead. Fixes #32454. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 0f5fe9a commit 0c2f98b

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"AWSTemplateFormatVersion": "2010-09-09",
3+
"Resources": {
4+
"AutoScalingGroup": {
5+
"Type": "AWS::AutoScaling::AutoScalingGroup",
6+
"Properties": {
7+
"DesiredCapacity": "1",
8+
"MinSize": "1",
9+
"MaxSize": "5"
10+
},
11+
"CreationPolicy": {
12+
"ResourceSignal": {
13+
"Count": 1,
14+
"Timeout": "PT10M"
15+
}
16+
},
17+
"UpdatePolicy": {
18+
"AutoScalingRollingUpdate": {
19+
"PauseTime": "PT10M",
20+
"SuspendProcesses": [
21+
"HealthCheck",
22+
"ReplaceUnhealthy",
23+
"AZRebalance",
24+
"AlarmNotification",
25+
"ScheduledActions"
26+
],
27+
"WaitOnResourceSignals": true
28+
}
29+
}
30+
}
31+
}
32+
}

packages/aws-cdk-lib/cloudformation-include/test/valid-templates.test.ts

+7
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,13 @@ describe('CDK Include', () => {
714714
);
715715
});
716716

717+
test('correctly handles string arrays in policy attributes', () => {
718+
const cfnTemplate = includeTestTemplate(stack, 'string-arrays-in-policy.json');
719+
Template.fromStack(stack).templateMatches(
720+
loadTestFileToJsObject('string-arrays-in-policy.json'),
721+
);
722+
});
723+
717724
test("correctly handles referencing the ingested template's resources across Stacks", () => {
718725
// for cross-stack sharing to work, we need an App
719726
const app = new core.App();

packages/aws-cdk-lib/core/lib/helpers-internal/cfn-parse.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export class FromCloudFormation {
173173
}
174174

175175
// in all other cases, delegate to the standard mapping logic
176-
return this.getArray(this.getString)(value);
176+
return FromCloudFormation.getArray(FromCloudFormation.getString)(value);
177177
}
178178

179179
public static getArray<T>(mapper: (arg: any) => FromCloudFormationResult<T>): (x: any) => FromCloudFormationResult<T[]> {
@@ -716,8 +716,8 @@ export class CfnParser {
716716

717717
const key = objectKeys[0];
718718
return key === 'Ref' || key.startsWith('Fn::') ||
719-
// special intrinsic only available in the 'Conditions' section
720-
(this.options.context === CfnParsingContext.CONDITIONS && key === 'Condition')
719+
// special intrinsic only available in the 'Conditions' section
720+
(this.options.context === CfnParsingContext.CONDITIONS && key === 'Condition')
721721
? key
722722
: undefined;
723723
}

0 commit comments

Comments
 (0)