Pipeline

class aws_cdk.aws_codepipeline.Pipeline(scope, id, *, artifact_bucket=None, cross_account_keys=None, cross_region_replication_buckets=None, enable_key_rotation=None, pipeline_name=None, restart_execution_on_update=None, reuse_cross_region_support_stacks=None, role=None, stages=None)

Bases: Resource

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

Example:

# 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
))
Parameters:
  • scope (Construct) –

  • id (str) –

  • artifact_bucket (Optional[IBucket]) – The S3 bucket used by this Pipeline to store artifacts. Default: - A new S3 bucket will be created.

  • cross_account_keys (Optional[bool]) – 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. Default: true

  • cross_region_replication_buckets (Optional[Mapping[str, IBucket]]) – 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. Default: - None.

  • enable_key_rotation (Optional[bool]) – 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. Default: - false (key rotation is disabled)

  • pipeline_name (Optional[str]) – Name of the pipeline. Default: - AWS CloudFormation generates an ID and uses that for the pipeline name.

  • restart_execution_on_update (Optional[bool]) – Indicates whether to rerun the AWS CodePipeline pipeline after you update it. Default: false

  • reuse_cross_region_support_stacks (Optional[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)

  • role (Optional[IRole]) – The IAM role to be assumed by this Pipeline. Default: a new IAM role will be created.

  • stages (Optional[Sequence[Union[StageProps, Dict[str, Any]]]]) – The list of Stages, in order, to create this Pipeline with. You can always add more Stages later by calling {@link Pipeline#addStage}. Default: - None.

Methods

add_stage(*, placement=None, stage_name, actions=None, transition_disabled_reason=None, transition_to_enabled=None)

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

Parameters:
  • placement (Union[StagePlacement, Dict[str, Any], None]) –

  • stage_name (str) – The physical, human-readable name to assign to this Pipeline Stage.

  • actions (Optional[Sequence[IAction]]) – The list of Actions to create this Stage with. You can always add more Actions later by calling {@link IStage#addAction}.

  • transition_disabled_reason (Optional[str]) – The reason for disabling transition to this stage. Only applicable if transitionToEnabled is set to false. Default: ‘Transition disabled’

  • transition_to_enabled (Optional[bool]) – Whether to enable transition to this stage. Default: true

Return type:

IStage

Returns:

the newly created Stage

add_to_role_policy(statement)

Adds a statement to the pipeline role.

Parameters:

statement (PolicyStatement) –

Return type:

None

apply_removal_policy(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).

Parameters:

policy (RemovalPolicy) –

Return type:

None

bind_as_notification_rule_source(_scope)

Returns a source configuration for notification rule.

Parameters:

_scope (Construct) –

Return type:

NotificationRuleSourceConfig

notify_on(id, target, *, events, detail_type=None, enabled=None, notification_rule_name=None)

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.

Parameters:
  • id (str) –

  • target (INotificationRuleTarget) –

  • events (Sequence[PipelineNotificationEvents]) – A list of event types associated with this notification rule for CodePipeline Pipeline. For a complete list of event types and IDs, see Notification concepts in the Developer Tools Console User Guide.

  • detail_type (Optional[DetailType]) – The level of detail to include in the notifications for this resource. BASIC will include only the contents of the event as it would appear in AWS CloudWatch. FULL will include any supplemental information provided by AWS CodeStar Notifications and/or the service for the resource for which the notification is created. Default: DetailType.FULL

  • enabled (Optional[bool]) – The status of the notification rule. If the enabled is set to DISABLED, notifications aren’t sent for the notification rule. Default: true

  • notification_rule_name (Optional[str]) – The name for the notification rule. Notification rule names must be unique in your AWS account. Default: - generated from the id

Return type:

INotificationRule

notify_on_any_action_state_change(id, target, *, detail_type=None, enabled=None, notification_rule_name=None)

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

Parameters:
  • id (str) –

  • target (INotificationRuleTarget) –

  • detail_type (Optional[DetailType]) – The level of detail to include in the notifications for this resource. BASIC will include only the contents of the event as it would appear in AWS CloudWatch. FULL will include any supplemental information provided by AWS CodeStar Notifications and/or the service for the resource for which the notification is created. Default: DetailType.FULL

  • enabled (Optional[bool]) – The status of the notification rule. If the enabled is set to DISABLED, notifications aren’t sent for the notification rule. Default: true

  • notification_rule_name (Optional[str]) – The name for the notification rule. Notification rule names must be unique in your AWS account. Default: - generated from the id

Return type:

INotificationRule

notify_on_any_manual_approval_state_change(id, target, *, detail_type=None, enabled=None, notification_rule_name=None)

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

Parameters:
  • id (str) –

  • target (INotificationRuleTarget) –

  • detail_type (Optional[DetailType]) – The level of detail to include in the notifications for this resource. BASIC will include only the contents of the event as it would appear in AWS CloudWatch. FULL will include any supplemental information provided by AWS CodeStar Notifications and/or the service for the resource for which the notification is created. Default: DetailType.FULL

  • enabled (Optional[bool]) – The status of the notification rule. If the enabled is set to DISABLED, notifications aren’t sent for the notification rule. Default: true

  • notification_rule_name (Optional[str]) – The name for the notification rule. Notification rule names must be unique in your AWS account. Default: - generated from the id

Return type:

INotificationRule

notify_on_any_stage_state_change(id, target, *, detail_type=None, enabled=None, notification_rule_name=None)

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

Parameters:
  • id (str) –

  • target (INotificationRuleTarget) –

  • detail_type (Optional[DetailType]) – The level of detail to include in the notifications for this resource. BASIC will include only the contents of the event as it would appear in AWS CloudWatch. FULL will include any supplemental information provided by AWS CodeStar Notifications and/or the service for the resource for which the notification is created. Default: DetailType.FULL

  • enabled (Optional[bool]) – The status of the notification rule. If the enabled is set to DISABLED, notifications aren’t sent for the notification rule. Default: true

  • notification_rule_name (Optional[str]) – The name for the notification rule. Notification rule names must be unique in your AWS account. Default: - generated from the id

Return type:

INotificationRule

notify_on_execution_state_change(id, target, *, detail_type=None, enabled=None, notification_rule_name=None)

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

Parameters:
  • id (str) –

  • target (INotificationRuleTarget) –

  • detail_type (Optional[DetailType]) – The level of detail to include in the notifications for this resource. BASIC will include only the contents of the event as it would appear in AWS CloudWatch. FULL will include any supplemental information provided by AWS CodeStar Notifications and/or the service for the resource for which the notification is created. Default: DetailType.FULL

  • enabled (Optional[bool]) – The status of the notification rule. If the enabled is set to DISABLED, notifications aren’t sent for the notification rule. Default: true

  • notification_rule_name (Optional[str]) – The name for the notification rule. Notification rule names must be unique in your AWS account. Default: - generated from the id

Return type:

INotificationRule

on_event(id, *, description=None, event_pattern=None, rule_name=None, target=None)

Defines an event rule triggered by this CodePipeline.

Parameters:
  • id (str) – Identifier for this event handler.

  • description (Optional[str]) – A description of the rule’s purpose. Default: - No description

  • event_pattern (Union[EventPattern, Dict[str, Any], None]) – Additional restrictions for the event to route to the specified target. The method that generates the rule probably imposes some type of event filtering. The filtering implied by what you pass here is added on top of that filtering. Default: - No additional filtering based on an event pattern.

  • rule_name (Optional[str]) – A name for the rule. Default: AWS CloudFormation generates a unique physical ID.

  • target (Optional[IRuleTarget]) – The target to register for the event. Default: - No target is added to the rule. Use addTarget() to add a target.

Return type:

Rule

on_state_change(id, *, description=None, event_pattern=None, rule_name=None, target=None)

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

Parameters:
  • id (str) – Identifier for this event handler.

  • description (Optional[str]) – A description of the rule’s purpose. Default: - No description

  • event_pattern (Union[EventPattern, Dict[str, Any], None]) – Additional restrictions for the event to route to the specified target. The method that generates the rule probably imposes some type of event filtering. The filtering implied by what you pass here is added on top of that filtering. Default: - No additional filtering based on an event pattern.

  • rule_name (Optional[str]) – A name for the rule. Default: AWS CloudFormation generates a unique physical ID.

  • target (Optional[IRuleTarget]) – The target to register for the event. Default: - No target is added to the rule. Use addTarget() to add a target.

Return type:

Rule

stage(stage_name)

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

Parameters:

stage_name (str) –

Return type:

IStage

to_string()

Returns a string representation of this construct.

Return type:

str

Attributes

artifact_bucket

Bucket used to store output artifacts.

cross_region_support

Returns all of the {@link CrossRegionSupportStack}s that were generated automatically when dealing with Actions that reside in a different region than the Pipeline itself.

env

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

The construct tree node associated with this construct.

pipeline_arn

ARN of this pipeline.

pipeline_name

The name of the pipeline.

pipeline_version

The version of the pipeline.

Attribute:

true

role

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

stack

The stack in which this resource is defined.

stage_count

Get the number of Stages in this Pipeline.

stages

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 {@link addStage} method if you want to add more stages to the pipeline.

Static Methods

classmethod from_pipeline_arn(scope, id, pipeline_arn)

Import a pipeline into this app.

Parameters:
  • scope (Construct) – the scope into which to import this pipeline.

  • id (str) – the logical ID of the returned pipeline construct.

  • pipeline_arn (str) – The ARN of the pipeline (e.g. arn:aws:codepipeline:us-east-1:123456789012:MyDemoPipeline).

Return type:

IPipeline

classmethod is_construct(x)

Return whether the given object is a Construct.

Parameters:

x (Any) –

Return type:

bool

classmethod is_resource(construct)

Check whether the given construct is a Resource.

Parameters:

construct (IConstruct) –

Return type:

bool