Skip to content
v2.274.0

CodePipeline ​

A CDK Pipeline that uses CodePipeline to deploy CDK apps.

This is a Pipeline with its engine property set to CodePipelineEngine, and exists for nicer ergonomics for users that don't need to switch out engines.

Example ​

ts
declare const codePipeline: codepipeline.Pipeline;

const sourceArtifact = new codepipeline.Artifact('MySourceArtifact');

const pipeline = new pipelines.CodePipeline(this, 'Pipeline', {
  codePipeline: codePipeline,
  synth: new pipelines.ShellStep('Synth', {
    input: pipelines.CodePipelineFileSet.fromArtifact(sourceArtifact),
    commands: ['npm ci', 'npm run build', 'npx cdk synth'],
  }),
});
python
# code_pipeline: codepipeline.Pipeline


source_artifact = codepipeline.Artifact("MySourceArtifact")

pipeline = pipelines.CodePipeline(self, "Pipeline",
    code_pipeline=code_pipeline,
    synth=pipelines.ShellStep("Synth",
        input=pipelines.CodePipelineFileSet.from_artifact(source_artifact),
        commands=["npm ci", "npm run build", "npx cdk synth"]
    )
)
java
Pipeline codePipeline;


Artifact sourceArtifact = new Artifact("MySourceArtifact");

CodePipeline pipeline = CodePipeline.Builder.create(this, "Pipeline")
        .codePipeline(codePipeline)
        .synth(ShellStep.Builder.create("Synth")
                .input(CodePipelineFileSet.fromArtifact(sourceArtifact))
                .commands(List.of("npm ci", "npm run build", "npx cdk synth"))
                .build())
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
Pipeline codePipeline;


var sourceArtifact = new Artifact("MySourceArtifact");

var pipeline = new CodePipeline(this, "Pipeline", new CodePipelineProps {
    CodePipeline = codePipeline,
    Synth = new ShellStep("Synth", new ShellStepProps {
        Input = CodePipelineFileSet.FromArtifact(sourceArtifact),
        Commands = new [] { "npm ci", "npm run build", "npx cdk synth" }
    })
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var codePipeline Pipeline


sourceArtifact := codepipeline.NewArtifact(jsii.String("MySourceArtifact"))

pipeline := pipelines.NewCodePipeline(this, jsii.String("Pipeline"), &CodePipelineProps{
	CodePipeline: codePipeline,
	Synth: pipelines.NewShellStep(jsii.String("Synth"), &ShellStepProps{
		Input: pipelines.CodePipelineFileSet_FromArtifact(sourceArtifact),
		Commands: []*string{
			jsii.String("npm ci"),
			jsii.String("npm run build"),
			jsii.String("npx cdk synth"),
		},
	}),
})

Initializer ​

ts
new CodePipeline(scope: Construct, id: string, props: CodePipelineProps)
python
CodePipeline(scope: Construct, id: str, props: CodePipelineProps)
java
new CodePipeline(Construct scope, String id, CodePipelineProps props)
csharp
new CodePipeline(Construct scope, string id, CodePipelineProps props)
go
NewCodePipeline(Scope Construct, Id *string, Props CodePipelineProps)

Construct Props ​

artifactBucketIBucketartifact_bucketIBucketartifactBucketIBucketArtifactBucketIBucketArtifactBucketIBucket= A new S3 bucket will be created.#
An existing S3 Bucket to use for storing the pipeline's artifact.
assetPublishingCodeBuildDefaultsCodeBuildOptionsasset_publishing_code_build_defaultsCodeBuildOptionsassetPublishingCodeBuildDefaultsCodeBuildOptionsAssetPublishingCodeBuildDefaultsCodeBuildOptionsAssetPublishingCodeBuildDefaultsCodeBuildOptions= Only `codeBuildDefaults` are app…#
Additional customizations to apply to the asset publishing CodeBuild projects.
default

Default: Only codeBuildDefaults are applied

cdkAssetsCliVersionstringcdk_assets_cli_versionstrcdkAssetsCliVersionStringCdkAssetsCliVersionstringCdkAssetsCliVersion*string= Latest version#
CDK CLI version to use in asset publishing steps.
notes

If you want to lock the cdk-assets version used in the pipeline, by steps that are automatically generated for you, specify the version here.

We recommend you do not specify this value, as not specifying it always uses the latest CLI version which is backwards compatible with old versions.

cliVersionstringcli_versionstrcliVersionStringCliVersionstringCliVersion*string= Latest version#
CDK CLI version to use in self-mutation step.
notes

If you want to lock the CDK CLI version used in the pipeline, by steps that are automatically generated for you, specify the version here.

We recommend you do not specify this value, as not specifying it always uses the latest CLI version which is backwards compatible with old versions.

If you do specify it, be aware that this version should always be equal to or higher than the version of the CDK framework used by the CDK app, when the CDK commands are run during your pipeline execution. When you change this version, the next time the SelfMutate step runs it will still be using the CLI of the the previous version that was in this property: it will only start using the new version after SelfMutate completes successfully. That means that if you want to update both framework and CLI version, you should update the CLI version first, commit, push and deploy, and only then update the framework version.

codeBuildDefaultsCodeBuildOptionscode_build_defaultsCodeBuildOptionscodeBuildDefaultsCodeBuildOptionsCodeBuildDefaultsCodeBuildOptionsCodeBuildDefaultsCodeBuildOptions= All projects run non-privileged …#
Customize the CodeBuild projects created for this pipeline.
default

Default: All projects run non-privileged build, SMALL instance, LinuxBuildImage.STANDARD_7_0

codePipelinePipelinecode_pipelinePipelinecodePipelinePipelineCodePipelinePipelineCodePipelinePipeline= a new underlying pipeline is cre…#
An existing Pipeline to be reused and built upon.

[disable-awslint:ref-via-interface]

default

Default: a new underlying pipeline is created.

crossAccountKeysbooleancross_account_keysboolcrossAccountKeysBooleanCrossAccountKeysboolCrossAccountKeys*bool= false#
Create KMS keys for the artifact buckets, allowing cross-account deployments.
notes

The artifact buckets have to be encrypted to support deploying CDK apps to another account, so if you want to do that or want to have your artifact buckets encrypted, be sure to set this value to true.

Be aware there is a cost associated with maintaining the KMS keys.

crossRegionReplicationBuckets{ [key: string]: IBucket }cross_region_replication_bucketstyping.Mapping[str, IBucket]crossRegionReplicationBucketsMap<String, IBucket>CrossRegionReplicationBucketsIDictionary<string, IBucket>CrossRegionReplicationBuckets*map[string]IBucket= no cross region replication buck…#
A map of region to S3 bucket name used for cross-region CodePipeline.
notes · default

For every Action that you specify targeting a different region than the Pipeline itself, if you don't provide an explicit Bucket for that region using this property, the construct will automatically create a Stack containing an S3 Bucket in that region. Passed directly through to the {@link cp.Pipeline}.

Default: no cross region replication buckets.

dockerCredentialsDockerCredential[]docker_credentialstyping.List[DockerCredential]dockerCredentialsList<DockerCredential>DockerCredentialsDockerCredential[]DockerCredentials*[]DockerCredential= []#
A list of credentials used to authenticate to Docker registries.

Specify any credentials necessary within the pipeline to build, synth, update, or publish assets.

dockerEnabledForSelfMutationbooleandocker_enabled_for_self_mutationbooldockerEnabledForSelfMutationBooleanDockerEnabledForSelfMutationboolDockerEnabledForSelfMutation*bool= false#
Enable Docker for the self-mutate step.
notes

Set this to true if the pipeline itself uses Docker container assets (for example, if you use LinuxBuildImage.fromAsset() as the build image of a CodeBuild step in the pipeline).

You do not need to set it if you build Docker image assets in the application Stages and Stacks that are deployed by this pipeline.

Configures privileged mode for the self-mutation CodeBuild action.

If you are about to turn this on in an already-deployed Pipeline, set the value to true first, commit and allow the pipeline to self-update, and only then use the Docker asset in the pipeline.

dockerEnabledForSynthbooleandocker_enabled_for_synthbooldockerEnabledForSynthBooleanDockerEnabledForSynthboolDockerEnabledForSynth*bool= false#
Enable Docker for the 'synth' step.
notes

Set this to true if you are using file assets that require "bundling" anywhere in your application (meaning an asset compilation step will be run with the tools provided by a Docker image), both for the Pipeline stack as well as the application stacks.

A common way to use bundling assets in your application is by using the aws-cdk-lib/aws-lambda-nodejs library.

Configures privileged mode for the synth CodeBuild action.

If you are about to turn this on in an already-deployed Pipeline, set the value to true first, commit and allow the pipeline to self-update, and only then use the bundled asset.

enableKeyRotationbooleanenable_key_rotationboolenableKeyRotationBooleanEnableKeyRotationboolEnableKeyRotation*bool= false (key rotation is disabled)#
Enable KMS key rotation for the generated KMS keys.

By default KMS key rotation is disabled, but will add additional costs when enabled.

executionModeExecutionModeexecution_modeExecutionModeexecutionModeExecutionModeExecutionModeExecutionModeExecutionModeExecutionMode= ExecutionMode.SUPERSEDED#
The method that the pipeline will use to handle multiple executions.

QUEUED and PARALLEL require pipelineType: PipelineType.V2.

pipelineNamestringpipeline_namestrpipelineNameStringPipelineNamestringPipelineName*string= Automatically generated#
The name of the CodePipeline pipeline.
pipelineTypePipelineTypepipeline_typePipelineTypepipelineTypePipelineTypePipelineTypePipelineTypePipelineTypePipelineType= PipelineType.V2 if the feature f…#
Type of the pipeline.
default

Default: PipelineType.V2 if the feature flag CODEPIPELINE_DEFAULT_PIPELINE_TYPE_TO_V2 is true, PipelineType.V1 otherwise

publishAssetsInParallelbooleanpublish_assets_in_parallelboolpublishAssetsInParallelBooleanPublishAssetsInParallelboolPublishAssetsInParallel*bool= true#
Publish assets in multiple CodeBuild projects.
notes

If set to false, use one Project per type to publish all assets.

Publishing in parallel improves concurrency and may reduce publishing latency, but may also increase overall provisioning time of the CodeBuild projects.

Experiment and see what value works best for you.

reuseCrossRegionSupportStacksbooleanreuse_cross_region_support_stacksboolreuseCrossRegionSupportStacksBooleanReuseCrossRegionSupportStacksboolReuseCrossRegionSupportStacks*bool= true (Use the same support stack…#
Reuse the same cross region support stack for all pipelines in the App.
default

Default: true (Use the same support stack for all pipelines in App)

roleIRoleroleIRoleroleIRoleRoleIRoleRoleIRole= A new role is created#
The IAM role to be assumed by this Pipeline.
selfMutationbooleanself_mutationboolselfMutationBooleanSelfMutationboolSelfMutation*bool= true#
Whether the pipeline will update itself.
notes

This needs to be set to true to allow the pipeline to reconfigure itself when assets or stages are being added to it, and true is the recommended setting.

You can temporarily set this to false while you are iterating on the pipeline itself and prefer to deploy changes using cdk deploy.

selfMutationCodeBuildDefaultsCodeBuildOptionsself_mutation_code_build_defaultsCodeBuildOptionsselfMutationCodeBuildDefaultsCodeBuildOptionsSelfMutationCodeBuildDefaultsCodeBuildOptionsSelfMutationCodeBuildDefaultsCodeBuildOptions= Only `codeBuildDefaults` are app…#
Additional customizations to apply to the self mutation CodeBuild projects.
default

Default: Only codeBuildDefaults are applied

The build step that produces the CDK Cloud Assembly.
notes

The primary output of this step needs to be the cdk.out directory generated by the cdk synth command.

If you use a ShellStep here and you don't configure an output directory, the output directory will automatically be assumed to be cdk.out.

synthCodeBuildDefaultsCodeBuildOptionssynth_code_build_defaultsCodeBuildOptionssynthCodeBuildDefaultsCodeBuildOptionsSynthCodeBuildDefaultsCodeBuildOptionsSynthCodeBuildDefaultsCodeBuildOptions= Only `codeBuildDefaults` are app…#
Additional customizations to apply to the synthesize CodeBuild projects.
default

Default: Only codeBuildDefaults are applied

useChangeSetsbooleanuse_change_setsbooluseChangeSetsBooleanUseChangeSetsboolUseChangeSets*bool= true#
Deploy every stack by creating a change set and executing it.

When enabled, creates a "Prepare" and "Execute" action for each stack. Disable to deploy the stack in one pipeline action.

usePipelineRoleForActionsbooleanuse_pipeline_role_for_actionsboolusePipelineRoleForActionsBooleanUsePipelineRoleForActionsboolUsePipelineRoleForActions*bool= false#
Use pipeline service role for actions if no action role configured.

Properties ​

cloudAssemblyFileSetFileSetcloud_assembly_file_setFileSetcloudAssemblyFileSetFileSetCloudAssemblyFileSetFileSetCloudAssemblyFileSetFileSetrequired#
The FileSet tha contains the cloud assembly.

This is the primary output of the synth step.

nodeNodenodeNodenodeNodeNodeNodeNodeNoderequired#
The tree node.
pipelinePipelinepipelinePipelinepipelinePipelinePipelinePipelinePipelinePipelinerequired#
The CodePipeline pipeline that deploys the CDK app.

Only available after the pipeline has been built.

selfMutationEnabledbooleanself_mutation_enabledboolselfMutationEnabledBooleanSelfMutationEnabledboolSelfMutationEnabled*boolrequired#
Whether SelfMutation is enabled for this CDK Pipeline.
selfMutationProjectIProjectself_mutation_projectIProjectselfMutationProjectIProjectSelfMutationProjectIProjectSelfMutationProjectIProjectrequired#
The CodeBuild project that performs the SelfMutation.

Will throw an error if this is accessed before buildPipeline() is called, or if selfMutation has been disabled.

The build step that produces the CDK Cloud Assembly.
synthProjectIProjectsynth_projectIProjectsynthProjectIProjectSynthProjectIProjectSynthProjectIProjectrequired#
The CodeBuild project that performs the Synth.

Only available after the pipeline has been built.

usePipelineRoleForActionsbooleanuse_pipeline_role_for_actionsboolusePipelineRoleForActionsBooleanUsePipelineRoleForActionsboolUsePipelineRoleForActions*boolrequired#
Allow pipeline service role used for actions if no action role configured instead of creating a new role for each action.
wavesWave[]wavestyping.List[Wave]wavesList<Wave>WavesWave[]Waves*[]Waverequired#
The waves in this pipeline.

Methods ​

addStage(stage: Stage, options?: AddStageOpts): StageDeploymentdef add_stage(self, stage: Stage, options: typing.Optional[AddStageOpts] = None) -> StageDeploymentpublic StageDeployment addStage(Stage stage, AddStageOpts options)public StageDeployment AddStage(Stage stage, AddStageOpts? options = null)func AddStage(Stage Stage, Options AddStageOpts) StageDeployment#
Deploy a single Stage by itself.

Add a Stage to the pipeline, to be deployed in sequence with other Stages added to the pipeline. All Stacks in the stage will be deployed in an order automatically determined by their relative dependencies.

addWave(id: string, options?: WaveOptions): Wavedef add_wave(self, id: str, options: typing.Optional[WaveOptions] = None) -> Wavepublic Wave addWave(String id, WaveOptions options)public Wave AddWave(string id, WaveOptions? options = null)func AddWave(Id *string, Options WaveOptions) Wave#
Add a Wave to the pipeline, for deploying multiple Stages in parallel.
notes

Use the return object of this method to deploy multiple stages in parallel.

Example:

ts
declare const pipeline: pipelines.CodePipeline;

const wave = pipeline.addWave('MyWave');
wave.addStage(new MyApplicationStage(this, 'Stage1'));
wave.addStage(new MyApplicationStage(this, 'Stage2'));
buildPipeline(): voiddef build_pipeline(self, ) -> Nonepublic void buildPipeline()public void BuildPipeline()func BuildPipeline()#
Send the current pipeline definition to the engine, and construct the pipeline.

It is not possible to modify the pipeline after calling this method.

isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#
Checks if `x` is a construct.
notes · 1 parameter · returns

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

Parameters

  • xxxxX — Any object.

Returns: true if x is an object created from a class which extends Construct.

isPipeline(x: any): boolean@staticmethod def is_pipeline(x: Any) -> boolpublic static Boolean isPipeline(Object x)public static bool IsPipeline(object x)func IsPipeline(X interface{}) *boolstatic#
Return whether the given object extends `PipelineBase`.

We do attribute detection since we can't reliably use 'instanceof'.

toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#
Returns a string representation of this construct.
with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#
Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

1 parameter · returns

Parameters

  • mixinsmixinsmixinsmixinsMixins — The mixins to apply.

Returns: This construct for chaining