aws-cdk-lib.aws_codepipeline.Pipeline

class Pipeline (construct)

LanguageType name
.NETAmazon.CDK.AWS.CodePipeline.Pipeline
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awscodepipeline#Pipeline
Javasoftware.amazon.awscdk.services.codepipeline.Pipeline
Pythonaws_cdk.aws_codepipeline.Pipeline
TypeScript (source)aws-cdk-lib » aws_codepipeline » Pipeline

Implements IConstruct, IDependable, IResource, IPipeline, INotificationRuleSource

An AWS CodePipeline pipeline with its associated IAM role and S3 bucket.

Example

// create a pipeline
import * as codecommit from 'aws-cdk-lib/aws-codecommit';

const pipeline = new codepipeline.Pipeline(this, 'Pipeline');

// add a stage
const sourceStage = pipeline.addStage({ stageName: 'Source' });

// add a source action to the stage
declare const repo: codecommit.Repository;
declare const sourceArtifact: codepipeline.Artifact;
sourceStage.addAction(new codepipeline_actions.CodeCommitSourceAction({
  actionName: 'Source',
  output: sourceArtifact,
  repository: repo,
}));

// ... add more stages

Initializer

new Pipeline(scope: Construct, id: string, props?: PipelineProps)

Parameters

  • scope Construct
  • id string
  • props PipelineProps

Construct Props

NameTypeDescription
artifactBucket?IBucketThe S3 bucket used by this Pipeline to store artifacts.
crossAccountKeys?booleanCreate KMS keys for cross-account deployments.
crossRegionReplicationBuckets?{ [string]: IBucket }A map of region to S3 bucket name used for cross-region CodePipeline.
enableKeyRotation?booleanEnable KMS key rotation for the generated KMS keys.
pipelineName?stringName of the pipeline.
restartExecutionOnUpdate?booleanIndicates whether to rerun the AWS CodePipeline pipeline after you update it.
reuseCrossRegionSupportStacks?booleanReuse the same cross region support stack for all pipelines in the App.
role?IRoleThe IAM role to be assumed by this Pipeline.
stages?StageProps[]The list of Stages, in order, to create this Pipeline with.

artifactBucket?

Type: IBucket (optional, default: A new S3 bucket will be created.)

The S3 bucket used by this Pipeline to store artifacts.


crossAccountKeys?

Type: boolean (optional, default: true)

Create KMS keys for cross-account deployments.

This controls whether the pipeline is enabled for cross-account deployments.

By default cross-account deployments are enabled, but this feature requires that KMS Customer Master Keys are created which have a cost of $1/month.

If you do not need cross-account deployments, you can set this to false to not create those keys and save on that cost (the artifact bucket will be encrypted with an AWS-managed key). However, cross-account deployments will no longer be possible.


crossRegionReplicationBuckets?

Type: { [string]: IBucket } (optional, default: None.)

A map of region to S3 bucket name used for cross-region CodePipeline.

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.


enableKeyRotation?

Type: boolean (optional, default: false (key rotation is disabled))

Enable KMS key rotation for the generated KMS keys.

By default KMS key rotation is disabled, but will add an additional $1/month for each year the key exists when enabled.


pipelineName?

Type: string (optional, default: AWS CloudFormation generates an ID and uses that for the pipeline name.)

Name of the pipeline.


restartExecutionOnUpdate?

Type: boolean (optional, default: false)

Indicates whether to rerun the AWS CodePipeline pipeline after you update it.


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.


role?

Type: IRole (optional, default: a new IAM role will be created.)

The IAM role to be assumed by this Pipeline.


stages?

Type: StageProps[] (optional, default: None.)

The list of Stages, in order, to create this Pipeline with.

You can always add more Stages later by calling Pipeline#addStage.

Properties

NameTypeDescription
artifactBucketIBucketBucket used to store output artifacts.
crossRegionSupport{ [string]: CrossRegionSupport }Returns all of the CrossRegionSupportStacks that were generated automatically when dealing with Actions that reside in a different region than the Pipeline itself.
envResourceEnvironmentThe environment this resource belongs to.
nodeNodeThe tree node.
pipelineArnstringARN of this pipeline.
pipelineNamestringThe name of the pipeline.
pipelineVersionstringThe version of the pipeline.
roleIRoleThe IAM role AWS CodePipeline will use to perform actions or assume roles for actions with a more specific IAM role.
stackStackThe stack in which this resource is defined.
stageCountnumberGet the number of Stages in this Pipeline.
stagesIStage[]Returns the stages that comprise the pipeline.

artifactBucket

Type: IBucket

Bucket used to store output artifacts.


crossRegionSupport

Type: { [string]: CrossRegionSupport }

Returns all of the CrossRegionSupportStacks that were generated automatically when dealing with Actions that reside in a different region than the Pipeline itself.


env

Type: ResourceEnvironment

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.


node

Type: Node

The tree node.


pipelineArn

Type: string

ARN of this pipeline.


pipelineName

Type: string

The name of the pipeline.


pipelineVersion

Type: string

The version of the pipeline.


role

Type: IRole

The IAM role AWS CodePipeline will use to perform actions or assume roles for actions with a more specific IAM role.


stack

Type: Stack

The stack in which this resource is defined.


stageCount

Type: number

Get the number of Stages in this Pipeline.


stages

Type: IStage[]

Returns the stages that comprise the pipeline.

Note: the returned array is a defensive copy, so adding elements to it has no effect. Instead, use the addStage method if you want to add more stages to the pipeline.

Methods

NameDescription
addStage(props)Creates a new Stage, and adds it to this Pipeline.
addToRolePolicy(statement)Adds a statement to the pipeline role.
applyRemovalPolicy(policy)Apply the given removal policy to this resource.
bindAsNotificationRuleSource(_scope)Returns a source configuration for notification rule.
notifyOn(id, target, options)Defines a CodeStar notification rule triggered when the pipeline events emitted by you specified, it very similar to onEvent API.
notifyOnAnyActionStateChange(id, target, options?)Define an notification rule triggered by the set of the "Action execution" events emitted from this pipeline.
notifyOnAnyManualApprovalStateChange(id, target, options?)Define an notification rule triggered by the set of the "Manual approval" events emitted from this pipeline.
notifyOnAnyStageStateChange(id, target, options?)Define an notification rule triggered by the set of the "Stage execution" events emitted from this pipeline.
notifyOnExecutionStateChange(id, target, options?)Define an notification rule triggered by the set of the "Pipeline execution" events emitted from this pipeline.
onEvent(id, options?)Defines an event rule triggered by this CodePipeline.
onStateChange(id, options?)Defines an event rule triggered by the "CodePipeline Pipeline Execution State Change" event emitted from this pipeline.
stage(stageName)Access one of the pipeline's stages by stage name.
toString()Returns a string representation of this construct.
static fromPipelineArn(scope, id, pipelineArn)Import a pipeline into this app.

addStage(props)

public addStage(props: StageOptions): IStage

Parameters

  • props StageOptions — the creation properties of the new Stage.

Returns

  • IStage

Creates a new Stage, and adds it to this Pipeline.


addToRolePolicy(statement)

public addToRolePolicy(statement: PolicyStatement): void

Parameters

  • statement PolicyStatement

Adds a statement to the pipeline role.


applyRemovalPolicy(policy)

public applyRemovalPolicy(policy: RemovalPolicy): void

Parameters

  • policy RemovalPolicy

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).


bindAsNotificationRuleSource(_scope)

public bindAsNotificationRuleSource(_scope: Construct): NotificationRuleSourceConfig

Parameters

  • _scope Construct

Returns

  • NotificationRuleSourceConfig

Returns a source configuration for notification rule.


notifyOn(id, target, options)

public notifyOn(id: string, target: INotificationRuleTarget, options: PipelineNotifyOnOptions): INotificationRule

Parameters

  • id string
  • target INotificationRuleTarget
  • options PipelineNotifyOnOptions

Returns

  • INotificationRule

Defines a CodeStar notification rule triggered when the pipeline events emitted by you specified, it very similar to onEvent API.

You can also use the methods notifyOnExecutionStateChange, notifyOnAnyStageStateChange, notifyOnAnyActionStateChange and notifyOnAnyManualApprovalStateChange to define rules for these specific event emitted.


notifyOnAnyActionStateChange(id, target, options?)

public notifyOnAnyActionStateChange(id: string, target: INotificationRuleTarget, options?: NotificationRuleOptions): INotificationRule

Parameters

  • id string
  • target INotificationRuleTarget
  • options NotificationRuleOptions

Returns

  • INotificationRule

Define an notification rule triggered by the set of the "Action execution" events emitted from this pipeline.


notifyOnAnyManualApprovalStateChange(id, target, options?)

public notifyOnAnyManualApprovalStateChange(id: string, target: INotificationRuleTarget, options?: NotificationRuleOptions): INotificationRule

Parameters

  • id string
  • target INotificationRuleTarget
  • options NotificationRuleOptions

Returns

  • INotificationRule

Define an notification rule triggered by the set of the "Manual approval" events emitted from this pipeline.


notifyOnAnyStageStateChange(id, target, options?)

public notifyOnAnyStageStateChange(id: string, target: INotificationRuleTarget, options?: NotificationRuleOptions): INotificationRule

Parameters

  • id string
  • target INotificationRuleTarget
  • options NotificationRuleOptions

Returns

  • INotificationRule

Define an notification rule triggered by the set of the "Stage execution" events emitted from this pipeline.


notifyOnExecutionStateChange(id, target, options?)

public notifyOnExecutionStateChange(id: string, target: INotificationRuleTarget, options?: NotificationRuleOptions): INotificationRule

Parameters

  • id string
  • target INotificationRuleTarget
  • options NotificationRuleOptions

Returns

  • INotificationRule

Define an notification rule triggered by the set of the "Pipeline execution" events emitted from this pipeline.


onEvent(id, options?)

public onEvent(id: string, options?: OnEventOptions): Rule

Parameters

  • id string — Identifier for this event handler.
  • options OnEventOptions — Additional options to pass to the event rule.

Returns

  • Rule

Defines an event rule triggered by this CodePipeline.


onStateChange(id, options?)

public onStateChange(id: string, options?: OnEventOptions): Rule

Parameters

  • id string — Identifier for this event handler.
  • options OnEventOptions — Additional options to pass to the event rule.

Returns

  • Rule

Defines an event rule triggered by the "CodePipeline Pipeline Execution State Change" event emitted from this pipeline.


stage(stageName)

public stage(stageName: string): IStage

Parameters

  • stageName string

Returns

  • IStage

Access one of the pipeline's stages by stage name.


toString()

public toString(): string

Returns

  • string

Returns a string representation of this construct.


static fromPipelineArn(scope, id, pipelineArn)

public static fromPipelineArn(scope: Construct, id: string, pipelineArn: string): IPipeline

Parameters

  • scope Construct — the scope into which to import this pipeline.
  • id string — the logical ID of the returned pipeline construct.
  • pipelineArn string — The ARN of the pipeline (e.g. arn:aws:codepipeline:us-east-1:123456789012:MyDemoPipeline).

Returns

  • IPipeline

Import a pipeline into this app.