Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cloudformation-include): string arrays inside unknown properties cannot be parsed #32461

Merged
merged 5 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
"AutoScalingGroup": {
"Type": "AWS::AutoScaling::AutoScalingGroup",
"Properties": {
"DesiredCapacity": "1",
"MinSize": "1",
"MaxSize": "5"
},
"CreationPolicy": {
"ResourceSignal": {
"Count": 1,
"Timeout": "PT10M"
}
},
"UpdatePolicy": {
"AutoScalingRollingUpdate": {
"PauseTime": "PT10M",
"SuspendProcesses": [
"HealthCheck",
"ReplaceUnhealthy",
"AZRebalance",
"AlarmNotification",
"ScheduledActions"
],
"WaitOnResourceSignals": true
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,13 @@ describe('CDK Include', () => {
);
});

test('correctly handles string arrays in policy attributes', () => {
const cfnTemplate = includeTestTemplate(stack, 'string-arrays-in-policy.json');
Template.fromStack(stack).templateMatches(
loadTestFileToJsObject('string-arrays-in-policy.json'),
);
});

test("correctly handles referencing the ingested template's resources across Stacks", () => {
// for cross-stack sharing to work, we need an App
const app = new core.App();
Expand Down
6 changes: 3 additions & 3 deletions packages/aws-cdk-lib/core/lib/helpers-internal/cfn-parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export class FromCloudFormation {
}

// in all other cases, delegate to the standard mapping logic
return this.getArray(this.getString)(value);
return FromCloudFormation.getArray(FromCloudFormation.getString)(value);
}

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

const key = objectKeys[0];
return key === 'Ref' || key.startsWith('Fn::') ||
// special intrinsic only available in the 'Conditions' section
(this.options.context === CfnParsingContext.CONDITIONS && key === 'Condition')
// special intrinsic only available in the 'Conditions' section
(this.options.context === CfnParsingContext.CONDITIONS && key === 'Condition')
? key
: undefined;
}
Expand Down
Loading