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

[cdk-pipelines] Pipeline template grows very fast reaching the 460,800 bytes limit from CloudFormation #9225

Closed
JFox opened this issue Jul 23, 2020 · 19 comments
Assignees
Labels
@aws-cdk/pipelines CDK Pipelines library bug This issue is a bug. effort/medium Medium work item – several days of effort p1

Comments

@JFox
Copy link

JFox commented Jul 23, 2020

❓ General Issue

The Question

After adding around 14 stacks (25 counting nested stacks) to a single Pipeline Application (Stage) the pipeline references 27 assets and the template grows above CloudFormation's 460,800 bytes limit, blocking the pipeline and making it unusable.

Is there a way to avoid this by compressing the generated template or by splitting it somehow? I'm facing this on a staging stage and production is way bigger

My suspicion is that the assets make the template grow too fast as each of them generates a build action with the whole chain of roles, policies, etc.

Environment

  • CLI Version : 1.51.0 (build 8c2d53c)
  • Framework Version: 1.51.0 (build 8c2d53c)
  • Node.js Version: v12.18.0
  • OS : aws/codebuild/standard:4.0
  • Language (Version): TypeScript (3.9.5)
@JFox JFox added guidance Question that needs advice or information. needs-triage This issue or PR still needs to be triaged. labels Jul 23, 2020
@github-actions github-actions bot added the @aws-cdk/pipelines CDK Pipelines library label Jul 23, 2020
@njlynch
Copy link
Contributor

njlynch commented Jul 23, 2020

This sounds related to #9066, but possibly broader in scope.

@ericzbeard ericzbeard removed the needs-triage This issue or PR still needs to be triaged. label Jul 23, 2020
@srethira
Copy link

I ran into same exact problem. Here is the github issue I created - #9237. Is there any workaround for this problem, until further fix to it ?

njlynch added a commit that referenced this issue Jul 24, 2020
This change combines the two roles (and policies) per pipeline asset into a
single role + policy for all assets in a pipeline. In a small pipeline with only
3 assets, this reduced the overall template size by a third.

With a pipeline stack with 30 assets, this change reduces the template size from
363111 bytes to 190223 bytes.

Tested on a cross-account pipeline to verify permissions were retained.

fixes #9066
mitigates #9225
mitigates #9237
mergify bot pushed a commit that referenced this issue Jul 28, 2020
…ies (#9243)

This change combines the two roles (and policies) per pipeline asset into a
single role + policy for all assets in a pipeline. In a small pipeline with only
3 assets, this reduced the overall template size by a third.

With a pipeline stack with 30 assets, this change reduces the template size from
363111 bytes to 190223 bytes.

Tested on a cross-account pipeline to verify permissions were retained.

fixes #9066
mitigates #9225
mitigates #9237


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@njlynch
Copy link
Contributor

njlynch commented Jul 28, 2020

Hi @JFox (and @srethira) --

I just merged a change (#9243) that should help with this issue. Given your description (14 stacks, 25 including nested stacks, and 27 assets), I'm not 100% sure that it will be enough, but it should significantly help. (With even just 10 assets, this change cut the template size in half). The fix will go out in the next release; once it does, I would appreciate any feedback on if it was sufficient to solve the problem for you, or if more work is necessary.

Thanks!

@JFox
Copy link
Author

JFox commented Jul 28, 2020

Thank you so much for taking care of this and for doing it so quickly.

I would keep a very close eye and give it a try as soon as it is released and get back to you with specific numbers.

@srethira
Copy link

@njlynch Thanks for providing the fix in a short period of time. Do you know when this will be released?

@njlynch
Copy link
Contributor

njlynch commented Jul 28, 2020

@njlynch Thanks for providing the fix in a short period of time. Do you know when this will be released?

Soon! We typically release once a week.

@seawatts
Copy link

Hi @JFox (and @srethira) --

I just merged a change (#9243) that should help with this issue. Given your description (14 stacks, 25 including nested stacks, and 27 assets), I'm not 100% sure that it will be enough, but it should significantly help. (With even just 10 assets, this change cut the template size in half). The fix will go out in the next release; once it does, I would appreciate any feedback on if it was sufficient to solve the problem for you, or if more work is necessary.

Thanks!

I've got about 10 stacks with around 30 - 40 assets, with more to come. So we'll see. 🤞 I'll keep you updated.
I was thinking I could just create multiple pipelines / apps, however, because I have a shared stack that all the other stacks rely on, that solution doesn't work.

@seawatts
Copy link

seawatts commented Jul 29, 2020

Just tried out the latest fix (#9243) with v1.55.0 But now I am seeing a new error 😦

Maximum policy size of 10240 bytes exceeded for role PipelineStack-PipelineAssetsRole9B011B83-1UOLXJQTUXXXX

cc: @njlynch

@njlynch
Copy link
Contributor

njlynch commented Jul 29, 2020

@seawatts - Thanks for the quick turn-around and feedback. We'll investigate the new issue with the policy size.

@JFox
Copy link
Author

JFox commented Jul 29, 2020

As a first test, we went by deploying the new version it to a fresh new account and it seems to work now, we are not getting the policy limit mentioned by @seawatts. However I won't totally discard it. I will post back once we run it in the pipeline that is nearly below the 460,800 bytes limit

@JFox
Copy link
Author

JFox commented Jul 29, 2020

I correct myself, we also hit the Maximum policy size of 10240 bytes exceeded

@srethira
Copy link

Hi @JFox (and @srethira) --
I just merged a change (#9243) that should help with this issue. Given your description (14 stacks, 25 including nested stacks, and 27 assets), I'm not 100% sure that it will be enough, but it should significantly help. (With even just 10 assets, this change cut the template size in half). The fix will go out in the next release; once it does, I would appreciate any feedback on if it was sufficient to solve the problem for you, or if more work is necessary.
Thanks!

I've got about 10 stacks with around 30 - 40 assets, with more to come. So we'll see. 🤞 I'll keep you updated.
I was thinking I could just create multiple pipelines / apps, however, because I have a shared stack that all the other stacks rely on, that solution doesn't work.

That's my thought process to overcome to issue. Unfortunately, I'm in the same boat as you're on with stack dependency.

@njlynch
Copy link
Contributor

njlynch commented Jul 30, 2020

#9333 has been merged and will go out in the next release. I can create a pipeline with 50 assets successfully with this new approach. After that, we run into issues with limits on the number of actions in a single Pipeline stage. #9353 has been filed to track support for > 50 assets.

@JFox
Copy link
Author

JFox commented Jul 30, 2020

#9333 has been merged and will go out in the next release. I can create a pipeline with 50 assets successfully with this new approach. After that, we run into issues with limits on the number of actions in a single Pipeline stage. #9353 has been filed to track support for > 50 assets.

Great news! Thanks again for getting it done so fast

@nonken
Copy link
Contributor

nonken commented Jul 30, 2020

Super awesome!!! 🙏🏻

@njlynch
Copy link
Contributor

njlynch commented Aug 3, 2020

CDK 1.56.0 was released on Friday; please do let us know if this solved the issue for you.

@srethira
Copy link

srethira commented Aug 3, 2020

@njlynch I'm possibly running into #9353

71/101 | 4:35:41 PM | UPDATE_FAILED | AWS::CodePipeline::Pipeline | Pipeline/Pipeline (Pipeline9850B417) Pipeline stage 'Assets' has too many actions. There can only be up to 50 actions in a pipeline stage (Service: AWSCodePipeline; Status Code: 400; Error Code: InvalidStageDeclarationException; Request ID: 9304128e-3fa6-4793-8079-2525422cd668)

@ericzbeard ericzbeard removed their assignment Aug 3, 2020
@rix0rrr rix0rrr added bug This issue is a bug. effort/medium Medium work item – several days of effort p1 guidance Question that needs advice or information. and removed guidance Question that needs advice or information. labels Aug 4, 2020
@JFox
Copy link
Author

JFox commented Aug 10, 2020

We deployed version 1.56.0 successfully with 31 assets being generated in the Assets stage. I guess this will buy us enough time for the root cause to be addressed. Thanks @njlynch

@njlynch
Copy link
Contributor

njlynch commented Aug 10, 2020

Thanks for confirming, @JFox. Closing this out and tracking the remaining scaling issue (50 assets/actions) in #9353.

@njlynch njlynch closed this as completed Aug 10, 2020
curtiseppel pushed a commit to curtiseppel/aws-cdk that referenced this issue Aug 11, 2020
…ies (aws#9243)

This change combines the two roles (and policies) per pipeline asset into a
single role + policy for all assets in a pipeline. In a small pipeline with only
3 assets, this reduced the overall template size by a third.

With a pipeline stack with 30 assets, this change reduces the template size from
363111 bytes to 190223 bytes.

Tested on a cross-account pipeline to verify permissions were retained.

fixes aws#9066
mitigates aws#9225
mitigates aws#9237


----

*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
@aws-cdk/pipelines CDK Pipelines library bug This issue is a bug. effort/medium Medium work item – several days of effort p1
Projects
None yet
Development

No branches or pull requests

7 participants