Skip to content

Commit ed6de56

Browse files
PatMyronStephen Potter
authored andcommitted
fix(core): reduce CFN template indent size to save bytes (aws#19656)
also: aws/serverless-application-model#2368, cloudtools/troposphere#2028 aws#18694 aws#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 2ba4d1a commit ed6de56

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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)