aws / aws/aws-cdk

aws-cdk: Build a deployable artifact

Open
#23,051 2 comments 4 reactions 0 assignees View on GitHub
@aws-cdk/aws-sam effort/large feature-request p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
1d 19h
Merged PRs (30d)
71

Description

### Describe the feature

As a developer I would like the ability to generate a deployable artifact with CDK so that I can "build once and deploy many" times.

### Use Case

A mature CI/CD process can involve steps like (there are many variations, including feature flagging and canary deploys, but I will keep this simple/traditional):

**Continuous Integration phase**
1. Run unit tests, stubbed integration tests, and static code analysis
2. Build the code and IaC into a versioned deployable artifact
3. Upload this artifact to some repository
**Continuous Deployment Phase**
1. Deploy the versioned artifact from the CI step to a dev "environment" (preferably a dev AWS account)
2. Run some automated integration tests and perhaps relativistic performance tests etc.
3. Either manually or automatically promote/deploy this versioned artifact to a "test" or "uat" environment
4. Run more extensive automated and/or manual and/or exploratory tests
5. Either manually or automatically deploy the versioned artifact to a "prod" environment

Without a deployable artifact we essentially need to package up most of the repository or just pull down a specific SHA or tag. Doing this and running a deploy step that includes building the artifact again has the potential to introduce variability, thus makes promoting to further environments more risky.

### Proposed Solution

A `cdk build` capability that results in a self-contained deployable artifact that can be versioned and published to an artifact repository then later deployed while providing dynamic parameters to the deployment.

Perhaps `cdk deploy` can recognize the existence of an already built template/artifact and skip to the cloudformation deploy step.

### Other Information

AWS SAM essentially has this, by doing the following:

1. Run `sam build`
2. Package/zip up `.aws-sam/` along with a `samconfig.toml`. (** Note that the Functions can reference bundled code using the CodeUri property, without having it in account-specific S3 buckets)
4. Unpacking these and running `sam deploy --config-env ` will deploy the template and Lambda code

The `samconfig.toml` gives the ability to use environment-specific parameters, including some that come from environment-specific AWS accounts (like SSM parameters, secrets, etc.). These could include details like VPC Subnets and Security Groups for Lambdas.

### Acknowledgements

- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change

### CDK version used

2.51.1 (build 3d30cdb)

### Environment details (OS name and version, etc.)

Various

Contributor guide

Open the contributing guide

Research direction

Start with the cdk build and cdk deploy entry points and compare the AWS SAM build/package/deploy workflow described in the issue. Define the artifact contents, versioning, and environment-specific parameters before implementation; done means a built artifact can be deployed repeatedly without rebuilding.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
build-system, cloud, infrastructure, release
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.