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, execution_mode=None, pipeline_name=None, pipeline_type=None, restart_execution_on_update=None, reuse_cross_region_support_stacks=None, role=None, stages=None, triggers=None, variables=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 tofalse
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: false - false if the feature flagCODEPIPELINE_CROSS_ACCOUNT_KEYS_DEFAULT_VALUE_TO_FALSE
is true, true otherwisecross_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)execution_mode (
Optional
[ExecutionMode
]) – The method that the pipeline will use to handle multiple executions. Default: - ExecutionMode.SUPERSEDEDpipeline_name (
Optional
[str
]) – Name of the pipeline. Default: - AWS CloudFormation generates an ID and uses that for the pipeline name.pipeline_type (
Optional
[PipelineType
]) – Type of the pipeline. Default: - PipelineType.V2 if the feature flagCODEPIPELINE_DEFAULT_PIPELINE_TYPE_TO_V2
is true, PipelineType.V1 otherwiserestart_execution_on_update (
Optional
[bool
]) – Indicates whether to rerun the AWS CodePipeline pipeline after you update it. Default: falsereuse_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 callingPipeline#addStage
. Default: - None.triggers (
Optional
[Sequence
[Union
[TriggerProps
,Dict
[str
,Any
]]]]) – 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 whenpipelineType
is set toPipelineType.V2
. You can always add more triggers later by callingPipeline#addTrigger
. Default: - No triggersvariables (
Optional
[Sequence
[Variable
]]) – A list that defines the pipeline variables for a pipeline resource.variables
can only be used whenpipelineType
is set toPipelineType.V2
. You can always add more variables later by callingPipeline#addVariable
. Default: - No variables
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 callingIStage#addAction
.transition_disabled_reason (
Optional
[str
]) – The reason for disabling transition to this stage. Only applicable iftransitionToEnabled
is set tofalse
. Default: ‘Transition disabled’transition_to_enabled (
Optional
[bool
]) – Whether to enable transition to this stage. Default: true
- Return type:
- Returns:
the newly created Stage
- add_to_role_policy(statement)
Adds a statement to the pipeline role.
- Parameters:
statement (
PolicyStatement
) –- Return type:
None
- add_trigger(*, provider_type, git_configuration=None)
Adds a new Trigger to this Pipeline.
- Parameters:
provider_type (
ProviderType
) – The source provider for the event, such as connections configured for a repository with Git tags, for the specified trigger configuration.git_configuration (
Union
[GitConfiguration
,Dict
[str
,Any
],None
]) – Provides the filter criteria and the source stage for the repository event that starts the pipeline, such as Git tags. Default: - no configuration.
- Return type:
- Returns:
the newly created trigger
- add_variable(variable)
Adds a new Variable to this Pipeline.
- 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:
- notify_on(id, target, *, events, created_by=None, 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
andnotifyOnAnyManualApprovalStateChange
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.created_by (
Optional
[str
]) – The name or email alias of the person who created the notification rule. If not specified, it means that the creator’s alias is not provided. Default: - No alias provideddetail_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.FULLenabled (
Optional
[bool
]) – The status of the notification rule. If the enabled is set to DISABLED, notifications aren’t sent for the notification rule. Default: truenotification_rule_name (
Optional
[str
]) – The name for the notification rule. Notification rule names must be unique in your AWS account. Default: - generated from theid
- Return type:
- notify_on_any_action_state_change(id, target, *, created_by=None, 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
) –created_by (
Optional
[str
]) – The name or email alias of the person who created the notification rule. If not specified, it means that the creator’s alias is not provided. Default: - No alias provideddetail_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.FULLenabled (
Optional
[bool
]) – The status of the notification rule. If the enabled is set to DISABLED, notifications aren’t sent for the notification rule. Default: truenotification_rule_name (
Optional
[str
]) – The name for the notification rule. Notification rule names must be unique in your AWS account. Default: - generated from theid
- Return type:
- notify_on_any_manual_approval_state_change(id, target, *, created_by=None, 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
) –created_by (
Optional
[str
]) – The name or email alias of the person who created the notification rule. If not specified, it means that the creator’s alias is not provided. Default: - No alias provideddetail_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.FULLenabled (
Optional
[bool
]) – The status of the notification rule. If the enabled is set to DISABLED, notifications aren’t sent for the notification rule. Default: truenotification_rule_name (
Optional
[str
]) – The name for the notification rule. Notification rule names must be unique in your AWS account. Default: - generated from theid
- Return type:
- notify_on_any_stage_state_change(id, target, *, created_by=None, 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
) –created_by (
Optional
[str
]) – The name or email alias of the person who created the notification rule. If not specified, it means that the creator’s alias is not provided. Default: - No alias provideddetail_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.FULLenabled (
Optional
[bool
]) – The status of the notification rule. If the enabled is set to DISABLED, notifications aren’t sent for the notification rule. Default: truenotification_rule_name (
Optional
[str
]) – The name for the notification rule. Notification rule names must be unique in your AWS account. Default: - generated from theid
- Return type:
- notify_on_execution_state_change(id, target, *, created_by=None, 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
) –created_by (
Optional
[str
]) – The name or email alias of the person who created the notification rule. If not specified, it means that the creator’s alias is not provided. Default: - No alias provideddetail_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.FULLenabled (
Optional
[bool
]) – The status of the notification rule. If the enabled is set to DISABLED, notifications aren’t sent for the notification rule. Default: truenotification_rule_name (
Optional
[str
]) – The name for the notification rule. Notification rule names must be unique in your AWS account. Default: - generated from theid
- Return type:
- on_event(id, *, target=None, cross_stack_scope=None, description=None, event_pattern=None, rule_name=None)
Defines an event rule triggered by this CodePipeline.
- Parameters:
id (
str
) – Identifier for this event handler.target (
Optional
[IRuleTarget
]) – The target to register for the event. Default: - No target is added to the rule. UseaddTarget()
to add a target.cross_stack_scope (
Optional
[Construct
]) – The scope to use if the source of the rule and its target are in different Stacks (but in the same account & region). This helps dealing with cycles that often arise in these situations. Default: - none (the main scope will be used, even for cross-stack Events)description (
Optional
[str
]) – A description of the rule’s purpose. Default: - No descriptionevent_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.
- Return type:
- on_state_change(id, *, target=None, cross_stack_scope=None, description=None, event_pattern=None, rule_name=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.target (
Optional
[IRuleTarget
]) – The target to register for the event. Default: - No target is added to the rule. UseaddTarget()
to add a target.cross_stack_scope (
Optional
[Construct
]) – The scope to use if the source of the rule and its target are in different Stacks (but in the same account & region). This helps dealing with cycles that often arise in these situations. Default: - none (the main scope will be used, even for cross-stack Events)description (
Optional
[str
]) – A description of the rule’s purpose. Default: - No descriptionevent_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.
- Return type:
- stage(stage_name)
Access one of the pipeline’s stages by stage name.
- Parameters:
stage_name (
str
) –- Return type:
- 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 ``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 tree node.
- 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
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.
- classmethod is_construct(x)
Checks if
x
is a construct.Use this method instead of
instanceof
to properly detectConstruct
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 classConstruct
in each copy of theconstructs
library is seen as a different class, and an instance of one class will not test asinstanceof
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 theconstructs
library can be accidentally installed, andinstanceof
will behave unpredictably. It is safest to avoid usinginstanceof
, and using this type-testing method instead.- Parameters:
x (
Any
) – Any object.- Return type:
bool
- Returns:
true if
x
is an object created from a class which extendsConstruct
.
- classmethod is_owned_resource(construct)
Returns true if the construct was created by CDK, and false otherwise.
- Parameters:
construct (
IConstruct
) –- Return type:
bool
- classmethod is_resource(construct)
Check whether the given construct is a Resource.
- Parameters:
construct (
IConstruct
) –- Return type:
bool