aws / aws-sdk-js-v3

Modularized AWS SDK for JavaScript.
Apache License 2.0
3.14k stars 580 forks source link

ValidationException when referencing EventBridge EventBuses from partner integration #3714

Closed ezmiller closed 1 year ago

ezmiller commented 2 years ago

Describe the bug

I am trying to send an event to an event bus created through a partner integration with Shopify. I receive an error:

ValidationException: 1 validation error detected: Value 'arn:aws:events:us-east-1:*:event-bus/aws.partner/shopify.com//shopify-events-dev' at 'entries.1.member.eventBusName' failed to satisfy constraint: Member must satisfy regular expression pattern: (arn:aws[\w-]*:events:[a-z]{2}-[a-z]+-[\w-]+:[0-9]{12}:event-bus\/)?[.-_A-Za-z0-9]+

(note some parts of ARN removed and replaced with *s above for privacy)

Expected Behavior

The ARN is valid so I would expect not to have the Validation error.

Current Behavior

The current regex, I think, does not allow for /s after the first capturing group, and so the valid ARN is treated as invalid.

Reproduction Steps

N/A can't provide example since it requires a deployed partner integration event bus resource to reproduce.

Possible Solution

Adjust regex used for validation.

Additional Information/Context

No response

SDK version used

^3.112.0

Environment details (OS name and version, etc.)

mac os, 10.15.4

ajredniwja commented 2 years ago

@ezmiller thanks for opening this issue, to help you better can you please share more information about your code. What API you are using? How you are consuming the SDK?

ezmiller commented 2 years ago

@ajredniwja sure. Here is a function that makes a call using the v3 @aws-sdk/client-eventbridge and the PutEvents command:

import { LambdaClient, InvokeCommand } from '@aws-sdk/client-lambda'

const viaEventBridge = async (
  busName: string,
  source: string,
  detailType: string,
  detail: unknown
) => {
  const eventBridge = new EventBridgeClient({ region: process.env.AWS_REGION })

  const input = {
    Entries: [
      {
        Source: source,
        DetailType: detailType,
        Detail: JSON.stringify(detail),
        EventBusName: busName
      }
    ]
  }

  await eventBridge.send(new PutEventsCommand(input))
}

I asksed a question about this on stack overflow and someone there pointed out that there's a special command for partner integrations PutPartnerEvents, which however AWS customers cannot use.

So perhaps this behavior is intentional?

ezmiller commented 2 years ago

@ajredniwja was that additional context helpful?

ezmiller commented 2 years ago

@ajredniwja for additional context, the reason I want to be able to put events on the partner integration event bus is that I want to be able to write e2e tests that start with submitting an event to the event bus. Without the ability to put an event on the bus, I think my hands are tied.

ezmiller commented 1 year ago

@ajredniwja any chance you have an answer here?

rbuck-som commented 1 year ago

I have the same problem. Only when importing a resource it fails with the same error.

RanVaknin commented 1 year ago

Hi @ezmiller ,

I apologize for the long wait. The problem is that ARN you provided is the ARN is used by SaaS partners to call your event bus, not vice versa. Like you mentioned, this ARN shape corresponds to the one expected in Source for

PutPartnerEvents This is used by SaaS partners to write events to a customer's partner event bus. AWS customers do not use this operation. ... ... Source The event source that is generating the entry. Type: String Length Constraints: Minimum length of 1. Maximum length of 256. Pattern: aws.partner(/[.-_A-Za-z0-9]+){2,}

Notice the regex for this arn contains .partner like what you have supplied.

The ARN you need to supply should look something like this: arn:aws:events:us-east-1:123456789012:event-bus/myEventBusName and should be of an event bus you created.

It sounds like this article might help you set up the integration between EB and Shopify.

Let me know if you need anything else, Ran~

github-actions[bot] commented 1 year ago

This issue has not received a response in 1 week. If you still think there is a problem, please leave a comment to avoid the issue from automatically closing.

github-actions[bot] commented 1 year ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.