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
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'],
}),
});
# 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"]
)
)
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();
// 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" }
})
});
// 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
new CodePipeline(scope: Construct, id: string, props: CodePipelineProps)
CodePipeline(scope: Construct, id: str, props: CodePipelineProps)
new CodePipeline(Construct scope, String id, CodePipelineProps props)
new CodePipeline(Construct scope, string id, CodePipelineProps props)
NewCodePipeline(Scope Construct, Id *string, Props CodePipelineProps)
Construct Props
artifactBucketIBucketartifact_bucketIBucketartifactBucketIBucketArtifactBucketIBucketArtifactBucketIBucket= A new S3 bucket will be created.#assetPublishingCodeBuildDefaultsCodeBuildOptionsasset_publishing_code_build_defaultsCodeBuildOptionsassetPublishingCodeBuildDefaultsCodeBuildOptionsAssetPublishingCodeBuildDefaultsCodeBuildOptionsAssetPublishingCodeBuildDefaultsCodeBuildOptions= Only `codeBuildDefaults` are app…#default
Default: Only codeBuildDefaults are applied
cdkAssetsCliVersionstringcdk_assets_cli_versionstrcdkAssetsCliVersionStringCdkAssetsCliVersionstringCdkAssetsCliVersion*string= Latest version#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.
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 …#default
Default: All projects run non-privileged build, SMALL instance, LinuxBuildImage.STANDARD_7_0
codePipelinePipelinecode_pipelinePipelinecodePipelinePipelineCodePipelinePipelineCodePipelinePipeline= a new underlying pipeline is cre…#[disable-awslint:ref-via-interface]
default
Default: a new underlying pipeline is created.
crossAccountKeysbooleancross_account_keysboolcrossAccountKeysBooleanCrossAccountKeysboolCrossAccountKeys*bool= false#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…#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= []#Specify any credentials necessary within the pipeline to build, synth, update, or publish assets.
dockerEnabledForSelfMutationbooleandocker_enabled_for_self_mutationbooldockerEnabledForSelfMutationBooleanDockerEnabledForSelfMutationboolDockerEnabledForSelfMutation*bool= false#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#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)#By default KMS key rotation is disabled, but will add additional costs when enabled.
executionModeExecutionModeexecution_modeExecutionModeexecutionModeExecutionModeExecutionModeExecutionModeExecutionModeExecutionMode= ExecutionMode.SUPERSEDED#QUEUED and PARALLEL require pipelineType: PipelineType.V2.
pipelineNamestringpipeline_namestrpipelineNameStringPipelineNamestringPipelineName*string= Automatically generated#pipelineTypePipelineTypepipeline_typePipelineTypepipelineTypePipelineTypePipelineTypePipelineTypePipelineTypePipelineType= PipelineType.V2 if the feature f…#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#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…#default
Default: true (Use the same support stack for all pipelines in App)
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…#default
Default: Only codeBuildDefaults are applied
synthIFileSetProducersynthIFileSetProducersynthIFileSetProducerSynthIFileSetProducerSynthIFileSetProducerrequired#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…#default
Default: Only codeBuildDefaults are applied
useChangeSetsbooleanuse_change_setsbooluseChangeSetsBooleanUseChangeSetsboolUseChangeSets*bool= true#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#Properties
cloudAssemblyFileSetFileSetcloud_assembly_file_setFileSetcloudAssemblyFileSetFileSetCloudAssemblyFileSetFileSetCloudAssemblyFileSetFileSetrequired#This is the primary output of the synth step.
Only available after the pipeline has been built.
selfMutationEnabledbooleanself_mutation_enabledboolselfMutationEnabledBooleanSelfMutationEnabledboolSelfMutationEnabled*boolrequired#selfMutationProjectIProjectself_mutation_projectIProjectselfMutationProjectIProjectSelfMutationProjectIProjectSelfMutationProjectIProjectrequired#Will throw an error if this is accessed before buildPipeline() is called, or if selfMutation has been disabled.
synthIFileSetProducersynthIFileSetProducersynthIFileSetProducerSynthIFileSetProducerSynthIFileSetProducerrequired#synthProjectIProjectsynth_projectIProjectsynthProjectIProjectSynthProjectIProjectSynthProjectIProjectrequired#Only available after the pipeline has been built.
usePipelineRoleForActionsbooleanuse_pipeline_role_for_actionsboolusePipelineRoleForActionsBooleanUsePipelineRoleForActionsboolUsePipelineRoleForActions*boolrequired#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#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#notes
Use the return object of this method to deploy multiple stages in parallel.
Example:
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()#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#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#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#with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#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