Skip to content

(cli): Add cdk publish command for asset publishing #982

@hoegertn

Description

@hoegertn

Describe the feature

Add a new cdk publish CLI command that uploads synthesized assets (container images, Lambda bundles, file assets, etc.) to their respective destinations without performing a deployment.

Use Case

In CI/CD pipelines, the recommended best practice is to separate the build/publish phase from the deployment phase:

Synthesize (cdk synth) - Generate CloudFormation templates and asset manifests
Publish - Upload all assets (Docker images, Lambda ZIPs, S3 files) to their destinations
Deploy - Deploy stacks sequentially across stages/environments (without re-uploading assets)

Currently, cdk deploy combines asset publishing and deployment into a single operation. This creates challenges in enterprise CI/CD pipelines:

  • Immutable artifacts: Assets should be published once and reused across multiple deployments (dev → staging → production)
  • Separation of concerns: Build/publish should complete before any deployment begins
  • Reduced deployment time: When deploying to multiple stages, assets only need to be uploaded once
  • Atomic releases: All assets are verified to be published before any deployment starts
  • Pipeline structure: Most CI/CD systems (GitHub Actions, GitLab CI, CodePipeline, Jenkins) work best with distinct publish and deploy stages

The only way to achieve this workflow today is by installing and using the cdk-assets package directly:

This approach has drawbacks:

  • Requires an additional dependency
  • Not well documented in the main CDK documentation
  • The API and usage is less discoverable than built-in CLI commands
  • Users must understand the internal asset manifest structure

Proposed Solution

Add a cdk publish command to the CDK CLI.

Other Information

  • This aligns with the CDK Pipelines concept where assets are published before deployment
  • The underlying functionality already exists in cdk-assets - this would expose it as a first-class CLI command

If this is implemented, it would be also beneficial to have an option in the cdk deploy command to skip publishing during the deploy step.

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.x

Environment details (OS name and version, etc.)

all

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions