class CodePipeline (construct)
Language | Type name |
---|---|
.NET | Amazon.CDK.Pipelines.CodePipeline |
Java | software.amazon.awscdk.pipelines.CodePipeline |
Python | aws_cdk.pipelines.CodePipeline |
TypeScript (source) | @aws-cdk/pipelines » CodePipeline |
Implements
IConstruct
, IConstruct
, IDependable
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
// Modern API
const modernPipeline = new pipelines.CodePipeline(this, 'Pipeline', {
selfMutation: false,
synth: new pipelines.ShellStep('Synth', {
input: pipelines.CodePipelineSource.connection('my-org/my-app', 'main', {
connectionArn: 'arn:aws:codestar-connections:us-east-1:222222222222:connection/7d2469ff-514a-4e4f-9003-5ca4a43cdc41', // Created using the AWS console * });',
}),
commands: [
'npm ci',
'npm run build',
'npx cdk synth',
],
}),
});
// Original API
const cloudAssemblyArtifact = new codepipeline.Artifact();
const originalPipeline = new pipelines.CdkPipeline(this, 'Pipeline', {
selfMutating: false,
cloudAssemblyArtifact,
});
Initializer
new CodePipeline(scope: Construct, id: string, props: CodePipelineProps)
Parameters
- scope
Construct
- id
string
- props
Code
Pipeline Props
Construct Props
Name | Type | Description |
---|---|---|
synth | IFile | The build step that produces the CDK Cloud Assembly. |
asset | Code | Additional customizations to apply to the asset publishing CodeBuild projects. |
cli | string | CDK CLI version to use in self-mutation and asset publishing steps. |
code | Code | Customize the CodeBuild projects created for this pipeline. |
code | Pipeline | An existing Pipeline to be reused and built upon. |
cross | boolean | Create KMS keys for the artifact buckets, allowing cross-account deployments. |
docker | Docker [] | A list of credentials used to authenticate to Docker registries. |
docker | boolean | Enable Docker for the self-mutate step. |
docker | boolean | Enable Docker for the 'synth' step. |
pipeline | string | The name of the CodePipeline pipeline. |
publish | boolean | Publish assets in multiple CodeBuild projects. |
reuse | boolean | Reuse the same cross region support stack for all pipelines in the App. |
self | boolean | Whether the pipeline will update itself. |
self | Code | Additional customizations to apply to the self mutation CodeBuild projects. |
synth | Code | Additional customizations to apply to the synthesize CodeBuild projects. |
synth
Type:
IFile
The build step that produces the CDK Cloud Assembly.
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
.
assetPublishingCodeBuildDefaults?
Type:
Code
(optional, default: Only codeBuildDefaults
are applied)
Additional customizations to apply to the asset publishing CodeBuild projects.
cliVersion?
Type:
string
(optional, default: Latest version)
CDK CLI version to use in self-mutation and asset publishing steps.
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.
codeBuildDefaults?
Type:
Code
(optional, default: All projects run non-privileged build, SMALL instance, LinuxBuildImage.STANDARD_5_0)
Customize the CodeBuild projects created for this pipeline.
codePipeline?
Type:
Pipeline
(optional, default: a new underlying pipeline is created.)
An existing Pipeline to be reused and built upon.
[disable-awslint:ref-via-interface]
crossAccountKeys?
Type:
boolean
(optional, default: false)
Create KMS keys for the artifact buckets, allowing cross-account deployments.
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.
dockerCredentials?
Type:
Docker
[]
(optional, default: [])
A list of credentials used to authenticate to Docker registries.
Specify any credentials necessary within the pipeline to build, synth, update, or publish assets.
dockerEnabledForSelfMutation?
Type:
boolean
(optional, default: false)
Enable Docker for the self-mutate step.
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.
dockerEnabledForSynth?
Type:
boolean
(optional, default: false)
Enable Docker for the 'synth' step.
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/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.
pipelineName?
Type:
string
(optional, default: Automatically generated)
The name of the CodePipeline pipeline.
publishAssetsInParallel?
Type:
boolean
(optional, default: true)
Publish assets in multiple CodeBuild projects.
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.
reuseCrossRegionSupportStacks?
Type:
boolean
(optional, default: true (Use the same support stack for all pipelines in App))
Reuse the same cross region support stack for all pipelines in the App.
selfMutation?
Type:
boolean
(optional, default: true)
Whether the pipeline will update itself.
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
.
selfMutationCodeBuildDefaults?
Type:
Code
(optional, default: Only codeBuildDefaults
are applied)
Additional customizations to apply to the self mutation CodeBuild projects.
synthCodeBuildDefaults?
Type:
Code
(optional, default: Only codeBuildDefaults
are applied)
Additional customizations to apply to the synthesize CodeBuild projects.
Properties
Name | Type | Description |
---|---|---|
cloud | File | The FileSet tha contains the cloud assembly. |
node | Construct | The construct tree node associated with this construct. |
pipeline | Pipeline | The CodePipeline pipeline that deploys the CDK app. |
synth | IFile | The build step that produces the CDK Cloud Assembly. |
synth | IProject | The CodeBuild project that performs the Synth. |
waves | Wave [] | The waves in this pipeline. |
cloudAssemblyFileSet
Type:
File
The FileSet tha contains the cloud assembly.
This is the primary output of the synth step.
node
Type:
Construct
The construct tree node associated with this construct.
pipeline
Type:
Pipeline
The CodePipeline pipeline that deploys the CDK app.
Only available after the pipeline has been built.
synth
Type:
IFile
The build step that produces the CDK Cloud Assembly.
synthProject
Type:
IProject
The CodeBuild project that performs the Synth.
Only available after the pipeline has been built.
waves
Type:
Wave
[]
The waves in this pipeline.
Methods
Name | Description |
---|---|
add | Deploy a single Stage by itself. |
add | Add a Wave to the pipeline, for deploying multiple Stages in parallel. |
build | Send the current pipeline definition to the engine, and construct the pipeline. |
to | Returns a string representation of this construct. |
protected do | Implemented by subclasses to do the actual pipeline construction. |
addStage(stage, options?)
public addStage(stage: Stage, options?: AddStageOpts): StageDeployment
Parameters
- stage
Stage
- options
Add
Stage Opts
Returns
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, options?)
public addWave(id: string, options?: WaveOptions): Wave
Parameters
- id
string
- options
Wave
Options
Returns
Add a Wave to the pipeline, for deploying multiple Stages in parallel.
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()
public buildPipeline(): void
Send the current pipeline definition to the engine, and construct the pipeline.
It is not possible to modify the pipeline after calling this method.
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.
protected doBuildPipeline()
protected doBuildPipeline(): void
Implemented by subclasses to do the actual pipeline construction.