Skip to content

EventBridge Rules are not being invoke from Bitbucket pipeline

0

I am deploying using the Bitbucket pipeline and I want to call a script after each deployment. So I have created a EventBridge Rule in us-west-1 region. When I call that rule from the local machine, it is working fine but when I attach the script in bitbucket pipeline, it is not being invoke, I can see events in the monitoring log but the script is not being called.

I have selected the target as EC2 instance where my script stored along with the working command (tested directly in the EC2 console). Also, provide the ROLE with FULLACCESS permission.

Thank you in advance!

1 Answer
0

There are several potential reasons why your EventBridge rule is not being invoked from your Bitbucket pipeline while it works from your local machine:

  1. Region Mismatch: EventBridge is a regional service. If your Bitbucket pipeline is sending events to a different region than where your rule is created (us-west-1), the rule won't be triggered. Ensure that your pipeline is configured to send events to the same region where your rule is defined.

  2. IAM Permissions: Even though you've provided a role with FULLACCESS permissions, there might be issues with the trust relationship. EventBridge needs specific permissions to invoke your target (EC2 instance). Make sure that:

  • The role has a trust policy that allows the EventBridge service (events.amazonaws.com) to assume the role
  • The role has permissions to execute commands on your EC2 instance

2a. EventBridge Permission: You need to provide permissions to BitBucket runner to invoke EventBridge. Eventbridge does not support BitBucket or Atlassian as a source, so you will need to configure the script to invoke EventBridge. If you are using BitBucket hosted runner, use IAM access keys or if you are using AWS hosted runner, you can configure an IAM role to the EC2.

  1. Event Pattern Mismatch: The events coming from your Bitbucket pipeline might not match the event pattern defined in your rule. Check the event pattern in your rule and ensure it matches the events being sent from Bitbucket.

  2. Target Configuration: Verify that the target EC2 instance is correctly configured in your rule, including any command parameters or input transformations.

  3. Global Service Consideration: If you're monitoring events from AWS global services, note that these events are only available in the US East (N. Virginia) region (us-east-1). If your rule is related to a global service but created in us-west-1, it won't work.

To troubleshoot:

  • Check CloudWatch metrics for your rule to see if it's being triggered
  • Set up a dead-letter queue to capture any failed event deliveries
  • Temporarily set up a simpler target (like an SNS topic) to verify if the rule is being triggered at all
  • Ensure the EC2 instance is running and accessible when the events are sent

If the issue persists, you might want to consider creating a cross-region event routing setup if your events are being generated in a different region than us-west-1.
Sources
EventBridge rule not triggered | AWS re:Post
Troubleshooting Amazon EventBridge - Amazon EventBridge
EventBridge rule not working | AWS re:Post
Create an EventBridge rule for a CodeCommit source (CLI) - AWS CodePipeline
Create an EventBridge rule for an Amazon S3 source (CLI) - AWS CodePipeline

answered a year ago

EXPERT

revised a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.