Skip to content

reduce CloudFormation template size - #2368

Merged
moelasmar merged 1 commit into
aws:developfrom
PatMyron:patch-1
Apr 19, 2022
Merged

moelasmar merged 1 commit into
aws:developfrom
PatMyron:patch-1

Conversation

@PatMyron

@PatMyron PatMyron commented Apr 1, 2022 •

Copy link
Copy Markdown
Contributor

also: aws/aws-cdk#19656, cloudtools/troposphere#2028, awslabs/goformation#445

CloudFormation templates can currently only be 1MB, and template size limits apply even after transformation processing

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 on their own for now

Checklist:

  • Add/update unit tests using:
  • Add/update integration tests
  • make pr passes
  • Update documentation
  • Verify transformed template deploys and application functions as expected

mergify Bot pushed a commit to aws/aws-cdk that referenced this pull request Apr 1, 2022
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*
@jfuss

jfuss commented Apr 8, 2022

Copy link
Copy Markdown
Contributor

This seems like a fine change but this script is/should only be used for testing changes to the SAM repo. If you are using this to deploy a SAM template, you are using something not maintained for that and should be using SAM CLI or AWS CLI.

@PatMyron

Copy link
Copy Markdown
Contributor Author

@jfuss not sure I understand the relationship between this repo and https://github.com/aws/aws-sam-cli if you're saying these changes would be more meaningful there, mind linking to where these changes could be made more meaningfully?

@jfuss

jfuss commented Apr 12, 2022

Copy link
Copy Markdown
Contributor

@PatMyron This repo just holds the SAM Spec to CloudFormation conversion. SAM CLI's repo uses this to read the spec but holds the sam * commands.

There are a couple places you will need to update:

  1. https://github.com/aws/aws-sam-cli/blob/587ad2d22c3066b472bf3c8029e2e84eb643dda7/samcli/yamlhelper.py#L96
  2. https://github.com/aws/aws-sam-cli/blob/587ad2d22c3066b472bf3c8029e2e84eb643dda7/samcli/commands/package/package_context.py#L163

For 1, this covers sam build and sam package if the original template is in yaml. 2 covers the json case within sam package. I think that hits them all but 100% not sure.

@moelasmar
moelasmar merged commit 2b3b5b4 into aws:develop Apr 19, 2022
@PatMyron
PatMyron deleted the patch-1 branch April 20, 2022 00:34
StevePotter pushed a commit to StevePotter/aws-cdk that referenced this pull request Apr 27, 2022
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*
ali-n4i pushed a commit to ali-n4i/aws-cdk that referenced this pull request Jul 29, 2026
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*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants