Skip to content

Commit fd63ca3

Browse files
authored
fix(core): reduce CFN template indent size to save bytes (#19656)
also: aws/serverless-application-model#2368, cloudtools/troposphere#2028 #18694 #18886 [CloudFormation templates can currently only be 1MB](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cloudformation-limits.html) Simply reducing indentation from 2 to 1 should remove ~1/4 of the template file size for everyone by default while still preserving indentation formatting. Beyond improving the default, those wishing to reduce readability for further reduced file size could opt into using something like [`jq`](https://stedolan.github.io/jq/) on their own for now ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)? * [ ] Did you use `cdk-integ` to deploy the infrastructure and generate the snapshot (i.e. `cdk-integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent d8e602b commit fd63ca3

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

packages/@aws-cdk/core/lib/stack.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ export class Stack extends CoreConstruct implements ITaggable {
793793
Annotations.of(this).addInfo(`Number of resources: ${numberOfResources} is approaching allowed maximum of ${this.maxResources}`);
794794
}
795795
}
796-
fs.writeFileSync(outPath, JSON.stringify(template, undefined, 2));
796+
fs.writeFileSync(outPath, JSON.stringify(template, undefined, 1));
797797

798798
for (const ctx of this._missingContext) {
799799
if (lookupRoleArn != null) {

packages/@aws-cdk/pipelines/test/blueprint/stack-deployment.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe('templateUrl', () => {
3131
const sd = StageDeployment.fromStage(stage);
3232

3333
// THEN
34-
expect(sd.stacks[0].templateUrl).toBe('https://cdk-hnb659fds-assets-111-us-east-1.s3.us-east-1.amazonaws.com/93ae4de94f81d0905c37db64b7304f5d65233ca4d9581d3a32215743c9bb92dd.json');
34+
expect(sd.stacks[0].templateUrl).toBe('https://cdk-hnb659fds-assets-111-us-east-1.s3.us-east-1.amazonaws.com/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json');
3535
});
3636

3737
test('without region', () => {
@@ -43,7 +43,7 @@ describe('templateUrl', () => {
4343
const sd = StageDeployment.fromStage(stage);
4444

4545
// THEN
46-
expect(sd.stacks[0].templateUrl).toBe('https://cdk-hnb659fds-assets-111-.s3.amazonaws.com/$%7BAWS::Region%7D/93ae4de94f81d0905c37db64b7304f5d65233ca4d9581d3a32215743c9bb92dd.json');
46+
expect(sd.stacks[0].templateUrl).toBe('https://cdk-hnb659fds-assets-111-.s3.amazonaws.com/$%7BAWS::Region%7D/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json');
4747
});
4848

4949
});

0 commit comments

Comments
 (0)