Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Use an event to start a CodePipeline execution

Focus mode
Use an event to start a CodePipeline execution - CodeArtifact

This example demonstrates how to configure an Amazon EventBridge rule so that an AWS CodePipeline execution starts when a package version in a CodeArtifact repository is published, modified, or deleted.

Configure EventBridge permissions

You must add permissions for EventBridge to use CodePipeline to invoke the rule that you create. To add these permissions using the AWS Command Line Interface (AWS CLI), follow step 1 in Create a CloudWatch Events Rule for a CodeCommit Source (CLI) in the AWS CodePipeline User Guide.

Create the EventBridge rule

To create the rule, use the put-rule command with the --name and --event-pattern parameters. The event pattern specifies values that are matched against the contents of each event. The target is triggered if the pattern matches the event. For example, the following pattern matches CodeArtifact events from the myrepo repository in the my_domain domain.

aws events put-rule --name MyCodeArtifactRepoRule --event-pattern \ '{"source":["aws.codeartifact"],"detail-type":["CodeArtifact Package Version State Change"], "detail":{"domainName":["my_domain"],"domainOwner":["111122223333"],"repositoryName":["myrepo"]}}'

Create the EventBridge rule target

The following command adds a target to the rule so that when an event matches the rule, a CodePipeline execution is triggered. For the RoleArn parameter, specify the Amazon Resource Name (ARN) of the role created earlier in this topic.

aws events put-targets --rule MyCodeArtifactRepoRule --targets \ 'Id=1,Arn=arn:aws:codepipeline:us-west-2:111122223333:pipeline-name, RoleArn=arn:aws:iam::123456789012:role/MyRole'
PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.