Package software.amazon.awscdk.services.codepipeline
AWS CodePipeline Construct Library
Pipeline
To construct an empty Pipeline:
// Construct an empty Pipeline Pipeline pipeline = new Pipeline(this, "MyFirstPipeline");
To give the Pipeline a nice, human-readable name:
// Give the Pipeline a nice, human-readable name
Pipeline pipeline = Pipeline.Builder.create(this, "MyFirstPipeline")
.pipelineName("MyPipeline")
.build();
Be aware that in the default configuration, the Pipeline construct creates
an AWS Key Management Service (AWS KMS) Customer Master Key (CMK) for you to
encrypt the artifacts in the artifact bucket, which incurs a cost of
$1/month. This default configuration is necessary to allow cross-account
actions.
If you do not intend to perform cross-account deployments, you can disable
the creation of the Customer Master Keys by passing crossAccountKeys: false
when defining the Pipeline:
// Don't create Customer Master Keys
Pipeline pipeline = Pipeline.Builder.create(this, "MyFirstPipeline")
.crossAccountKeys(false)
.build();
If you want to enable key rotation for the generated KMS keys,
you can configure it by passing enableKeyRotation: true when creating the pipeline.
Note that key rotation will incur an additional cost of $1/month.
// Enable key rotation for the generated KMS key
Pipeline pipeline = Pipeline.Builder.create(this, "MyFirstPipeline")
// ...
.enableKeyRotation(true)
.build();
Stages
You can provide Stages when creating the Pipeline:
// Provide a Stage when creating a pipeline
Pipeline pipeline = Pipeline.Builder.create(this, "MyFirstPipeline")
.stages(List.of(StageProps.builder()
.stageName("Source")
.actions(List.of())
.build()))
.build();
Or append a Stage to an existing Pipeline:
// Append a Stage to an existing Pipeline
Pipeline pipeline;
IStage sourceStage = pipeline.addStage(StageOptions.builder()
.stageName("Source")
.actions(List.of())
.build());
You can insert the new Stage at an arbitrary point in the Pipeline:
// Insert a new Stage at an arbitrary point
Pipeline pipeline;
IStage anotherStage;
IStage yetAnotherStage;
IStage someStage = pipeline.addStage(StageOptions.builder()
.stageName("SomeStage")
.placement(StagePlacement.builder()
// note: you can only specify one of the below properties
.rightBefore(anotherStage)
.justAfter(yetAnotherStage)
.build())
.build());
You can disable transition to a Stage:
// Disable transition to a stage
Pipeline pipeline;
IStage someStage = pipeline.addStage(StageOptions.builder()
.stageName("SomeStage")
.transitionToEnabled(false)
.transitionDisabledReason("Manual transition only")
.build());
This is useful if you don't want every executions of the pipeline to flow into this stage automatically. The transition can then be "manually" enabled later on.
Actions
Actions live in a separate package, aws-cdk-lib/aws-codepipeline-actions.
To add an Action to a Stage, you can provide it when creating the Stage,
in the actions property,
or you can use the IStage.addAction() method to mutate an existing Stage:
// Use the `IStage.addAction()` method to mutate an existing Stage. IStage sourceStage; Action someAction; sourceStage.addAction(someAction);
Custom Action Registration
To make your own custom CodePipeline Action requires registering the action provider. Look to the JenkinsProvider in aws-cdk-lib/aws-codepipeline-actions for an implementation example.
// Make a custom CodePipeline Action
// Make a custom CodePipeline Action
CustomActionRegistration.Builder.create(this, "GenericGitSourceProviderResource")
.category(ActionCategory.SOURCE)
.artifactBounds(ActionArtifactBounds.builder().minInputs(0).maxInputs(0).minOutputs(1).maxOutputs(1).build())
.provider("GenericGitSource")
.version("1")
.entityUrl("https://docs.aws.amazon.com/codepipeline/latest/userguide/actions-create-custom-action.html")
.executionUrl("https://docs.aws.amazon.com/codepipeline/latest/userguide/actions-create-custom-action.html")
.actionProperties(List.of(CustomActionProperty.builder()
.name("Branch")
.required(true)
.key(false)
.secret(false)
.queryable(false)
.description("Git branch to pull")
.type("String")
.build(), CustomActionProperty.builder()
.name("GitUrl")
.required(true)
.key(false)
.secret(false)
.queryable(false)
.description("SSH git clone URL")
.type("String")
.build()))
.build();
Cross-account CodePipelines
Cross-account Pipeline actions require that the Pipeline has not been created with
crossAccountKeys: false.
Most pipeline Actions accept an AWS resource object to operate on. For example:
S3DeployActionaccepts ans3.IBucket.CodeBuildActionaccepts acodebuild.IProject.- etc.
These resources can be either newly defined (new s3.Bucket(...)) or imported
(s3.Bucket.fromBucketAttributes(...)) and identify the resource that should
be changed.
These resources can be in different accounts than the pipeline itself. For example, the following action deploys to an imported S3 bucket from a different account:
// Deploy an imported S3 bucket from a different account
IStage stage;
Artifact input;
stage.addAction(S3DeployAction.Builder.create()
.bucket(Bucket.fromBucketAttributes(this, "Bucket", BucketAttributes.builder()
.account("123456789012")
.build()))
.input(input)
.actionName("s3-deploy-action")
.build());
Actions that don't accept a resource object accept an explicit account parameter:
// Actions that don't accept a resource objet accept an explicit `account` parameter
IStage stage;
ArtifactPath templatePath;
stage.addAction(CloudFormationCreateUpdateStackAction.Builder.create()
.account("123456789012")
.templatePath(templatePath)
.adminPermissions(false)
.stackName(Stack.of(this).getStackName())
.actionName("cloudformation-create-update")
.build());
The Pipeline construct automatically defines an IAM Role for you in the
target account which the pipeline will assume to perform that action. This
Role will be defined in a support stack named
<PipelineStackName>-support-<account>, that will automatically be deployed
before the stack containing the pipeline.
If you do not want to use the generated role, you can also explicitly pass a
role when creating the action. In that case, the action will operate in the
account the role belongs to:
// Explicitly pass in a `role` when creating an action.
IStage stage;
ArtifactPath templatePath;
stage.addAction(CloudFormationCreateUpdateStackAction.Builder.create()
.templatePath(templatePath)
.adminPermissions(false)
.stackName(Stack.of(this).getStackName())
.actionName("cloudformation-create-update")
// ...
.role(Role.fromRoleArn(this, "ActionRole", "..."))
.build());
Cross-region CodePipelines
Similar to how you set up a cross-account Action, the AWS resource object you pass to actions can also be in different Regions. For example, the following Action deploys to an imported S3 bucket from a different Region:
// Deploy to an imported S3 bucket from a different Region.
IStage stage;
Artifact input;
stage.addAction(S3DeployAction.Builder.create()
.bucket(Bucket.fromBucketAttributes(this, "Bucket", BucketAttributes.builder()
.region("us-west-1")
.build()))
.input(input)
.actionName("s3-deploy-action")
.build());
Actions that don't take an AWS resource will accept an explicit region
parameter:
// Actions that don't take an AWS resource will accept an explicit `region` parameter.
IStage stage;
ArtifactPath templatePath;
stage.addAction(CloudFormationCreateUpdateStackAction.Builder.create()
.templatePath(templatePath)
.adminPermissions(false)
.stackName(Stack.of(this).getStackName())
.actionName("cloudformation-create-update")
// ...
.region("us-west-1")
.build());
The Pipeline construct automatically defines a replication bucket for
you in the target region, which the pipeline will replicate artifacts to and
from. This Bucket will be defined in a support stack named
<PipelineStackName>-support-<region>, that will automatically be deployed
before the stack containing the pipeline.
If you don't want to use these support stacks, and already have buckets in
place to serve as replication buckets, you can supply these at Pipeline definition
time using the crossRegionReplicationBuckets parameter. Example:
// Supply replication buckets for the Pipeline instead of using the generated support stack
Pipeline pipeline = Pipeline.Builder.create(this, "MyFirstPipeline")
// ...
.crossRegionReplicationBuckets(Map.of(
// note that a physical name of the replication Bucket must be known at synthesis time
"us-west-1", Bucket.fromBucketAttributes(this, "UsWest1ReplicationBucket", BucketAttributes.builder()
.bucketName("amzn-s3-demo-bucket")
// optional KMS key
.encryptionKey(Key.fromKeyArn(this, "UsWest1ReplicationKey", "arn:aws:kms:us-west-1:123456789012:key/1234-5678-9012"))
.build())))
.build();
See the AWS docs here for more information on cross-region CodePipelines.
Creating an encrypted replication bucket
If you're passing a replication bucket created in a different stack, like this:
// Passing a replication bucket created in a different stack.
App app = new App();
Stack replicationStack = Stack.Builder.create(app, "ReplicationStack")
.env(Environment.builder()
.region("us-west-1")
.build())
.build();
Key key = new Key(replicationStack, "ReplicationKey");
Bucket replicationBucket = Bucket.Builder.create(replicationStack, "ReplicationBucket")
// like was said above - replication buckets need a set physical name
.bucketName(PhysicalName.GENERATE_IF_NEEDED)
.encryptionKey(key)
.build();
// later...
// later...
Pipeline.Builder.create(replicationStack, "Pipeline")
.crossRegionReplicationBuckets(Map.of(
"us-west-1", replicationBucket))
.build();
When trying to encrypt it (and note that if any of the cross-region actions happen to be cross-account as well, the bucket has to be encrypted - otherwise the pipeline will fail at runtime), you cannot use a key directly - KMS keys don't have physical names, and so you can't reference them across environments.
In this case, you need to use an alias in place of the key when creating the bucket:
// Passing an encrypted replication bucket created in a different stack.
App app = new App();
Stack replicationStack = Stack.Builder.create(app, "ReplicationStack")
.env(Environment.builder()
.region("us-west-1")
.build())
.build();
Key key = new Key(replicationStack, "ReplicationKey");
Alias alias = Alias.Builder.create(replicationStack, "ReplicationAlias")
// aliasName is required
.aliasName(PhysicalName.GENERATE_IF_NEEDED)
.targetKey(key)
.build();
Bucket replicationBucket = Bucket.Builder.create(replicationStack, "ReplicationBucket")
.bucketName(PhysicalName.GENERATE_IF_NEEDED)
.encryptionKey(alias)
.build();
Variables
Variables are key-value pairs that can be used to dynamically configure actions in your pipeline.
There are two types of variables, Action-level variables and Pipeline-level variables. Action-level variables are produced when an action is executed. Pipeline-level variables are defined when the pipeline is created and resolved at pipeline run time. You specify the Pipeline-level variables when the pipeline is created, and you can provide values at the time of the pipeline execution.
Action-level variables
The library supports action-level variables.
Each action class that emits variables has a separate variables interface,
accessed as a property of the action instance called variables.
You instantiate the action class and assign it to a local variable;
when you want to use a variable in the configuration of a different action,
you access the appropriate property of the interface returned from variables,
which represents a single variable.
Example:
// MyAction is some action type that produces variables, like EcrSourceAction
MyAction myAction = new MyAction(new MyActionProps()
// ...
.actionName("myAction")
);
new OtherAction(new OtherActionProps()
// ...
.config(myAction.getVariables().getMyVariable())
.actionName("otherAction")
);
The namespace name that will be used will be automatically generated by the pipeline construct, based on the stage and action name; you can pass a custom name when creating the action instance:
// MyAction is some action type that produces variables, like EcrSourceAction
MyAction myAction = new MyAction(new MyActionProps()
// ...
.variablesNamespace("MyNamespace")
.actionName("myAction")
);
There are also global variables available,
not tied to any action;
these are accessed through static properties of the GlobalVariables class:
// OtherAction is some action type that produces variables, like EcrSourceAction
// OtherAction is some action type that produces variables, like EcrSourceAction
new OtherAction(new OtherActionProps()
// ...
.config(GlobalVariables.executionId)
.actionName("otherAction")
);
The following is an actual code example.
S3SourceAction sourceAction;
Artifact sourceOutput;
Bucket deployBucket;
Pipeline.Builder.create(this, "Pipeline")
.stages(List.of(StageProps.builder()
.stageName("Source")
.actions(List.of(sourceAction))
.build(), StageProps.builder()
.stageName("Deploy")
.actions(List.of(
S3DeployAction.Builder.create()
.actionName("DeployAction")
// can reference the variables
.objectKey(String.format("%s.txt", sourceAction.getVariables().getVersionId()))
.input(sourceOutput)
.bucket(deployBucket)
.build()))
.build()))
.build();
Check the documentation of the aws-cdk-lib/aws-codepipeline-actions
for details on how to use the variables for each action class.
See the CodePipeline documentation for more details on how to use the variables feature.
Pipeline-level variables
You can add one or more variables at the pipeline level. You can reference this value in the configuration of CodePipeline actions. You can add the variable names, default values, and descriptions when you create the pipeline. Variables are resolved at the time of execution.
Note that using pipeline-level variables in any kind of Source action is not supported. Also, the variables can only be used with pipeline type V2.
S3SourceAction sourceAction;
Artifact sourceOutput;
Bucket deployBucket;
// Pipeline-level variable
Variable variable = Variable.Builder.create()
.variableName("bucket-var")
.description("description")
.defaultValue("sample")
.build();
Pipeline.Builder.create(this, "Pipeline")
.pipelineType(PipelineType.V2)
.variables(List.of(variable))
.stages(List.of(StageProps.builder()
.stageName("Source")
.actions(List.of(sourceAction))
.build(), StageProps.builder()
.stageName("Deploy")
.actions(List.of(
S3DeployAction.Builder.create()
.actionName("DeployAction")
// can reference the variables
.objectKey(String.format("%s.txt", variable.reference()))
.input(sourceOutput)
.bucket(deployBucket)
.build()))
.build()))
.build();
Or append a variable to an existing pipeline:
Pipeline pipeline;
Variable variable = Variable.Builder.create()
.variableName("bucket-var")
.description("description")
.defaultValue("sample")
.build();
pipeline.addVariable(variable);
Events
Using a pipeline as an event target
A pipeline can be used as a target for a CloudWatch event rule:
// A pipeline being used as a target for a CloudWatch event rule.
import software.amazon.awscdk.services.events.targets.*;
import software.amazon.awscdk.services.events.*;
Pipeline pipeline;
// kick off the pipeline every day
Rule rule = Rule.Builder.create(this, "Daily")
.schedule(Schedule.rate(Duration.days(1)))
.build();
rule.addTarget(new CodePipeline(pipeline));
When a pipeline is used as an event target, the "codepipeline:StartPipelineExecution" permission is granted to the AWS CloudWatch Events service.
Event sources
Pipelines emit CloudWatch events. To define event rules for events emitted by
the pipeline, stages or action, use the onXxx methods on the respective
construct:
// Define event rules for events emitted by the pipeline
import software.amazon.awscdk.services.events.*;
Pipeline myPipeline;
IStage myStage;
Action myAction;
IRuleTarget target;
myPipeline.onStateChange("MyPipelineStateChange", OnEventOptions.builder().target(target).build());
myStage.onStateChange("MyStageStateChange", target);
myAction.onStateChange("MyActionStateChange", target);
CodeStar Notifications
To define CodeStar Notification rules for Pipelines, use one of the notifyOnXxx() methods.
They are very similar to onXxx() methods for CloudWatch events:
// Define CodeStar Notification rules for Pipelines
import software.amazon.awscdk.services.chatbot.*;
Pipeline pipeline;
SlackChannelConfiguration target = SlackChannelConfiguration.Builder.create(this, "MySlackChannel")
.slackChannelConfigurationName("YOUR_CHANNEL_NAME")
.slackWorkspaceId("YOUR_SLACK_WORKSPACE_ID")
.slackChannelId("YOUR_SLACK_CHANNEL_ID")
.build();
INotificationRule rule = pipeline.notifyOnExecutionStateChange("NotifyOnExecutionStateChange", target);
Trigger
To trigger a pipeline with Git tags or branches, specify the triggers property.
The triggers can only be used with pipeline type V2.
Push filter
Pipelines can be started based on push events. You can specify the pushFilter property to
filter the push events. The pushFilter can specify Git tags and branches.
In the case of Git tags, your pipeline starts when a Git tag is pushed.
You can filter with glob patterns. The tagsExcludes takes priority over the tagsIncludes.
CodeStarConnectionsSourceAction sourceAction;
CodeBuildAction buildAction;
Pipeline.Builder.create(this, "Pipeline")
.pipelineType(PipelineType.V2)
.stages(List.of(StageProps.builder()
.stageName("Source")
.actions(List.of(sourceAction))
.build(), StageProps.builder()
.stageName("Build")
.actions(List.of(buildAction))
.build()))
.triggers(List.of(TriggerProps.builder()
.providerType(ProviderType.CODE_STAR_SOURCE_CONNECTION)
.gitConfiguration(GitConfiguration.builder()
.sourceAction(sourceAction)
.pushFilter(List.of(GitPushFilter.builder()
.tagsExcludes(List.of("exclude1", "exclude2"))
.tagsIncludes(List.of("include*"))
.build()))
.build())
.build()))
.build();
In the case of branches, your pipeline starts when a commit is pushed on the specified branches.
You can filter with glob patterns. The branchesExcludes takes priority over the branchesIncludes.
CodeStarConnectionsSourceAction sourceAction;
CodeBuildAction buildAction;
Pipeline.Builder.create(this, "Pipeline")
.pipelineType(PipelineType.V2)
.stages(List.of(StageProps.builder()
.stageName("Source")
.actions(List.of(sourceAction))
.build(), StageProps.builder()
.stageName("Build")
.actions(List.of(buildAction))
.build()))
.triggers(List.of(TriggerProps.builder()
.providerType(ProviderType.CODE_STAR_SOURCE_CONNECTION)
.gitConfiguration(GitConfiguration.builder()
.sourceAction(sourceAction)
.pushFilter(List.of(GitPushFilter.builder()
.branchesExcludes(List.of("exclude1", "exclude2"))
.branchesIncludes(List.of("include*"))
.build()))
.build())
.build()))
.build();
File paths can also be specified along with the branches to start the pipeline.
You can filter with glob patterns. The filePathsExcludes takes priority over the filePathsIncludes.
CodeStarConnectionsSourceAction sourceAction;
CodeBuildAction buildAction;
Pipeline.Builder.create(this, "Pipeline")
.pipelineType(PipelineType.V2)
.stages(List.of(StageProps.builder()
.stageName("Source")
.actions(List.of(sourceAction))
.build(), StageProps.builder()
.stageName("Build")
.actions(List.of(buildAction))
.build()))
.triggers(List.of(TriggerProps.builder()
.providerType(ProviderType.CODE_STAR_SOURCE_CONNECTION)
.gitConfiguration(GitConfiguration.builder()
.sourceAction(sourceAction)
.pushFilter(List.of(GitPushFilter.builder()
.branchesExcludes(List.of("exclude1", "exclude2"))
.branchesIncludes(List.of("include1", "include2"))
.filePathsExcludes(List.of("/path/to/exclude1", "/path/to/exclude2"))
.filePathsIncludes(List.of("/path/to/include1", "/path/to/include1"))
.build()))
.build())
.build()))
.build();
Pull request filter
Pipelines can be started based on pull request events. You can specify the pullRequestFilter property to
filter the pull request events. The pullRequestFilter can specify branches, file paths, and event types.
In the case of branches, your pipeline starts when a pull request event occurs on the specified branches.
You can filter with glob patterns. The branchesExcludes takes priority over the branchesIncludes.
CodeStarConnectionsSourceAction sourceAction;
CodeBuildAction buildAction;
Pipeline.Builder.create(this, "Pipeline")
.pipelineType(PipelineType.V2)
.stages(List.of(StageProps.builder()
.stageName("Source")
.actions(List.of(sourceAction))
.build(), StageProps.builder()
.stageName("Build")
.actions(List.of(buildAction))
.build()))
.triggers(List.of(TriggerProps.builder()
.providerType(ProviderType.CODE_STAR_SOURCE_CONNECTION)
.gitConfiguration(GitConfiguration.builder()
.sourceAction(sourceAction)
.pullRequestFilter(List.of(GitPullRequestFilter.builder()
.branchesExcludes(List.of("exclude1", "exclude2"))
.branchesIncludes(List.of("include*"))
.build()))
.build())
.build()))
.build();
File paths can also be specified along with the branches to start the pipeline.
You can filter with glob patterns. The filePathsExcludes takes priority over the filePathsIncludes.
CodeStarConnectionsSourceAction sourceAction;
CodeBuildAction buildAction;
Pipeline.Builder.create(this, "Pipeline")
.pipelineType(PipelineType.V2)
.stages(List.of(StageProps.builder()
.stageName("Source")
.actions(List.of(sourceAction))
.build(), StageProps.builder()
.stageName("Build")
.actions(List.of(buildAction))
.build()))
.triggers(List.of(TriggerProps.builder()
.providerType(ProviderType.CODE_STAR_SOURCE_CONNECTION)
.gitConfiguration(GitConfiguration.builder()
.sourceAction(sourceAction)
.pullRequestFilter(List.of(GitPullRequestFilter.builder()
.branchesExcludes(List.of("exclude1", "exclude2"))
.branchesIncludes(List.of("include1", "include2"))
.filePathsExcludes(List.of("/path/to/exclude1", "/path/to/exclude2"))
.filePathsIncludes(List.of("/path/to/include1", "/path/to/include1"))
.build()))
.build())
.build()))
.build();
To filter types of pull request events for triggers, you can specify the events property.
CodeStarConnectionsSourceAction sourceAction;
CodeBuildAction buildAction;
Pipeline.Builder.create(this, "Pipeline")
.pipelineType(PipelineType.V2)
.stages(List.of(StageProps.builder()
.stageName("Source")
.actions(List.of(sourceAction))
.build(), StageProps.builder()
.stageName("Build")
.actions(List.of(buildAction))
.build()))
.triggers(List.of(TriggerProps.builder()
.providerType(ProviderType.CODE_STAR_SOURCE_CONNECTION)
.gitConfiguration(GitConfiguration.builder()
.sourceAction(sourceAction)
.pullRequestFilter(List.of(GitPullRequestFilter.builder()
.branchesExcludes(List.of("exclude1", "exclude2"))
.branchesIncludes(List.of("include1", "include2"))
.events(List.of(GitPullRequestEvent.OPEN, GitPullRequestEvent.CLOSED))
.build()))
.build())
.build()))
.build();
Append a trigger to an existing pipeline
You can append a trigger to an existing pipeline:
Pipeline pipeline;
CodeStarConnectionsSourceAction sourceAction;
pipeline.addTrigger(TriggerProps.builder()
.providerType(ProviderType.CODE_STAR_SOURCE_CONNECTION)
.gitConfiguration(GitConfiguration.builder()
.sourceAction(sourceAction)
.pushFilter(List.of(GitPushFilter.builder()
.tagsExcludes(List.of("exclude1", "exclude2"))
.tagsIncludes(List.of("include*"))
.build()))
.build())
.build());
Execution mode
To control the concurrency behavior when multiple executions of a pipeline are started, you can use the executionMode property.
The execution mode can only be used with pipeline type V2.
Pipeline.Builder.create(this, "Pipeline")
.pipelineType(PipelineType.V2)
.executionMode(ExecutionMode.PARALLEL)
.build();
Stage Level Condition
Conditions are used for specific types of expressions and each has specific options for results available as follows:
Entry - The conditions for making checks that, if met, allow entry to a stage. Rules are engaged with the following result options: Fail or Skip
On Failure - The conditions for making checks for the stage when it fails. Rules are engaged with the following result option: Rollback
On Success - The conditions for making checks for the stage when it succeeds. Rules are engaged with the following result options: Rollback or Fail
Conditions are supported by a set of rules for each type of condition.
For each type of condition, there are specific actions that are set up by the condition. The action is the result of the succeeded or failed condition check. For example, the condition for entry (entry condition) encounters an alarm (rule), then the check is successful and the result (action) is that the stage entry is blocked.
CodeStarConnectionsSourceAction sourceAction;
CodeBuildAction buildAction;
Pipeline.Builder.create(this, "Pipeline")
.pipelineType(PipelineType.V2)
.stages(List.of(StageProps.builder()
.stageName("Source")
.actions(List.of(sourceAction))
.build(), StageProps.builder()
.stageName("Build")
.actions(List.of(buildAction))
// BeforeEntry condition - checks before entering the stage
.beforeEntry(Conditions.builder()
.conditions(List.of(Condition.builder()
.rules(List.of(Rule.Builder.create()
.name("LambdaCheck")
.provider("LambdaInvoke")
.version("1")
.configuration(Map.of(
"FunctionName", "LambdaFunctionName"))
.build()))
.result(Result.FAIL)
.build()))
.build())
// OnSuccess condition - checks after successful stage completion
.onSuccess(Conditions.builder()
.conditions(List.of(Condition.builder()
.result(Result.FAIL)
.rules(List.of(Rule.Builder.create()
.name("CloudWatchCheck")
.provider("LambdaInvoke")
.version("1")
.configuration(Map.of(
"AlarmName", "AlarmName1",
"WaitTime", "300", // 5 minutes
"FunctionName", "funcName2"))
.build()))
.build()))
.build())
// OnFailure condition - handles stage failure
.onFailure(FailureConditions.builder()
.conditions(List.of(Condition.builder()
.result(Result.ROLLBACK)
.rules(List.of(Rule.Builder.create()
.name("RollBackOnFailure")
.provider("LambdaInvoke")
.version("1")
.configuration(Map.of(
"AlarmName", "Alarm",
"WaitTime", "300", // 5 minutes
"FunctionName", "funcName1"))
.build()))
.build()))
.build())
.build()))
.build();
Use pipeline service role as default action role in pipeline
You could enable this field to use pipeline service role as default action role in Codepipeline by set usePipelineServiceRoleForActions as true if no action role provided.
Migrating a pipeline type from V1 to V2
To migrate your pipeline type from V1 to V2, you just need to update the pipelineType property to PipelineType.V2.
This migration does not cause replacement of your pipeline.
When the @aws-cdk/aws-codepipeline:defaultPipelineTypeToV2 feature flag is set to true (default for new projects),
the V2 type is selected by default if you do not specify a value for pipelineType property. Otherwise, the V1 type is selected.
Pipeline.Builder.create(this, "Pipeline")
.pipelineType(PipelineType.V2)
.build();
See the CodePipeline documentation for more details on the differences between each type.
-
ClassDescriptionLow-level class for generic CodePipeline Actions implementing the
IActioninterface.Specifies the constraints on the number of input and output artifacts an action can have.A builder forActionArtifactBoundsAn implementation forActionArtifactBoundsExample:A builder forActionBindOptionsAn implementation forActionBindOptionsExample:Example:A builder forActionConfigAn implementation forActionConfigExample:A builder forActionPropertiesAn implementation forActionPropertiesAn output artifact of an action.A specific file within an output artifact.TheAWS::CodePipeline::CustomActionTyperesource creates a custom action for activities that aren't included in the CodePipeline default actions, such as running an internally developed build process or a test suite.Returns information about the details of an artifact.A builder forCfnCustomActionType.ArtifactDetailsPropertyAn implementation forCfnCustomActionType.ArtifactDetailsPropertyA fluent builder forCfnCustomActionType.The configuration properties for the custom action.A builder forCfnCustomActionType.ConfigurationPropertiesPropertyAn implementation forCfnCustomActionType.ConfigurationPropertiesPropertySettingsis a property of theAWS::CodePipeline::CustomActionTyperesource that provides URLs that users can access to view information about the CodePipeline custom action.A builder forCfnCustomActionType.SettingsPropertyAn implementation forCfnCustomActionType.SettingsPropertyProperties for defining aCfnCustomActionType.A builder forCfnCustomActionTypePropsAn implementation forCfnCustomActionTypePropsTheAWS::CodePipeline::Pipelineresource creates a CodePipeline pipeline that describes how software changes go through a release process.Represents information about an action declaration.A builder forCfnPipeline.ActionDeclarationPropertyAn implementation forCfnPipeline.ActionDeclarationPropertyRepresents information about an action type.A builder forCfnPipeline.ActionTypeIdPropertyAn implementation forCfnPipeline.ActionTypeIdPropertyA mapping ofartifactStoreobjects and their corresponding AWS Regions.A builder forCfnPipeline.ArtifactStoreMapPropertyAn implementation forCfnPipeline.ArtifactStoreMapPropertyThe S3 bucket where artifacts for the pipeline are stored.A builder forCfnPipeline.ArtifactStorePropertyAn implementation forCfnPipeline.ArtifactStorePropertyThe conditions for making checks for entry to a stage.A builder forCfnPipeline.BeforeEntryConditionsPropertyAn implementation forCfnPipeline.BeforeEntryConditionsPropertyReserved for future use.A builder forCfnPipeline.BlockerDeclarationPropertyAn implementation forCfnPipeline.BlockerDeclarationPropertyA fluent builder forCfnPipeline.The condition for the stage.A builder forCfnPipeline.ConditionPropertyAn implementation forCfnPipeline.ConditionPropertyRepresents information about the key used to encrypt data in the artifact store, such as an AWS Key Management Service ( AWS KMS) key.A builder forCfnPipeline.EncryptionKeyPropertyAn implementation forCfnPipeline.EncryptionKeyPropertyThe environment variables for the action.A builder forCfnPipeline.EnvironmentVariablePropertyAn implementation forCfnPipeline.EnvironmentVariablePropertyThe configuration that specifies the result, such as rollback, to occur upon stage failure.A builder forCfnPipeline.FailureConditionsPropertyAn implementation forCfnPipeline.FailureConditionsPropertyThe Git repository branches specified as filter criteria to start the pipeline.A builder forCfnPipeline.GitBranchFilterCriteriaPropertyAn implementation forCfnPipeline.GitBranchFilterCriteriaPropertyA type of trigger configuration for Git-based source actions.A builder forCfnPipeline.GitConfigurationPropertyAn implementation forCfnPipeline.GitConfigurationPropertyThe Git repository file paths specified as filter criteria to start the pipeline.A builder forCfnPipeline.GitFilePathFilterCriteriaPropertyAn implementation forCfnPipeline.GitFilePathFilterCriteriaPropertyThe event criteria for the pull request trigger configuration, such as the lists of branches or file paths to include and exclude.A builder forCfnPipeline.GitPullRequestFilterPropertyAn implementation forCfnPipeline.GitPullRequestFilterPropertyThe event criteria that specify when a specified repository event will start the pipeline for the specified trigger configuration, such as the lists of Git tags to include and exclude.A builder forCfnPipeline.GitPushFilterPropertyAn implementation forCfnPipeline.GitPushFilterPropertyThe Git tags specified as filter criteria for whether a Git tag repository event will start the pipeline.A builder forCfnPipeline.GitTagFilterCriteriaPropertyAn implementation forCfnPipeline.GitTagFilterCriteriaPropertyRepresents information about an artifact to be worked on, such as a test or build artifact.A builder forCfnPipeline.InputArtifactPropertyAn implementation forCfnPipeline.InputArtifactPropertyRepresents information about the output of an action.A builder forCfnPipeline.OutputArtifactPropertyAn implementation forCfnPipeline.OutputArtifactPropertyRepresents information about the specified trigger configuration, such as the filter criteria and the source stage for the action that contains the trigger.A builder forCfnPipeline.PipelineTriggerDeclarationPropertyAn implementation forCfnPipeline.PipelineTriggerDeclarationPropertyThe retry configuration specifies automatic retry for a failed stage, along with the configured retry mode.A builder forCfnPipeline.RetryConfigurationPropertyAn implementation forCfnPipeline.RetryConfigurationPropertyRepresents information about the rule to be created for an associated condition.A builder forCfnPipeline.RuleDeclarationPropertyAn implementation forCfnPipeline.RuleDeclarationPropertyThe ID for the rule type, which is made up of the combined values for category, owner, provider, and version.A builder forCfnPipeline.RuleTypeIdPropertyAn implementation forCfnPipeline.RuleTypeIdPropertyRepresents information about a stage and its definition.A builder forCfnPipeline.StageDeclarationPropertyAn implementation forCfnPipeline.StageDeclarationPropertyThe name of the pipeline in which you want to disable the flow of artifacts from one stage to another.A builder forCfnPipeline.StageTransitionPropertyAn implementation forCfnPipeline.StageTransitionPropertyThe conditions for making checks that, if met, succeed a stage.A builder forCfnPipeline.SuccessConditionsPropertyAn implementation forCfnPipeline.SuccessConditionsPropertyA variable declared at the pipeline level.A builder forCfnPipeline.VariableDeclarationPropertyAn implementation forCfnPipeline.VariableDeclarationPropertyProperties for defining aCfnPipeline.A builder forCfnPipelinePropsAn implementation forCfnPipelinePropsTheAWS::CodePipeline::Webhookresource creates and registers your webhook.A fluent builder forCfnWebhook.The authentication applied to incoming webhook trigger requests.A builder forCfnWebhook.WebhookAuthConfigurationPropertyAn implementation forCfnWebhook.WebhookAuthConfigurationPropertyThe event criteria that specify when a webhook notification is sent to your URL.A builder forCfnWebhook.WebhookFilterRulePropertyAn implementation forCfnWebhook.WebhookFilterRulePropertyProperties for defining aCfnWebhook.A builder forCfnWebhookPropsAn implementation forCfnWebhookPropsCommon properties shared by all Actions.A builder forCommonActionPropsAn implementation forCommonActionPropsCommon properties shared by all Actions whoseActionProperties.ownerfield is 'AWS' (or unset, as 'AWS' is the default).A builder forCommonAwsActionPropsAn implementation forCommonAwsActionPropsThe condition for the stage.A builder forConditionAn implementation forConditionThe conditions for making checks for the stage.A builder forConditionsAn implementation forConditionsAn interface representing resources generated in order to support the cross-region capabilities of CodePipeline.A builder forCrossRegionSupportAn implementation forCrossRegionSupportThe creation attributes used for defining a configuration property of a custom Action.A builder forCustomActionPropertyAn implementation forCustomActionPropertyThe resource representing registering a custom Action with CodePipeline.A fluent builder forCustomActionRegistration.Properties of registering a custom Action.A builder forCustomActionRegistrationPropsAn implementation forCustomActionRegistrationPropsA reference to a CustomActionType resource.A builder forCustomActionTypeReferenceAn implementation forCustomActionTypeReferenceExecution mode.The configuration that specifies the result, such as rollback, to occur upon stage failure.A builder forFailureConditionsAn implementation forFailureConditionsGit configuration for trigger.A builder forGitConfigurationAn implementation forGitConfigurationEvent for trigger with pull request filter.Git pull request filter for trigger.A builder forGitPullRequestFilterAn implementation forGitPullRequestFilterGit push filter for trigger.A builder forGitPushFilterAn implementation forGitPushFilterThe CodePipeline variables that are global, not bound to a specific action.A Pipeline Action.Internal default implementation forIAction.A proxy class which represents a concrete javascript instance of this type.(experimental) Indicates that this resource can be referenced as a CustomActionType.Internal default implementation forICustomActionTypeRef.A proxy class which represents a concrete javascript instance of this type.The abstract view of an AWS CodePipeline as required and used by Actions.Internal default implementation forIPipeline.A proxy class which represents a concrete javascript instance of this type.(experimental) Indicates that this resource can be referenced as a Pipeline.Internal default implementation forIPipelineRef.A proxy class which represents a concrete javascript instance of this type.The abstract interface of a Pipeline Stage that is used by Actions.Internal default implementation forIStage.A proxy class which represents a concrete javascript instance of this type.(experimental) Indicates that this resource can be referenced as a Webhook.Internal default implementation forIWebhookRef.A proxy class which represents a concrete javascript instance of this type.An AWS CodePipeline pipeline with its associated IAM role and S3 bucket.A fluent builder forPipeline.The list of event types for AWS Codepipeline Pipeline.Additional options to pass to the notification rule.A builder forPipelineNotifyOnOptionsAn implementation forPipelineNotifyOnOptionsExample:A builder forPipelinePropsAn implementation forPipelinePropsA reference to a Pipeline resource.A builder forPipelineReferenceAn implementation forPipelineReferencePipeline types.Provider type for trigger.The action to be done when the condition is met.The method that you want to configure for automatic stage retry on stage failure.Represents a rule in AWS CodePipeline that can be used to add conditions and controls to pipeline execution.A fluent builder forRule.Properties for defining a CodePipeline Rule.A builder forRulePropsAn implementation forRulePropsExample:A builder forStageOptionsAn implementation forStageOptionsAllows you to control where to place a new Stage when it's added to the Pipeline.A builder forStagePlacementAn implementation forStagePlacementConstruction properties of a Pipeline Stage.A builder forStagePropsAn implementation forStagePropsTrigger.A fluent builder forTrigger.Properties of trigger.A builder forTriggerPropsAn implementation forTriggerPropsPipeline-Level variable.A fluent builder forVariable.Properties of pipeline-level variable.A builder forVariablePropsAn implementation forVariablePropsA reference to a Webhook resource.A builder forWebhookReferenceAn implementation forWebhookReference