Deploy stacks in parallel where possible
I am deploying a CDK app that uses 9 different stacks. Many of the stacks either do not depend on each other, or can be deployed in parallel. For example one base stack that has a DynamoDB table needs to be deployed first, but then all five stacks which have a Lambda that uses that table could be deployed in parallel. Then finally a stack that creates the API gateway that points at those Lambda functions can be deployed.
Ideally I would like to be able to opt in to deploying stacks concurrently as much as possible. Right now CDK only ever deploys one stack at a time, which makes the overall cdk deploy much slower than it needs to be.
Second that. It is very time-consuming even on relatively small projects.
Would be super useful, but I guess it's not easy to implement because there are also a few number of limitations in terms of what can happen concurrently in an account/region, such as:
https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Limits.html#limits-api
& more, see: https://twitter.com/danbdo/status/1110183888415002624?s=19
@eladb This would be amazing. Any thoughts/plans on this?
Bumping this, we have so many stacks that without this we would likely have to utilize some sort of wrapper for the CDK which would diminish some of the value.
@lusentis I don't believe that concurrency limits will impact the development of this feature from the point of view of CDK, because CloudFormation already handles that concurrency internally. From CDK's perspective it would just be deploying multiple CloudFormation stacks in parallel and waiting for CFN to come back with a success status. CFN already handles the retries / concurrency internally when it is deploying multiple stacks at once
I've got some environments with 30 or 40 stacks, so this would be very helpful.
we also have a huge infrastructure. If we could execute the stacks parallelly it would save couple of hours' time.
I have multiple independent stacks which manage cloudfront distributions. Updating cloudfront distribution usually takes 5-10 minutes…
Currently I work around the limitation by opening multiple terminal sessions and deploying single stack per terminal session, but hence in parallel.
Very necessary feature. With other deployment tools is possible, for example Sceptre
Especially painfull, as issue https://github.com/aws/aws-cdk/issues/5637 blocks implementing workaround for this one.
+1, would save us significant deploy time as well.
Already painful experience with the same stack and different environments...
@OperationalFallacy With the same stack and different environments its not too bad because you can just run multiple copies of CDK in parallel with different profiles, or different CDK_DEFAULT_ACCOUNT env variable.
Something like this:
cdk deploy --profile dev --require-approval=never &
cdk deploy --profile production --require-approval=never &
This assumes you have two different AWS credential profiles setup, and are using two different AWS subaccounts for a developer environment and a production environment (this is best practice anyway). The & operator causes CDK to run in the background, so both instances of CDK will deploy to their respective environments in parallel.
In general I do agree that deploying to multiple environments concurrently as well as multiple stacks concurrently would be nice though
I'm using a CloudFront factory CDK pattern that updates 10+ CF distros (separate stacks) sequentially. It takes forever to push even simple changes. Therefore this would be a great improvement if we can parallelize cdk deploy.
In the meantime, I'm tempted to run cdk list and then simply fire off individual stacks. i.e. for stack in $(cdk list); do cdk deploy $stack --require-approval=never &; done;
Edit: I'll be exploring CDK pipelines to deploy in parallel.
+1
We have over 200 stacks and deploying some of them in parallel would help us a lot.
We are not planning to support this in the foreseeable future. I would highly recommend looking into CDK pipelines to deploy multiple stacks in parallel.
Is CDK pipelines a product or something? Or you’re saying creating a pipeline to deploy inparallel?
I believe Elad was referring to this @OperationalFallacy : https://docs.aws.amazon.com/cdk/api/latest/docs/pipelines-readme.html
Thanks @skinny85, that looks like something really cool, but I can't wrap my head around it. Is there a blog post or other resources for it?
Thanks @skinny85, that looks like something really cool, but I can't wrap my head around it. Is there a blog post or other resources for it?
Check this out: https://www.youtube.com/watch?v=774leNpQXo0