Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amazon EventBridge not compatible with partner event sources #6514

Closed
trevorrecker opened this issue Aug 7, 2019 · 6 comments

Comments

@trevorrecker
Copy link

commented Aug 7, 2019

This is a Bug Report

Description

When deploying an AWS Lambda that is triggered by Amazon EventBridge using a partner event source (such as segment.com) a CloudFormation error occurs that the event bus cannot be found. This error appears to be caused by the way the event bus ARN is parsed by Serverless, detailed below.

Configuration:

# ...
functions:
  # ...
  create-request:
    handler: functions/handler.createRequest
    events:
      - eventBridge:
          eventBus: 'arn:aws:events:us-east-1:XXXXXXXXXXXX:event-bus/aws.partner/segment.com/XXXXXXXXXX'
          pattern:
            source:
              - 'aws.partner/segment.com/XXXXXXXXXX'
            detail:
              event:
                - 'My Event'
              type:
                - 'track'
# ...

The deployment error that is displayed in the console is:

Failed to create resource. Event bus XXXXXXXXXX does not exist. See details in CloudWatch Log: 2019/08/06/[$LATEST][...].

In the current implementation, Serverless parses out the event bus ARN so it only includes the text after the last / character. In the case of partner sources, a portion of the ARN is omitted by this approach.

Current implementation added in #6397 here:

eventBusName = EventBus.split('/').pop();

This implementation works for custom event busses formatted as follows:

event-bus/<bus_name>

However, it is not compatible with event busses from partner sources or any ARN containing additional / characters such as the Segment event bus in my example:

event-bus/aws.partner/segment.com/XXXXXXXXXX

The above ARN path is converted to event-bus/XXXXXXXXXX which does not exist.

Similar or dependent issues:

Additional Data

@pmuens

This comment has been minimized.

Copy link
Member

commented Aug 8, 2019

Thanks for opening @trevorrecker 👍

We're working on a fix for that right now...

@pmuens pmuens referenced this issue Aug 8, 2019

Merged

Fix support for EventBridge partner event sources #6518

8 of 8 tasks complete
@pmuens

This comment has been minimized.

Copy link
Member

commented Aug 8, 2019

Hey @trevorrecker thanks again for reporting. I pushed a fix via #6518

Can you take it for a spin and see if it fixes the problem? Thanks!

@pmuens pmuens added this to Product - In Definition in Serverless via automation Aug 8, 2019

@pmuens pmuens added this to the 1.50.0 milestone Aug 8, 2019

@trevorrecker

This comment has been minimized.

Copy link
Author

commented Aug 8, 2019

Thanks @pmuens I tried out the PR locally and when I run a deploy it is now able to find the event bus but it looks like there may still be an issue somewhere down the line.

Error output from Serverless deploy:

An error occurred: CreateDashrequestCustomEventBridge1 - Failed to create resource. User: arn:aws:sts::XXXXXXXXXXXX:assumed-role/dispatcher-dev-IamRoleCustomResourcesLa-BFC919FFZVDA/dispatcher-dev-custom-resource-event-bridge is not authorized to perform: events:PutRule on resource: arn:aws:events:us-east-1:XXXXXXXXXXXX:rule/XXXXXXXXXX/dispatcher-dev-create-request-rule-1 See details in CloudWatch Log: 2019/08/08/[$LATEST][...].

Now that the name is updated, it looks like the rule being referenced in the error output doesn't line up with the permission and resource assigned in the EventBridge creation.

arn:aws:events:us-east-1:XXXXXXXXXXXX:rule/XXXXXXXXXX/dispatcher-dev-create-request-rule-1 uses the Segment ID (omitting everything prior to the last slash character once again) I'm not sure exactly why, when events:PutRule is assigned here, it's assigned using the same eventBusName variable that was updated.

It could be that the provider's ID is the correct one to use here, so the nesting resource name doesn't cause cascading issues down the line. If there's any other info that would be useful to you, I'm happy to provide it. Let me know when you'd like me to pull and try again.

@pmuens

This comment has been minimized.

Copy link
Member

commented Aug 9, 2019

Thanks for replying @trevorrecker 👍

I was finally able to setup Segment and connect it to AWS via EventBridge. I figured what the other remaining problem you reported above is. I updated the PR, tested it on my end and it works fine.

Could you test it again and confirm that it's also working on your end? Thanks!

@trevorrecker

This comment has been minimized.

Copy link
Author

commented Aug 9, 2019

I'm happy to report that it's working great now! Thanks for such a quick response and getting things up and running @pmuens!

@pmuens

This comment has been minimized.

Copy link
Member

commented Aug 9, 2019

Great! Thanks @trevorrecker 👍 Will merge it in a second :shipit:

@pmuens pmuens closed this in #6518 Aug 9, 2019

Serverless automation moved this from Product - In Definition to Done Aug 9, 2019

@medikoo medikoo removed this from the 1.50.0 milestone Aug 14, 2019

@medikoo medikoo removed this from Done in Serverless Aug 14, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.