Bootstrapping an AWS CDK app with a workflow - Amazon CodeCatalyst

Bootstrapping an AWS CDK app with a workflow

This section describes how to bootstrap an AWS CDK application using a CodeCatalyst workflow. To accomplish this, you must add the AWS CDK bootstrap action to your workflow. The AWS CDK bootstrap action provisions a bootstrap stack in your AWS environment using the modern template. If a bootstrap stack already exists, the action updates it if necessary. Having a bootstrap stack present in AWS is a prerequisite for deploying an AWS CDK app.

For more information about bootstrapping, see Bootstrapping in the AWS Cloud Development Kit (AWS CDK) Developer Guide.

When to use this action

Use this action if you have a workflow that deploys an AWS CDK app, and you want to deploy (and update, if needed) the bootstrap stack at the same time. In this case, you would add the AWS CDK bootstrap action to the same workflow as the one that deploys your AWS CDK app.

Do not use this action if either of the following applies:

  • You already deployed a bootstrap stack using another mechanism, and you want to keep it intact (no updates).

  • You want to use a custom bootstrap template, which is not supported with the AWS CDK bootstrap action.

How it works

The AWS CDK bootstrap works as follows:

  1. At runtime, if you specified version 1.0.7 or earlier of the action, the action downloads the latest CDK CLI (also called the AWS CDK Tookit) to the CodeCatalyst build image.

    If you specified version 1.0.8 or later, the action comes bundled with a specific version of the CDK CLI, so no download occurs.

  2. The action uses the CDK CLI to run the cdk bootstrap command. This command performs the bootstrapping tasks described in the Bootstrapping topic in the AWS Cloud Development Kit (AWS CDK) Developer Guide.

CDK CLI versions used by the "AWS CDK bootstrap" action

The following table shows which version of the CDK CLI is used by default by different versions of the AWS CDK bootstrap action.

Note

You might be able to override the default. For more information, see CdkCliVersion in the "AWS CDK bootstrap" action YAML definition.

"AWS CDK bootstrap" action version AWS CDK CLI version

1.0.0 – 1.0.7

latest

1.0.8 or later

2.99.1

Prerequisites

Before you can use the AWS CDK bootstrap action, make sure you have an AWS CDK app ready. The bootstrap action will synthesize the AWS CDK app before bootstrapping. You can write your app in any programming language supported by the AWS CDK.

Make sure your AWS CDK app files are available in:

Example workflow

Refer to the Example workflow in the Deploying an AWS Cloud Development Kit (AWS CDK) app with a workflow for a workflow that includes the AWS CDK bootstrap action.

Adding the "AWS CDK bootstrap" action

Use the following instructions to add the AWS CDK bootstrap action to your workflow.

Prerequisites

Before you begin, make sure you have completed the tasks described in Prerequisites.

Visual
To add the "AWS CDK bootstrap" action using the visual editor
  1. Open the CodeCatalyst console at https://codecatalyst.aws/.

  2. Choose your project.

  3. In the navigation pane, choose CI/CD, and then choose Workflows.

  4. Choose the name of your workflow. You can filter by the source repository or branch name where the workflow is defined, or filter by workflow name.

  5. Choose Edit.

  6. Choose Visual.

  7. At the top-left, choose + Actions to open the action catalog.

  8. From the drop-down list, choose Amazon CodeCatalyst.

  9. Search for the AWS CDK bootstrap action, and do one of the following:

    • Choose the plus sign (+) to add the action to the workflow diagram and open its configuration pane.

      Or

    • Choose AWS CDK bootstrap. The action details dialog box appears. On this dialog box:

      • (Optional) Choose View source to view the action's source code.

      • Choose Add to workflow to add the action to the workflow diagram and open its configuration pane.

  10. In the Inputs, Configuration, and Outputs tabs, complete the fields according to your needs. For a description of each field, see the "AWS CDK bootstrap" action YAML definition. This reference provides detailed information about each field (and corresponding YAML property value) as it appears in both the YAML and visual editors.

  11. (Optional) Choose Validate to validate the workflow's YAML code before committing.

  12. Choose Commit, enter a commit message, and then choose Commit again.

    Note

    If your AWS CDK bootstrap action fails with an npm install error, see How do I fix "npm install" errors? for information about how to fix the error.

YAML
To add the "AWS CDK bootstrap" action using the YAML editor
  1. Open the CodeCatalyst console at https://codecatalyst.aws/.

  2. Choose your project.

  3. In the navigation pane, choose CI/CD, and then choose Workflows.

  4. Choose the name of your workflow. You can filter by the source repository or branch name where the workflow is defined, or filter by workflow name.

  5. Choose Edit.

  6. Choose YAML.

  7. At the top-left, choose + Actions to open the action catalog.

  8. From the drop-down list, choose Amazon CodeCatalyst.

  9. Search for the AWS CDK bootstrap action, and choose + to add it to the workflow diagram and open its configuration pane.

  10. Modify the properties in the YAML code according to your needs. An explanation of each available property is provided in the "AWS CDK bootstrap" action YAML definition.

  11. (Optional) Choose Validate to validate the workflow's YAML code before committing.

  12. Choose Commit, enter a commit message, and then choose Commit again.

    Note

    If your AWS CDK bootstrap action fails with an npm install error, see How do I fix "npm install" errors? for information about how to fix the error.