B.AwsCdkParallel
A python based package that enables AWS CDK parallel stack deployments.
Description
One of the biggest downsides of AWS CDK IaC tool is the sequential deployments.
If you have many stacks within your project - it can take hours and hours till
everything gets deployed. Wouldn't it be cool to parallelize them? According to
AWS CDK tool maintainers - they are not even thinking right now to include such
functionality. Hence, this project was built. This project allows you to run
traditional cdk deploy * and cdk destroy * -f. But the main trick is that it
can do it in parallel - massively increasing the speed of your deployments.
Remarks
Biomapas aims to modernise life-science industry by sharing its IT knowledge with other companies and the community. This is an open source library intended to be used by anyone. Improvements and pull requests are welcome.
Some techniques and inspirations were taken from this blog post:
https://taimos.de/blog/deploying-your-cdk-app-to-different-stages-and-environments
General issue is being discussed on github:
https://github.com/aws/aws-cdk/issues/1973
Related technology
- Python 3
- AWS CDK
- AWS CloudFormation
Assumptions
The project assumes the following:
- You have basic-good knowledge in python programming.
- You have basic-good knowledge in AWS.
- You have very good knowledge in AWS CDK.
Useful sources
-
Read more AWS CDK:
https://github.com/aws/aws-cdk -
Read more about parallel AWS CDK deployments:
https://taimos.de/blog/deploying-your-cdk-app-to-different-stages-and-environments
Install
The project is built and uploaded to PyPi. Install it by using pip.
pip install b_aws_cdk_parallel
Or directly install it through source.
pip install .
Usage & Examples
Programmatic usage
The quickest and easiest example:
from b_aws_cdk_parallel.deployment_executor import DeploymentExecutor
from b_aws_cdk_parallel.deployment_type import DeploymentType
executor = DeploymentExecutor(type=DeploymentType.DEPLOY)
executor.run()
executor = DeploymentExecutor(type=DeploymentType.DESTROY)
executor.run()
The more advanced example to deploy/destroy:
from b_aws_cdk_parallel.deployment_executor import DeploymentExecutor
from b_aws_cdk_parallel.deployment_type import DeploymentType
from b_aws_cdk_parallel.cdk_arguments import CdkArguments
executor = DeploymentExecutor(
type=DeploymentType.DEPLOY, # Or DESTROY
# You can specify a full path to your CDK app.
path='/optional/path/to/cdk/app',
# You can specify OS-level global parameters.
env={
'optional': 'os-level environment variables'
},
# You can specify AWS-CDK-specific arguments.
cdk_arguments=CdkArguments(
aws_cdk_app_stacks_to_deploy=['MyCoolStack'],
aws_cdk_app_parameters=['Test1=Test1'],
aws_cdk_app_context=['Context1=Context1']
)
)
executor.run()
The library generates beautiful stack dependency outputs for easier debugging:
----- Stack dependency graph: -----
» Stack1: []
× Stack2: [Stack1]
× Stack3: [Stack1]
× Stack4: [Stack1, Stack2, Stack3]
× Stack5: [Stack1, Stack4]
» Stack8: []
× Stack7: [Stack1, Stack2, Stack3, Stack4, Stack5]
× Stack6: [Stack1, Stack7]
× Stack10: [Stack1, Stack6, Stack7]
× Stack9: [Stack1, Stack8]
» B-Aws-Cdk-Parallel-MainStack-3: []
[Stack2] Doing stuff...
[Stack2] Doing stuff...
[Stack4] Doing stuff...
[Stack3] Doing stuff...
CLI usage
The library also exposes CLI access.
To get usage help, simply run:
acdk -h
To deploy infrastructure, run:
acdk deploy --path /project/app/
To destroy infrastructure, run:
acdk destroy --path /project/app/
Testing
This project has integration tests based on pytest. To run tests, simply run:
pytest b_aws_cdk_parallel_test/integration/tests
Contribution
Found a bug? Want to add or suggest a new feature?
Contributions of any kind are gladly welcome. You may contact us
directly, create a pull-request or an issue in github platform.
Lets modernize the world together.
Release history
3.3.0
- Add
--max-parallel-deploymentsCLI flag to allow control of number the of stack deployments that run at the same time. For larger projects this can significantly reduce the amount of memory used when deploying a highly parallel stack.
3.2.0
- Remove
aws-cdk.coredependency as it is probably not needed (if the project is developed with AWS CDK anyways it will havecoremodule installed). By removing this dependency bothV1andV2versions of AWS CDK should work.
3.1.0
- Fix dependencies.
- Remove unnecessary dependencies.
3.0.0
- cdk v2 compatibility.
- Use the stack displayName when calling the cdk deploy command.
2.3.0
- Improve parallel stack deployments by introducing
--exclusivelyflag. - Make dependencies graph beautiful.
- Output beautiful stack names (not aws cdk generated names).
- Fix --path CLI bug.
2.2.0
- Support "--parameters".
- Support "--context".
- Support specifying stacks.
- Add a lot more tests.
2.1.0
- Expose CLI command
acdkto enable deployment/destruction through CLI.
2.0.0
- Major bug fixes for resolving stack dependencies. The algorithm for parallel stack destruction has fundamentally changed.
- Added integration tests to test against an actual AWS environment.
- More improvements will come for 2.1.0.
1.3.0
- Do not rebuild assets on destroy.
1.2.0
- Do not rebuild assets on deployment.
1.1.0
- Add ability to control maximum parallel deployments.
1.0.0
- Complete rework of the project. Build a dependency tree to determine what to deploy.
0.4.1
- Raise exception in case of a failed deployment.
0.4.0
- Cdk list command should also receive path and environment.
0.3.0
- Add ability to specify CDK path and environment variables for processes.
0.2.0
- Add ability to retry main deployment too.
0.1.0
- Refactor project to make it more debug-friendly.
0.0.2
- Upgrade dependencies.
0.0.1
- Initial build.
Metadata
Release files for b-aws-cdk-parallel 3.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| b_aws_cdk_parallel-3.3.0.tar.gz | 21.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| b_aws_cdk_parallel-3.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 52.4 kB
Release files / b_aws_cdk_parallel-3.3.0.tar.gz
| Download URL | b_aws_cdk_parallel-3.3.0.tar.gz |
|---|---|
| Size | 21.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0169894c27dac1da1b02bf83a616a2965daa9cd1669291f8a66b2df6cff8eff5
|
|
BLAKE2b-256 checksum How to use checksums |
67ca99544c8928c82ce74f4e8cf5145594f90a7945f402eaac1760d767b3d086
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.14
|
Release files / b_aws_cdk_parallel-3.3.0-py3-none-any.whl
| Download URL | b_aws_cdk_parallel-3.3.0-py3-none-any.whl |
|---|---|
| Size | 31.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7a1797765286fa9ae2b22191b9a34f41df411c57092fcb99e16e7164572f7b56
|
|
BLAKE2b-256 checksum How to use checksums |
ad508a7cfaddff6bc77f977e8d94752c340c96f7ea58bda7d4f12d6029d418bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.14
|
Security for b-aws-cdk-parallel 3.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.