Need full control of what infrastructure gets deployed? Link your own CDK repository to define all of your own infrastructure in AWS. Let Deplify handle managing the deployments of that infrastructure across multiple environments.

Getting Started

Deploying your CDK project is easy, just follow the steps below.

1

Inject DEPLIFY_STACK_ID env variable as part of your cdk stack names.

Note This step is optional, but highly reccommended.

As part of the build step, Deplify will provide a DEPLIFY_STACK_ID environment variable. This is the unique identifier for a stack, this can be used to generate a unique cloudformation stack names to avoid naming collisions when deploying multiple versions of the same stack into the same AWS account.

In your cdk code repo, when defining a CDK stack, you should use DEPLIFY_STACK_ID as part of the prefix. Below is an example.

  const app = new cdk.App();
  new TestCdkStack(app, `${process.env.DEPLIFY_STACK_ID}-Stack`, {
    // ..props
  });
2

Ensure CDK code is environment agnostic

Deplify will handle deploying your CDK code to the correct AWS account + region. So ensure you are not hardcoding any environment details in your CDK code.

const app = new cdk.App();
new TestCdkStack(app, `${process.env.DEPLIFY_STACK_ID}-Stack`, {
// REMOVE THIS LINE IF YOU HAVE IT!!
env: { account: '123456789012', region: 'us-east-1' },
});
3

Create a CDK Provider stack in Deplify

Note Deplify will handle running cdk synth & cdk deploy so do not add them in your build configuration. Deplify will always use the version of CDK defined in your package dependencies.

  • Hit the Add a Stack button in the environment view.
  • Choose the CDK Provider blueprint.
  • If your project requires custom build commands, ensure you fill them in. In most cases, you can leave the defaults.
  • Click Create Stack
4

All Done

Your project will begin deployment. Track the deployment in the dashboard.