Amazon EventBridge Rules error with Lambda

0

Hi Everybody, I have 2 environments: STG and PROD. I using Medialive for Livestream. I've created below:

Environment STG:
Amazon EventBridge => Lambda function handler event Medialive
Environment PROD:
Amazon EventBridge => Lambda function handler event Medialive

Amazon EventBridge STG and Amazon EventBridge PROD have the same rules like:

{
  "source": ["aws.medialive"],
  "detail-type": ["MediaLive Channel State Change"]
}

When I config above. I found that events Amazon EventBridge environment STG in Lambda PROD, or opposite events Amazon EventBridge environment PROD in Lambda STG. This leads to conflict when operating my website.

Please explain or help me fix my issues. Thank you so much.

2개 답변
0

Recommended option is to create different accounts for the different environments. If you use a single account, each environment should have its own Event Bus in EventBridge. PROD functions will create the rule on the PROD bus and STG functions will create the rule on the STG bus. The functions that send events to the event bus will use an environment variable with the ARN of the bus.

profile pictureAWS
전문가
Uri
답변함 2년 전
  • Hi Bro, Please let me know, with event same: { "source": ["aws.medialive"], "detail-type": ["MediaLive Channel State Change"] } How to config with eventbus. Thank you

  • The events will be the same in both buses, but you write them to different buses. As you can see in the PutEvents API, there is a field there for the event bus name. This will be different for the different environments.

0

I am assuming you are using the same Account ID for both environments. This may explain your experience.

If that is the case, you would have to further filter the rule by the ARN of the channel. Essentially you would have something like so:

{
"source": ["aws.medialive"],
  "detail-type": ["MediaLive Channel State Change"]
  "detail": {
    "channel_arn": ["<staging-channel-arn>"]
  }
}

and

{
"source": ["aws.medialive"],
  "detail-type": ["MediaLive Channel State Change"]
  "detail": {
    "channel_arn": ["<production-channel-arn>"]
  }
}

You can find the schema for this event here -> https://us-east-2.console.aws.amazon.com/events/home?region=us-east-2#/registries/aws.events/schemas/aws.medialive%40MediaLiveChannelStateChange/version/1

답변함 2년 전
  • Hi bro, Because I will create many channels. Channel is not static, each environment will create when the client requests so can't specify channel ARN.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠