Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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,10 @@
{
"Resources": {
"Bucket": {
"Type": "AWS::S3::Bucket",
"Properties": {
"AccessControl": true
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ describe('CDK Include', () => {
);
});

test('accepts booleans for properties with type string', () => {
includeTestTemplate(stack, 'boolean-for-string.json');

expect(stack).toMatchTemplate(
loadTestFileToJsObject('boolean-for-string.json'),
);
});

test('correctly changes the logical IDs, including references, if imported with preserveLogicalIds=false', () => {
const cfnTemplate = includeTestTemplate(stack, 'bucket-with-encryption-key.json', {
preserveLogicalIds: false,
Expand Down
6 changes: 6 additions & 0 deletions packages/@aws-cdk/core/lib/cfn-parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ export class FromCloudFormation {
return new FromCloudFormationResult(value.toString());
}

// CloudFormation treats booleans and strings interchangeably;
// so, if we get a boolean here, convert it to a string
if (typeof value === 'boolean') {
return new FromCloudFormationResult(value.toString());
}

// in all other cases, just return the input,
// and let a validator handle it if it's not a string
return new FromCloudFormationResult(value);
Expand Down