-
Notifications
You must be signed in to change notification settings - Fork 4k
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
(cdk cli): Create Smaller CloudFormation Templates #18694
Comments
@rix0rrr FYI, I created a PR for this that's one line. I can't see any issues with just simply not pretty-printing the file when writing it, but there could be some issue or concern that I'm not aware of. Thanks! |
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*
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*
@corymhall i would definitely like to make some progress in this. What did you have in mind? |
Fixes #18694, #8712 This change adds an option to suppress indentation in CloudFormation template files. Suppressing indentation will reduce the file size of templates. Indentation can be set by enabling for specific Stacks using the new `suppressTemplateIndentation` property in `StackProps`, or globally using the new `@aws-cdk/core:suppressTemplateIndentation` context key. This PR provides additional template size reduction beyond the indentation change in #19656. @rix0rrr @mackalex @PatMyron ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
Description
Allow options when deploying using the cdk cli that would result in physically smaller CloudFormation template.
Currently the template that is generated and deployed is formatted as JSON with whitespace.
From our testing, simply removing the whitespace can result in a template that is roughly 50% of the size.
Outputting the template as YAML also decreases the template size by roughly the same amount.
Use Case
We have a CDK project that has several lambda functions behind an API. We just ran into the limit where a CloudFormation template has to be less than 1MB.
The number of resources we have is relatively low, but due to the auto generated names of resources the template size is quite large.
If we could minify the template before deploying, or if we could have CDK deploy the template as YAML, we would be able to halve the size of the template and deploy twice as many resources.
Proposed Solution
This would be a combination of previously proposed solutions.
#8712
The above issue suggests having an option to compact the whitespace. This seems like a reasonable proposal.
#2965
The above issue mentions including the option of writing YAML to
cdk.out
. This appears to have been rejected on the premise that the folder is for machines to read, and that the only benefit of YAML is that it's human readable.This ignores the fact that the YAML format results in a significantly smaller file size, and that AWS CloudFormation has a hard limit on template file sizes.
Other information
No response
Acknowledge
The text was updated successfully, but these errors were encountered: