From 52810aef8de4c06f6122e538c77f8ba5a60bfb21 Mon Sep 17 00:00:00 2001 From: Alex McKenzie Date: Tue, 8 Feb 2022 19:01:11 -0500 Subject: [PATCH 1/2] disable pretty printing of json file The JSON file that is created by the CDK for deployment is only read by machines, but pretty printing the file uses up a lot of space. This is a practical concern due to the fact that CloudFormation has a file size limit for templates --- packages/aws-cdk/lib/api/cxapp/cloud-executable.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk/lib/api/cxapp/cloud-executable.ts b/packages/aws-cdk/lib/api/cxapp/cloud-executable.ts index 9bbb607de44fb..6b669792010ad 100644 --- a/packages/aws-cdk/lib/api/cxapp/cloud-executable.ts +++ b/packages/aws-cdk/lib/api/cxapp/cloud-executable.ts @@ -173,7 +173,7 @@ export class CloudExecutable { // // Be sure to flush the changes we just made back to disk. The on-disk format is always // JSON. - await fs.writeFile(stack.templateFullPath, JSON.stringify(stack.template, undefined, 2), { encoding: 'utf-8' }); + await fs.writeFile(stack.templateFullPath, JSON.stringify(stack.template), { encoding: 'utf-8' }); } } From 3e0ff7b4b1fb2e0c00049af4649dcb83c21f2fcb Mon Sep 17 00:00:00 2001 From: Alex McKenzie Date: Wed, 2 Mar 2022 09:11:50 -0600 Subject: [PATCH 2/2] change indentation from 2 to 1 The CloudFormation console will display the original template file that was uploaded by the CDK. To balance the concerns of readability and file size the indentation has been changed from two spaces to one space. Co-authored-by: Pat Myron --- packages/aws-cdk/lib/api/cxapp/cloud-executable.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk/lib/api/cxapp/cloud-executable.ts b/packages/aws-cdk/lib/api/cxapp/cloud-executable.ts index 6b669792010ad..65ac7e78a5cb5 100644 --- a/packages/aws-cdk/lib/api/cxapp/cloud-executable.ts +++ b/packages/aws-cdk/lib/api/cxapp/cloud-executable.ts @@ -173,7 +173,7 @@ export class CloudExecutable { // // Be sure to flush the changes we just made back to disk. The on-disk format is always // JSON. - await fs.writeFile(stack.templateFullPath, JSON.stringify(stack.template), { encoding: 'utf-8' }); + await fs.writeFile(stack.templateFullPath, JSON.stringify(stack.template, undefined, 1), { encoding: 'utf-8' }); } }