Skip to content
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

reduce CloudFormation template size #2368

Merged
merged 1 commit into from
Apr 19, 2022
Merged

reduce CloudFormation template size #2368

merged 1 commit into from
Apr 19, 2022

Conversation

PatMyron
Copy link
Contributor

@PatMyron PatMyron commented Apr 1, 2022

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

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

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
Copy link
Contributor

jfuss commented Apr 8, 2022

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
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
Copy link
Contributor

jfuss commented Apr 12, 2022

@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*
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.

None yet

4 participants