Skip to content
v2.274.0

Pipeline L2 construct ​

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

Example ​

ts
// 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
python
# create a pipeline
import aws_cdk.aws_codecommit as codecommit

# add a source action to the stage
# repo: codecommit.Repository
# source_artifact: codepipeline.Artifact


pipeline = codepipeline.Pipeline(self, "Pipeline")

# add a stage
source_stage = pipeline.add_stage(stage_name="Source")
source_stage.add_action(codepipeline_actions.CodeCommitSourceAction(
    action_name="Source",
    output=source_artifact,
    repository=repo
))
java
// create a pipeline
import software.amazon.awscdk.services.codecommit.*;

// add a source action to the stage
Repository repo;
Artifact sourceArtifact;


Pipeline pipeline = new Pipeline(this, "Pipeline");

// add a stage
IStage sourceStage = pipeline.addStage(StageOptions.builder().stageName("Source").build());
sourceStage.addAction(CodeCommitSourceAction.Builder.create()
        .actionName("Source")
        .output(sourceArtifact)
        .repository(repo)
        .build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
// create a pipeline
using Amazon.CDK.AWS.CodeCommit;

// add a source action to the stage
Repository repo;
Artifact sourceArtifact;


var pipeline = new Pipeline(this, "Pipeline");

// add a stage
var sourceStage = pipeline.AddStage(new StageOptions { StageName = "Source" });
sourceStage.AddAction(new CodeCommitSourceAction(new CodeCommitSourceActionProps {
    ActionName = "Source",
    Output = sourceArtifact,
    Repository = repo
}));
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// create a pipeline
import codecommit "github.com/aws/aws-cdk-go/awscdk"

// add a source action to the stage
var repo Repository
var sourceArtifact Artifact


pipeline := codepipeline.NewPipeline(this, jsii.String("Pipeline"))

// add a stage
sourceStage := pipeline.AddStage(&StageOptions{
	StageName: jsii.String("Source"),
})
sourceStage.AddAction(codepipeline_actions.NewCodeCommitSourceAction(&CodeCommitSourceActionProps{
	ActionName: jsii.String("Source"),
	Output: sourceArtifact,
	Repository: repo,
}))

Initializer ​

ts
new Pipeline(scope: Construct, id: string, props?: PipelineProps)
python
Pipeline(scope: Construct, id: str, props: typing.Optional[PipelineProps] = None)
java
new Pipeline(Construct scope, String id, PipelineProps props)
csharp
new Pipeline(Construct scope, string id, PipelineProps? props = null)
go
NewPipeline(Scope Construct, Id *string, Props PipelineProps)

Construct Props ​

artifactBucketoptionalIBucketartifact_bucketoptionalIBucketartifactBucketoptionalIBucketArtifactBucketoptionalIBucketArtifactBucketoptionalIBucket#
The S3 bucket used by this Pipeline to store artifacts.

Default: A new S3 bucket will be created.

crossAccountKeysoptionalbooleancross_account_keysoptionalboolcrossAccountKeysoptionalBooleanCrossAccountKeysoptionalboolCrossAccountKeysoptional*bool#
Create KMS keys for cross-account deployments.

Default: false - false if the feature flag CODEPIPELINE_CROSS_ACCOUNT_KEYS_DEFAULT_VALUE_TO_FALSE is true, true otherwise

notes

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.

crossRegionReplicationBucketsoptional{ [key: string]: IBucket }cross_region_replication_bucketsoptionaltyping.Mapping[str, IBucket]crossRegionReplicationBucketsoptionalMap<String, IBucket>CrossRegionReplicationBucketsoptionalIDictionary<string, IBucket>CrossRegionReplicationBucketsoptional*map[string]IBucket= None.#
A map of region to S3 bucket name used for cross-region CodePipeline.
notes

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.

enableKeyRotationoptionalbooleanenable_key_rotationoptionalboolenableKeyRotationoptionalBooleanEnableKeyRotationoptionalboolEnableKeyRotationoptional*bool#
Enable KMS key rotation for the generated KMS keys.

Default: false (key rotation is disabled)

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

executionModeoptionalExecutionModeexecution_modeoptionalExecutionModeexecutionModeoptionalExecutionModeExecutionModeoptionalExecutionModeExecutionModeoptionalExecutionMode= ExecutionMode.SUPERSEDED#
The method that the pipeline will use to handle multiple executions.
pipelineNameoptionalstringpipeline_nameoptionalstrpipelineNameoptionalStringPipelineNameoptionalstringPipelineNameoptional*string#
Name of the pipeline.

Default: AWS CloudFormation generates an ID and uses that for the pipeline name.

pipelineTypeoptionalPipelineTypepipeline_typeoptionalPipelineTypepipelineTypeoptionalPipelineTypePipelineTypeoptionalPipelineTypePipelineTypeoptionalPipelineType#
Type of the pipeline.

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

restartExecutionOnUpdateoptionalbooleanrestart_execution_on_updateoptionalboolrestartExecutionOnUpdateoptionalBooleanRestartExecutionOnUpdateoptionalboolRestartExecutionOnUpdateoptional*bool= false#
Indicates whether to rerun the AWS CodePipeline pipeline after you update it.
reuseCrossRegionSupportStacksoptionalbooleanreuse_cross_region_support_stacksoptionalboolreuseCrossRegionSupportStacksoptionalBooleanReuseCrossRegionSupportStacksoptionalboolReuseCrossRegionSupportStacksoptional*bool#
Reuse the same cross region support stack for all pipelines in the App.

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

roleoptionalIRoleroleoptionalIRoleroleoptionalIRoleRoleoptionalIRoleRoleoptionalIRole#
The IAM role to be assumed by this Pipeline.

Default: a new IAM role will be created.

stagesoptionalStageProps[]stagesoptionaltyping.List[StageProps]stagesoptionalList<StageProps>StagesoptionalStageProps[]Stagesoptional*[]StageProps= None.#
The list of Stages, in order, to create this Pipeline with.

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

triggersoptionalTriggerProps[]triggersoptionaltyping.List[TriggerProps]triggersoptionalList<TriggerProps>TriggersoptionalTriggerProps[]Triggersoptional*[]TriggerProps#
The trigger configuration specifying a type of event, such as Git tags, that starts the pipeline.

Default: No triggers

notes

When a trigger configuration is specified, default change detection for repository and branch commits is disabled.

triggers can only be used when pipelineType is set to PipelineType.V2. You can always add more triggers later by calling Pipeline#addTrigger.

usePipelineRoleForActionsoptionalbooleanuse_pipeline_role_for_actionsoptionalboolusePipelineRoleForActionsoptionalBooleanUsePipelineRoleForActionsoptionalboolUsePipelineRoleForActionsoptional*bool= false#
Use pipeline service role for actions if no action role configured.
variablesoptionalVariable[]variablesoptionaltyping.List[Variable]variablesoptionalList<Variable>VariablesoptionalVariable[]Variablesoptional*[]Variable#
A list that defines the pipeline variables for a pipeline resource.

Default: No variables

variables can only be used when pipelineType is set to PipelineType.V2. You can always add more variables later by calling Pipeline#addVariable.

Properties ​

artifactBucketIBucketartifact_bucketIBucketartifactBucketIBucketArtifactBucketIBucketArtifactBucketIBucketrequired#
Bucket used to store output artifacts.
crossRegionSupport{ [key: string]: CrossRegionSupport }cross_region_supporttyping.Mapping[str, CrossRegionSupport]crossRegionSupportMap<String, CrossRegionSupport>CrossRegionSupportIDictionary<string, CrossRegionSupport>CrossRegionSupport*map[string]CrossRegionSupportrequired#
Returns all of the `CrossRegionSupportStack`s that were generated automatically when dealing with Actions that reside in a different region than the Pipeline itself.
The environment this resource belongs to.
notes

For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.

For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.

nodeNodenodeNodenodeNodeNodeNodeNodeNoderequired#
The tree node.
pipelineArnstringpipeline_arnstrpipelineArnStringPipelineArnstringPipelineArn*stringrequired#
ARN of this pipeline.
pipelineNamestringpipeline_namestrpipelineNameStringPipelineNamestringPipelineName*stringrequired#
The name of the pipeline.
pipelineRefPipelineReferencepipeline_refPipelineReferencepipelineRefPipelineReferencePipelineRefPipelineReferencePipelineRefPipelineReferencerequired#
A reference to a Pipeline resource.
pipelineVersionstringpipeline_versionstrpipelineVersionStringPipelineVersionstringPipelineVersion*stringrequired#
The version of the pipeline.
PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringrequiredstatic#
Uniquely identifies this class.
roleIRoleroleIRoleroleIRoleRoleIRoleRoleIRolerequired#
The IAM role AWS CodePipeline will use to perform actions or assume roles for actions with a more specific IAM role.
stackStackstackStackstackStackStackStackStackStackrequired#
The stack in which this resource is defined.
stageCountnumberstage_countint | floatstageCountNumberStageCountdoubleStageCount*float64required#
Get the number of Stages in this Pipeline.
stagesIStage[]stagestyping.List[IStage]stagesList<IStage>StagesIStage[]Stages*[]IStagerequired#
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 ​

addStage(props: StageOptions): IStagedef add_stage(self, props: StageOptions) -> IStagepublic IStage addStage(StageOptions props)public IStage AddStage(StageOptions props)func AddStage(Props StageOptions) IStage#
Creates a new Stage, and adds it to this Pipeline.
1 parameter · returns

Parameters

  • propspropspropspropsProps — the creation properties of the new Stage.

Returns: the newly created Stage

addToRolePolicy(statement: PolicyStatement): voiddef add_to_role_policy(self, statement: PolicyStatement) -> Nonepublic void addToRolePolicy(PolicyStatement statement)public void AddToRolePolicy(PolicyStatement statement)func AddToRolePolicy(Statement PolicyStatement)#
Adds a statement to the pipeline role.
addTrigger(props: TriggerProps): Triggerdef add_trigger(self, props: TriggerProps) -> Triggerpublic Trigger addTrigger(TriggerProps props)public Trigger AddTrigger(TriggerProps props)func AddTrigger(Props TriggerProps) Trigger#
Adds a new Trigger to this Pipeline.
1 parameter · returns

Parameters

  • propspropspropspropsProps — Trigger property to add to this Pipeline.

Returns: the newly created trigger

addVariable(variable: Variable): Variabledef add_variable(self, variable: Variable) -> Variablepublic Variable addVariable(Variable variable)public Variable AddVariable(Variable variable)func AddVariable(Variable Variable) Variable#
Adds a new Variable to this Pipeline.
1 parameter · returns

Parameters

  • variablevariablevariablevariableVariable — Variable instance to add to this Pipeline.

Returns: the newly created variable

applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#
Override the cross-stack reference strength for this resource.
notes · 1 parameter

When set, any cross-stack reference to this resource will use the specified mechanism instead of the global default determined by the @aws-cdk/core:defaultCrossStackReferences context key. This is useful for selectively weakening specific references to avoid the "deadly embrace" problem without changing the app-wide default.

Parameters

  • strengthstrengthstrengthstrengthStrength — - The reference strength to use for this resource.
applyRemovalPolicy(policy: RemovalPolicy): voiddef apply_removal_policy(self, policy: RemovalPolicy) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy)public void ApplyRemovalPolicy(RemovalPolicy policy)func ApplyRemovalPolicy(Policy RemovalPolicy)#
Apply the given removal policy to this resource.
notes

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: Construct): NotificationRuleSourceConfigdef bind_as_notification_rule_source(self, _scope: Construct) -> NotificationRuleSourceConfigpublic NotificationRuleSourceConfig bindAsNotificationRuleSource(Construct _scope)public NotificationRuleSourceConfig BindAsNotificationRuleSource(Construct _scope)func BindAsNotificationRuleSource(_scope Construct) NotificationRuleSourceConfig#
Returns a source configuration for notification rule.
fromPipelineArn(scope: Construct, id: string, pipelineArn: string): IPipeline@staticmethod def from_pipeline_arn(scope: Construct, id: str, pipeline_arn: str) -> IPipelinepublic static IPipeline fromPipelineArn(Construct scope, String id, String pipelineArn)public static IPipeline FromPipelineArn(Construct scope, string id, string pipelineArn)func FromPipelineArn(Scope Construct, Id *string, PipelineArn *string) IPipelinestatic#
Import a pipeline into this app.
3 parameters

Parameters

  • scopescopescopescopeScope — the scope into which to import this pipeline.
  • ididididId — the logical ID of the returned pipeline construct.
  • pipelineArnpipeline_arnpipelineArnpipelineArnPipelineArn — The ARN of the pipeline (e.g. arn:aws:codepipeline:us-east-1:123456789012:MyDemoPipeline).
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.

isOwnedResource(construct: IConstruct): boolean@staticmethod def is_owned_resource(construct: IConstruct) -> boolpublic static Boolean isOwnedResource(IConstruct construct)public static bool IsOwnedResource(IConstruct construct)func IsOwnedResource(Construct IConstruct) *boolstatic#
Returns true if the construct was created by CDK, and false otherwise.
isResource(construct: IConstruct): boolean@staticmethod def is_resource(construct: IConstruct) -> boolpublic static Boolean isResource(IConstruct construct)public static bool IsResource(IConstruct construct)func IsResource(Construct IConstruct) *boolstatic#
Check whether the given construct is a Resource.
notifyOn(id: string, target: INotificationRuleTarget, options: PipelineNotifyOnOptions): INotificationRuledef notify_on(self, id: str, target: INotificationRuleTarget, options: PipelineNotifyOnOptions) -> INotificationRulepublic INotificationRule notifyOn(String id, INotificationRuleTarget target, PipelineNotifyOnOptions options)public INotificationRule NotifyOn(string id, INotificationRuleTarget target, PipelineNotifyOnOptions options)func NotifyOn(Id *string, Target INotificationRuleTarget, Options PipelineNotifyOnOptions) 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: string, target: INotificationRuleTarget, options?: NotificationRuleOptions): INotificationRuledef notify_on_any_action_state_change(self, id: str, target: INotificationRuleTarget, options: typing.Optional[NotificationRuleOptions] = None) -> INotificationRulepublic INotificationRule notifyOnAnyActionStateChange(String id, INotificationRuleTarget target, NotificationRuleOptions options)public INotificationRule NotifyOnAnyActionStateChange(string id, INotificationRuleTarget target, NotificationRuleOptions? options = null)func NotifyOnAnyActionStateChange(Id *string, Target INotificationRuleTarget, Options NotificationRuleOptions) INotificationRule#
Define an notification rule triggered by the set of the "Action execution" events emitted from this pipeline.
notifyOnAnyManualApprovalStateChange(id: string, target: INotificationRuleTarget, options?: NotificationRuleOptions): INotificationRuledef notify_on_any_manual_approval_state_change(self, id: str, target: INotificationRuleTarget, options: typing.Optional[NotificationRuleOptions] = None) -> INotificationRulepublic INotificationRule notifyOnAnyManualApprovalStateChange(String id, INotificationRuleTarget target, NotificationRuleOptions options)public INotificationRule NotifyOnAnyManualApprovalStateChange(string id, INotificationRuleTarget target, NotificationRuleOptions? options = null)func NotifyOnAnyManualApprovalStateChange(Id *string, Target INotificationRuleTarget, Options NotificationRuleOptions) INotificationRule#
Define an notification rule triggered by the set of the "Manual approval" events emitted from this pipeline.
notifyOnAnyStageStateChange(id: string, target: INotificationRuleTarget, options?: NotificationRuleOptions): INotificationRuledef notify_on_any_stage_state_change(self, id: str, target: INotificationRuleTarget, options: typing.Optional[NotificationRuleOptions] = None) -> INotificationRulepublic INotificationRule notifyOnAnyStageStateChange(String id, INotificationRuleTarget target, NotificationRuleOptions options)public INotificationRule NotifyOnAnyStageStateChange(string id, INotificationRuleTarget target, NotificationRuleOptions? options = null)func NotifyOnAnyStageStateChange(Id *string, Target INotificationRuleTarget, Options NotificationRuleOptions) INotificationRule#
Define an notification rule triggered by the set of the "Stage execution" events emitted from this pipeline.
notifyOnExecutionStateChange(id: string, target: INotificationRuleTarget, options?: NotificationRuleOptions): INotificationRuledef notify_on_execution_state_change(self, id: str, target: INotificationRuleTarget, options: typing.Optional[NotificationRuleOptions] = None) -> INotificationRulepublic INotificationRule notifyOnExecutionStateChange(String id, INotificationRuleTarget target, NotificationRuleOptions options)public INotificationRule NotifyOnExecutionStateChange(string id, INotificationRuleTarget target, NotificationRuleOptions? options = null)func NotifyOnExecutionStateChange(Id *string, Target INotificationRuleTarget, Options NotificationRuleOptions) INotificationRule#
Define an notification rule triggered by the set of the "Pipeline execution" events emitted from this pipeline.
onEvent(id: string, options?: OnEventOptions): Ruledef on_event(self, id: str, options: typing.Optional[OnEventOptions] = None) -> Rulepublic Rule onEvent(String id, OnEventOptions options)public Rule OnEvent(string id, OnEventOptions? options = null)func OnEvent(Id *string, Options OnEventOptions) Rule#
Defines an event rule triggered by this CodePipeline.
2 parameters

Parameters

  • ididididId — Identifier for this event handler.
  • optionsoptionsoptionsoptionsOptions — Additional options to pass to the event rule.
onStateChange(id: string, options?: OnEventOptions): Ruledef on_state_change(self, id: str, options: typing.Optional[OnEventOptions] = None) -> Rulepublic Rule onStateChange(String id, OnEventOptions options)public Rule OnStateChange(string id, OnEventOptions? options = null)func OnStateChange(Id *string, Options OnEventOptions) Rule#
Defines an event rule triggered by the "CodePipeline Pipeline Execution State Change" event emitted from this pipeline.
2 parameters

Parameters

  • ididididId — Identifier for this event handler.
  • optionsoptionsoptionsoptionsOptions — Additional options to pass to the event rule.
stage(stageName: string): IStagedef stage(self, stage_name: str) -> IStagepublic IStage stage(String stageName)public IStage Stage(string stageName)func Stage(StageName *string) IStage#
Access one of the pipeline's stages by stage name.
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.