Create an EventBridge rule for an Amazon ECR source (console)
To create an EventBridge rule for use in CodePipeline operations (Amazon ECR source)
- Open the Amazon EventBridge console at https://console.aws.amazon.com/events/ - . 
- 
                    In the navigation pane, choose Events. 
- 
                    Choose Create rule, and then under Event source, from Service Name, choose Elastic Container Registry (ECR). 
- 
                    In Event Source, choose Event Pattern. Choose Edit, and then paste the following example event pattern in the Event Source window for a eb-testrepository with an image tag ofcli-testing:{ "detail-type": [ "ECR Image Action" ], "source": [ "aws.ecr" ], "detail": { "action-type": [ "PUSH" ], "image-tag": [ "latest" ], "repository-name": [ "eb-test" ], "result": [ "SUCCESS" ] } }NoteTo view the full event pattern supported for Amazon ECR events, see Amazon ECR Events and EventBridge or Amazon Elastic Container Registry Events. 
- 
                    Choose Save. In the Event Pattern Preview pane, view the rule. 
- 
                    In Targets, choose CodePipeline. 
- 
                    Enter the pipeline ARN for the pipeline to be started by this rule. NoteYou can find the pipeline ARN in the metadata output after you run the get-pipeline command. The pipeline ARN is constructed in this format: arn:aws:codepipeline: region:account:pipeline-nameSample pipeline ARN: arn:aws:codepipeline:us-east-2:80398EXAMPLE:MyFirstPipeline
- 
                    Create or specify an IAM service role that grants EventBridge permissions to invoke the target associated with your EventBridge rule (in this case, the target is CodePipeline). - 
                            Choose Create a new role for this specific resource to create a service role that gives EventBridge permissions to your start your pipeline executions. 
- 
                            Choose Use existing role to enter a service role that gives EventBridge permissions to your start your pipeline executions. 
 
- 
                            
- 
                    (Optional) To specify source overrides with a specific image ID, use the input transformer to pass the data as a JSON parameters. You can also use the input transformer to pass pipeline variables. - 
                            Expand Additional settings. Under Configure target input, choose Configure input transformer. In the dialog window, choose Enter my own. In the Input path box, type the following key-value pairs. {"revisionValue": "$.detail.image-digest"}
- 
                            In the Template box, type the following key-value pairs. { "sourceRevisions": [ { "actionName": "Source", "revisionType": "IMAGE_DIGEST", "revisionValue": "<revisionValue>" } ], "variables": [ { "name": "Variable_Name", "value": "Variable_Value" } ] }
- 
                            Choose Confirm. 
 
- 
                            
- 
                    Review your rule setup to make sure it meets your requirements. 
- 
                    Choose Configure details. 
- 
                    On the Configure rule details page, enter a name and description for the rule, and then choose State to enable the rule. 
- 
                    If you're satisfied with the rule, choose Create rule.