aws-sdk-js-v3 icon indicating copy to clipboard operation
aws-sdk-js-v3 copied to clipboard

ValidationException when referencing EventBridge EventBuses from partner integration

Open ezmiller opened this issue 2 years ago • 4 comments

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

ezmiller avatar Jun 18 '22 14:06 ezmiller

@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?

ajredniwja avatar Jun 20 '22 14:06 ajredniwja

@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 avatar Jun 21 '22 04:06 ezmiller

@ajredniwja was that additional context helpful?

ezmiller avatar Jun 27 '22 13:06 ezmiller

@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 avatar Jun 28 '22 18:06 ezmiller

@ajredniwja any chance you have an answer here?

ezmiller avatar Dec 22 '22 15:12 ezmiller

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

rbuck-som avatar Jan 20 '23 15:01 rbuck-som

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~

RanVaknin avatar Jan 28 '23 02:01 RanVaknin

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] avatar Feb 05 '23 00:02 github-actions[bot]

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.

github-actions[bot] avatar Feb 23 '23 00:02 github-actions[bot]