"AWS CDK deploy" action reference - Amazon CodeCatalyst

"AWS CDK deploy" action reference

The following is the action definition YAML reference for the AWS CDK deploy action. To learn how to use this action, see Adding the "AWS CDK deploy" action.

Note

Most of the YAML properties that follow have corresponding UI elements in the visual editor. To look up a UI element, use Ctrl+F. The element will be listed with its associated YAML property.

# The workflow definition starts here. # See Top-level properties for details. Name: MyWorkflow SchemaVersion: 1.0 Actions: # The action definition starts here. CDKDeploy_nn: Identifier: aws/cdk-deploy@v1 DependsOn: - CDKBootstrap Compute: - Type: EC2 | Lambda - Fleet: fleet-name Timeout: timeout-minutes Inputs: # Specify a source or an artifact, but not both. Sources: - source-name-1 Artifacts: - artifact-name Outputs: Artifacts: - Name: cdk_artifact Files: - "cdk.out/**/*" Environment: Name: environment-name Connections: - Name: account-connection-name Role: iam-role-name Configuration: StackName: my-cdk-stack Region: us-west-2 Tags: '{"key1": "value1", "key2": "value2"}' Context: '{"key1": "value1", "key2": "value2"}' CdkRootPath: directory/cdk.json CfnOutputVariables:'["CnfOutputKey1","CfnOutputKey2","CfnOutputKey3"]'

CDKDeploy

(Required)

Specify the name of the action. All action names must be unique. Action names are limited to alphanumeric characters (a-z, A-Z, 0-9), hyphens (-), and underscores (_). Spaces are not allowed. You cannot use quotation marks to enable special characters and spaces in action names.

Default: CDKDeploy_nn.

Corresponding UI: Configuration tab/Action name

Identifier

(CDKDeploy/Identifier)

(Required)

Identifies the action. Do not change this property.

Default: aws/cdk-deploy@v1.

Corresponding UI: Workflow diagram/CDKDeploy_nn/aws/cdk-deploy@v1 label

DependsOn

(CDKDeploy/DependsOn)

(Optional)

Specify an action or action group that must run successfully in order for the AWS CDK deploy action to run. We recommend specifying the AWS CDK bootstrap action in the DependsOn property, like this:

CDKDeploy: Identifier: aws/cdk-deploy@v1 DependsOn: - CDKBootstrap
Note

Bootstrapping is a mandatory prerequisite for deploying an AWS CDK app. If you do not include the AWS CDK Bootstrap action in your workflow, then you must find another way to deploy the AWS CDK bootstrap stack before running your AWS CDK deploy action. For more information, see Prerequisites in Adding the "AWS CDK deploy" action.

For more information about the 'depends on' functionality, see Configuring actions to depend on other actions.

Corresponding UI: Inputs tab/Depends on - optional

Compute

(CDKDeploy/Compute)

(Optional)

The computing engine used to run your workflow actions. You can specify compute either at the workflow level or at the action level, but not both. When specified at the workflow level, the compute configuration applies to all actions defined in the workflow. This compute is not shared however, as a separate compute is spun up for each action.

Corresponding UI: none

Type

(CDKDeploy/Compute/Type)

(Required if Compute is included)

The type of compute engine. You can use one of the following values:

  • EC2 (visual editor) or EC2 (YAML editor)

    Optimized for flexibility during action runs.

  • Lambda (visual editor) or Lambda (YAML editor)

    Optimized action start-up speeds.

For more information about compute types, see About compute types.

Corresponding UI: Configuration tab/Advanced - optional/Compute type

Fleet

(CDKDeploy/Compute/Fleet)

(Optional)

Specify the machine or fleet that will run your workflow or workflow actions. With on-demand fleets, when an action starts, the workflow provisions the resources it needs, and the machines are destroyed when the action finishes. Examples of on-demand fleets: Linux.x86-64.Large, Linux.x86-64.XLarge. For more information about on-demand fleets, see On-demand fleet properties.

With provisioned fleets, you configure a set of dedicated machines to run your workflow actions. These machines remain idle, ready to process actions immediately. For more information about provisioned fleets, see Provisioned fleet properties.

If Fleet is omitted, the default is Linux.x86-64.Large.

Corresponding UI: Configuration tab/Advanced - optional/Compute fleet

Timeout

(CDKDeploy/Timeout)

(Required)

Specify the amount of time in minutes (YAML editor), or hours and minutes (visual editor), that the action can run before CodeCatalyst ends the action. The minimum is 5 minutes and the maximum is 8 hours. The default is 8 hours (480 minutes).

Corresponding UI: Configuration tab/Timeout - optional

Inputs

(CDKDeploy/Inputs)

(Optional)

The Inputs section defines the data that the CDKDeploy needs during a workflow run.

Note

Only one input (either a source or an artifact) is allowed for each AWS CDK deploy action.

Corresponding UI: Inputs tab

Sources

(CDKDeploy/Inputs/Sources)

(Required if the AWS CDK app you want to deploy is stored in a source repository)

If your AWS CDK app is stored in a source repository, specify the label of that source repository. The AWS CDK deploy action synthesizes the app in this repository before starting the deployment process. Currently, the only supported label is WorkflowSource.

If your AWS CDK app is not contained within a source repository, it must reside in an artifact generated by another action.

For more information about sources, see Working with sources.

Corresponding UI: Inputs tab/Sources - optional

Artifacts - input

(CDKDeploy/Inputs/Artifacts)

(Required if the AWS CDK app you want to deploy is stored in an output artifact from a previous action)

If your AWS CDK app is contained in an artifact generated by a previous action, specify that artifact here. The AWS CDK deploy action synthesizes the app in the specified artifact into a CloudFormation template before starting the deployment process. If your AWS CDK app is not contained within an artifact, it must reside in your source repository.

For more information about artifacts, including examples, see Working with artifacts.

Corresponding UI: Inputs tab/Artifacts - optional

Outputs

(CDKDeploy/Outputs)

(Optional)

Defines the data that is output by the action during a workflow run.

Corresponding UI: Outputs tab

Artifacts - output

(CDKDeploy/Outputs/Artifacts

(Optional)

Specify the artifacts generated by the action. You can reference these artifacts as input in other actions.

For more information about artifacts, including examples, see Working with artifacts.

Corresponding UI: Outputs tab/Artifacts

Name

(CDKDeploy/Outputs/Artifacts/Name)

(Required if Artifacts - output is included)

Specify the name of the artifact that will contain the AWS CloudFormation template that is synthesized by the AWS CDK deploy action at runtime. The default value is cdk_artifact. If you do not specify an artifact, then the action synthesizes the template but won't save it in an artifact. Consider saving the synthesized template in an artifact to preserve a record of it for testing or troubleshooting purposes.

Corresponding UI: Outputs tab/Artifacts/Add artifact/Build artifact name

Files

(CDKDeploy/Outputs/Artifacts/Files)

(Required if Artifacts - output is included)

Specify the files to include in the artifact. You must specify "cdk.out/**/*" to include your AWS CDK app's synthesized AWS CloudFormation template.

Note

cdk.out is the default directory into which synthesized files are saved. If you specified an output directory other than cdk.out in your cdk.json file, specify that directory here instead of cdk.out.

Corresponding UI: Outputs tab/Artifacts/Add artifact/Files produced by build

Environment

(CDKDeploy/Environment)

(Required)

Specify the CodeCatalyst environment to use with the action.

For more information about environments, see Working with environments and Creating an environment.

Corresponding UI: Configuration tab/'Environment/account/role'/Environment

Name

(CDKDeploy/Environment/Name)

(Required)

Specify the name of an existing environment that you want to associate with the action.

Corresponding UI: Configuration tab/'Environment/account/role'/Environment

Connections

(CDKDeploy/Environment/Connections)

(Required)

Specify the account connection to associate with the action.

For more information about account connections, see Adding AWS accounts. For information about how to associate an account connection with your environment, see Creating an environment.

Corresponding UI: Configuration tab/'Environment/account/role'/AWS account connection

Name

(CDKDeploy/Environment/Connections/Name)

(Required)

Specify the name of the account connection.

Corresponding UI: Configuration tab/'Environment/account/role'/AWS account connection

Role

(CDKDeploy/Environment/Connections/Role)

(Required)

Specify the name of the IAM role that the AWS CDK deploy action uses to access AWS and deploy the AWS CDK application stack. Make sure that this role includes:

  • The following permissions policy:

    Warning

    Limit the permissions to those shown in the following policy. Using a role with broader permissions might pose a security risk.

    { "Version": "2012-10-17", "Statement": [ { "Sid": "VisualEditor0", "Effect": "Allow", "Action": [ "cloudformation:DescribeStackEvents", "cloudformation:DescribeChangeSet", "cloudformation:DescribeStacks", "cloudformation:ListStackResources" ], "Resource": "*" }, { "Sid": "VisualEditor1", "Effect": "Allow", "Action": "sts:AssumeRole", "Resource": "arn:aws:iam::aws-account:role/cdk-*" } ] }
  • The following custom trust policy:

    { "Version": "2012-10-17", "Statement": [ { "Sid": "", "Effect": "Allow", "Principal": { "Service": [ "codecatalyst-runner.amazonaws.com", "codecatalyst.amazonaws.com" ] }, "Action": "sts:AssumeRole" } ] }

Make sure that this role is added to your account connection. To learn more about adding an IAM role to an account connection, see Adding the codecatalyst-dev-admin-spaceName role or existing IAM roles to account connections.

Note

You can specify the name of the codecatalyst-dev-admin-spaceName role here, if you'd like. For more information about this role, see Creating the codecatalyst-dev-admin-spaceName role for your account and space. Understand that the codecatalyst-dev-admin-spaceName role has very broad permissions which may pose a security risk. We recommend that you only use this role in tutorials and scenarios where security is less of a concern.

Corresponding UI: Configuration tab/'Environment/account/role'/Role

Configuration

(CDKDeploy/Configuration)

(Required)

A section where you can define the configuration properties of the action.

Corresponding UI: Configuration tab

StackName

(CDKDeploy/Configuration/StackName)

(Required)

The name of your AWS CDK app stack, as it appears in the entrypoint file in your AWS CDK app's bin directory. The following example shows the contents of a TypeScript entrypoint file, with the stack name highlighted in red italics. If your entrypoint file is in a different language, it will look similar.

import * as cdk from 'aws-cdk-lib'; import { CdkWorksopTypescriptStack } from '../lib/cdk_workshop_typescript-stack'; const app = new cdk.App(); new CdkWorkshopTypescriptStack(app, 'CdkWorkshopTypescriptStack');

You can only specify one stack.

Tip

If you have multiple stacks, you can create a parent stack with nested stacks. You can then specify the parent stack in this action to deploy all stacks.

Corresponding UI: Configuration tab/Stack name

Region

(CDKDeploy/Configuration/Region)

(Required)

Specify the AWS Region into which the AWS CDK application stack will be deployed. For a list of Region codes, see Regional endpoints.

Corresponding UI: Configuration tab/Region

Tags

(CDKDeploy/Configuration/Tags)

(Optional)

Specify tags that you want to apply to the AWS resources in the AWS CDK application stack. Tags are applied to the stack itself as well as to individual resources in the stack. For more information about tagging, see Tagging in the AWS Cloud Development Kit (AWS CDK) Developer Guide.

Corresponding UI: Configuration tab/Advanced - optional/Tags

Context

(CDKDeploy/Configuration/Context)

(Optional)

Specify contexts, in the form of key-value pairs, to associate with the AWS CDK application stack. For more information about contexts, see Runtime contexts in the AWS Cloud Development Kit (AWS CDK) Developer Guide.

Corresponding UI: Configuration tab/Advanced - optional/Context

CdkRootPath

(CDKDeploy/Configuration/CdkRootPath)

(Optional)

The path to the directory that contains your AWS CDK project's cdk.json file. The AWS CDK deploy action runs from this folder, and any outputs created by the action will be added to this directory. If unspecified, the AWS CDK deploy action assumes that the cdk.json file is in the root of your AWS CDK project.

Corresponding UI: Configuration tab/Advanced - optional/Directory where the cdk.json resides

CfnOutputVariables

(CDKDeploy/Configuration/CfnOutputVariables)

(Optional)

Specify which CfnOutput constructs in your AWS CDK application code you want to expose as workflow output variables. You can then reference the workflow output variables in subsequent actions in your workflow. For more information about variables in CodeCatalyst, see Working with variables.

For example, if your AWS CDK application code looks like this:

import { Duration, Stack, StackProps, CfnOutput, RemovalPolicy} from 'aws-cdk-lib'; import * as dynamodb from 'aws-cdk-lib/aws-dynamodb'; import * as s3 from 'aws-cdk-lib/aws-s3'; import { Construct } from 'constructs'; import * as cdk from 'aws-cdk-lib'; export class HelloCdkStack extends Stack { constructor(scope: Construct, id: string, props?: StackProps) { super(scope, id, props); const bucket = new s3.Bucket(this, 'my-bucket', { removalPolicy: RemovalPolicy.DESTROY, }); new CfnOutput(this, 'bucketName', { value: bucket.bucketName, description: 'The name of the s3 bucket', exportName: 'myBucket', }); const table = new dynamodb.Table(this, 'todos-table', { partitionKey: {name: 'todoId', type: dynamodb.AttributeType.NUMBER}, billingMode: dynamodb.BillingMode.PAY_PER_REQUEST, removalPolicy: RemovalPolicy.DESTROY, }) new CfnOutput(this, 'tableName', { value: table.tableName, description: 'The name of the dynamodb table', exportName: 'myDynamoDbTable', }); ... } }

...and your CfnOutputVariables property looks like this:

Configuration: ... CfnOutputVariables: '["bucketname","tableName"]'

...then the action generates the following workflow output variables:

Key Value

bucketName

bucket.bucketName

tableName

table.tableName

You can then reference the bucketName and tableName variables in subsequent actions. To learn how to reference workflow output variables in subsequent actions, see Referencing a workflow output variable.

If you do not specify any CfnOutput constructs in the CfnOutputVariables property, then the action exposes the first four (or fewer) CloudFormation output variables it finds into workflow output variables. For more information, see "AWS CDK deploy" action output variables.

Tip

To obtain a list of all the CloudFormation output variables the action produces, run the workflow containing the AWS CDK deploy action once, and then look in the action's Logs tab. The logs contain a list of all the CloudFormation output variables associated with your AWS CDK app. Once you know what all the CloudFormation variables are, you can specify which ones you want to convert to workflow output variables using the CfnOutputVariables property.

For more information about AWS CloudFormation output variables, see the documentation for the CfnOutput construct, available at class CfnOutput (construct) in the AWS Cloud Development Kit (AWS CDK) API Reference.

Corresponding UI: Configuration tab/Advanced - optional/AWS CloudFormation output variables