class Pipeline (construct)
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.CodePipeline.Pipeline |
![]() | github.com/aws/aws-cdk-go/awscdk/v2/awscodepipeline#Pipeline |
![]() | software.amazon.awscdk.services.codepipeline.Pipeline |
![]() | aws_cdk.aws_codepipeline.Pipeline |
![]() | aws-cdk-lib » aws_codepipeline » Pipeline |
Implements
IConstruct
, IDependable
, IResource
, IPipeline
, INotification
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
Pipeline
Props
Construct Props
Name | Type | Description |
---|---|---|
artifact | IBucket | The S3 bucket used by this Pipeline to store artifacts. |
cross | boolean | Create KMS keys for cross-account deployments. |
cross | { [string]: IBucket } | A map of region to S3 bucket name used for cross-region CodePipeline. |
enable | boolean | Enable KMS key rotation for the generated KMS keys. |
execution | Execution | The method that the pipeline will use to handle multiple executions. |
pipeline | string | Name of the pipeline. |
pipeline | Pipeline | Type of the pipeline. |
restart | boolean | Indicates whether to rerun the AWS CodePipeline pipeline after you update it. |
reuse | boolean | Reuse the same cross region support stack for all pipelines in the App. |
role? | IRole | The IAM role to be assumed by this Pipeline. |
stages? | Stage [] | The list of Stages, in order, to create this Pipeline with. |
triggers? | Trigger [] | The trigger configuration specifying a type of event, such as Git tags, that starts the pipeline. |
variables? | Variable [] | A list that defines the pipeline variables for a pipeline resource. |
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: false - false if the feature flag CODEPIPELINE_CROSS_ACCOUNT_KEYS_DEFAULT_VALUE_TO_FALSE
is true, true otherwise)
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.
executionMode?
Type:
Execution
(optional, default: ExecutionMode.SUPERSEDED)
The method that the pipeline will use to handle multiple executions.
pipelineName?
Type:
string
(optional, default: AWS CloudFormation generates an ID and uses that for the pipeline name.)
Name of the pipeline.
pipelineType?
Type:
Pipeline
(optional, default: PipelineType.V2 if the feature flag CODEPIPELINE_DEFAULT_PIPELINE_TYPE_TO_V2
is true, PipelineType.V1 otherwise)
Type of the pipeline.
See also: https://docs.aws.amazon.com/codepipeline/latest/userguide/pipeline-types-planning.html
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:
Stage
[]
(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
.
triggers?
Type:
Trigger
[]
(optional, default: No triggers)
The trigger configuration specifying a type of event, such as Git tags, that starts the pipeline.
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
.
variables?
Type:
Variable
[]
(optional, default: No variables)
A list that defines the pipeline variables for a pipeline resource.
variables
can only be used when pipelineType
is set to PipelineType.V2
.
You can always add more variables later by calling Pipeline#addVariable
.
Properties
Name | Type | Description |
---|---|---|
artifact | IBucket | Bucket used to store output artifacts. |
cross | { [string]: Cross } | Returns all of the CrossRegionSupportStack s that were generated automatically when dealing with Actions that reside in a different region than the Pipeline itself. |
env | Resource | The environment this resource belongs to. |
node | Node | The tree node. |
pipeline | string | ARN of this pipeline. |
pipeline | string | The name of the pipeline. |
pipeline | string | The version of the pipeline. |
role | IRole | The IAM role AWS CodePipeline will use to perform actions or assume roles for actions with a more specific IAM role. |
stack | Stack | The stack in which this resource is defined. |
stage | number | Get the number of Stages in this Pipeline. |
stages | IStage [] | Returns the stages that comprise the pipeline. |
artifactBucket
Type:
IBucket
Bucket used to store output artifacts.
crossRegionSupport
Type:
{ [string]:
Cross
}
Returns all of the CrossRegionSupportStack
s that were generated automatically when dealing with Actions that reside in a different region than the Pipeline itself.
env
Type:
Resource
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
Name | Description |
---|---|
add | Creates a new Stage, and adds it to this Pipeline. |
add | Adds a statement to the pipeline role. |
add | Adds a new Trigger to this Pipeline. |
add | Adds a new Variable to this Pipeline. |
apply | Apply the given removal policy to this resource. |
bind | Returns a source configuration for notification rule. |
notify | Defines a CodeStar notification rule triggered when the pipeline events emitted by you specified, it very similar to onEvent API. |
notify | Define an notification rule triggered by the set of the "Action execution" events emitted from this pipeline. |
notify | Define an notification rule triggered by the set of the "Manual approval" events emitted from this pipeline. |
notify | Define an notification rule triggered by the set of the "Stage execution" events emitted from this pipeline. |
notify | Define an notification rule triggered by the set of the "Pipeline execution" events emitted from this pipeline. |
on | Defines an event rule triggered by this CodePipeline. |
on | 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. |
to | Returns a string representation of this construct. |
static from | Import a pipeline into this app. |
Stage(props)
addpublic addStage(props: StageOptions): IStage
Parameters
- props
Stage
— the creation properties of the new Stage.Options
Returns
Creates a new Stage, and adds it to this Pipeline.
ToRolePolicy(statement)
addpublic addToRolePolicy(statement: PolicyStatement): void
Parameters
- statement
Policy
Statement
Adds a statement to the pipeline role.
Trigger(props)
addpublic addTrigger(props: TriggerProps): Trigger
Parameters
- props
Trigger
— Trigger property to add to this Pipeline.Props
Returns
Adds a new Trigger to this Pipeline.
Variable(variable)
addpublic addVariable(variable: Variable): Variable
Parameters
- variable
Variable
— Variable instance to add to this Pipeline.
Returns
Adds a new Variable to this Pipeline.
RemovalPolicy(policy)
applypublic applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
Removal
Policy
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
).
AsNotificationRuleSource(_scope)
bindpublic bindAsNotificationRuleSource(_scope: Construct): NotificationRuleSourceConfig
Parameters
- _scope
Construct
Returns
Returns a source configuration for notification rule.
On(id, target, options)
notifypublic notifyOn(id: string, target: INotificationRuleTarget, options: PipelineNotifyOnOptions): INotificationRule
Parameters
- id
string
- target
INotification
Rule Target - options
Pipeline
Notify On Options
Returns
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.
OnAnyActionStateChange(id, target, options?)
notifypublic notifyOnAnyActionStateChange(id: string, target: INotificationRuleTarget, options?: NotificationRuleOptions): INotificationRule
Parameters
- id
string
- target
INotification
Rule Target - options
Notification
Rule Options
Returns
Define an notification rule triggered by the set of the "Action execution" events emitted from this pipeline.
OnAnyManualApprovalStateChange(id, target, options?)
notifypublic notifyOnAnyManualApprovalStateChange(id: string, target: INotificationRuleTarget, options?: NotificationRuleOptions): INotificationRule
Parameters
- id
string
- target
INotification
Rule Target - options
Notification
Rule Options
Returns
Define an notification rule triggered by the set of the "Manual approval" events emitted from this pipeline.
OnAnyStageStateChange(id, target, options?)
notifypublic notifyOnAnyStageStateChange(id: string, target: INotificationRuleTarget, options?: NotificationRuleOptions): INotificationRule
Parameters
- id
string
- target
INotification
Rule Target - options
Notification
Rule Options
Returns
Define an notification rule triggered by the set of the "Stage execution" events emitted from this pipeline.
OnExecutionStateChange(id, target, options?)
notifypublic notifyOnExecutionStateChange(id: string, target: INotificationRuleTarget, options?: NotificationRuleOptions): INotificationRule
Parameters
- id
string
- target
INotification
Rule Target - options
Notification
Rule Options
Returns
Define an notification rule triggered by the set of the "Pipeline execution" events emitted from this pipeline.
Event(id, options?)
onpublic onEvent(id: string, options?: OnEventOptions): Rule
Parameters
- id
string
— Identifier for this event handler. - options
On
— Additional options to pass to the event rule.Event Options
Returns
Defines an event rule triggered by this CodePipeline.
StateChange(id, options?)
onpublic onStateChange(id: string, options?: OnEventOptions): Rule
Parameters
- id
string
— Identifier for this event handler. - options
On
— Additional options to pass to the event rule.Event Options
Returns
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
Access one of the pipeline's stages by stage name.
String()
topublic toString(): string
Returns
string
Returns a string representation of this construct.
PipelineArn(scope, id, pipelineArn)
static frompublic 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
Import a pipeline into this app.