已知CodeCommit可触发CodePipeline,能否通过ECR推送触发?
Can AWS ECR Image Push Trigger AWS CodePipeline?
Absolutely! While AWS CodePipeline doesn’t have a native, out-of-the-box trigger option for ECR image pushes (unlike CodeCommit’s direct integration), you can easily set this up using AWS EventBridge as a middle layer. Here’s how to do it step by step:
Step 1: Create an EventBridge Rule
- Head to the EventBridge console and create a new rule.
- For the event source, select AWS events or EventBridge partner events, then choose ECR as the service name and Image pushed to repository as the event type.
- Optional: Narrow down the trigger to a specific ECR repository (or even specific image tags) by adding filters to the event pattern. For example, to only trigger when pushing images tagged
prod, add a filter fordetail.image-tagequalsprod.
Step 2: Configure CodePipeline as the Target
- In the rule’s target section, select CodePipeline from the target types.
- Choose your target CodePipeline, and make sure the IAM role associated with the EventBridge rule has the
codepipeline:StartPipelineExecutionpermission. If you don’t have an existing role, EventBridge can create one for you with the necessary permissions.
Step 3: Test the Setup
- Push an image to your target ECR repository (matching any filters you set).
- Check the EventBridge console to confirm the event was captured, then verify that your CodePipeline starts executing automatically.
This setup works reliably for most use cases, and you can tweak the event filters to fit your specific workflow (like triggering only for certain tags or repositories).
内容的提问来源于stack exchange,提问作者Laimonas Sutkus
相关产品推荐
相关产品推荐

