Eventbridge Input Transformer example doesnt work

0

I am trying to setup an eventbridge input transformer, and am following the example instructions on this page: https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-transform-target-input.html

I need to use reserved variables, so I am testing by trying to use the input template with the description:

Including reserved variables in JSON

Here is my Input Template:

{
  "instance" : <instance>,
  "state": <state>,
  "ruleArn" : <aws.events.rule-arn>,
  "ruleName" : <aws.events.rule-name>,
  "originalEvent" : <aws.events.event>
}

According to the docs, Generate Output is supposed to result in:

{
  "instance" : "i-0123456789",
  "state": "RUNNING",
  "ruleArn" : "arn:aws:events:us-east-2:123456789012:rule/example",
  "ruleName" : "example",
  "originalEvent" : {
    ... // commented for brevity
  }
}

but instead I am getting:

{
  "instance" : i-0123456789,
  "state": RUNNING,
  "ruleArn" : <aws.events.rule-arn>,
  "ruleName" : <aws.events.rule-name>,
  "originalEvent" : <aws.events.event>
}

Is this broken, or am I missing something?

I also need to transform the input before being sent to an EventBridge event bus in another account as a Target, but when I select that as the target, the ability to configure the target input as an Input Transformer disappears from the Additional Settings section.

Is this not supported? It is obviously a critical use case to be able to filter data before it crosses account boundaries.

Ethan
已提問 2 年前檢視次數 3751 次
1 個回答
0

Hi Ethan, thanks for reaching out!

When setting up an Input Transformer in the console, the reserved variables won't populate in the Input Transformer set-up window when clicking Generate Output to test a Transformer. However, these variables will populate after creating the Transformer, saving the rule, and passing an event that triggers the rule. For example, here's the output of an event using the same Input Transformer from the documentation utilizing the reserved variables:

{
	"instance": "i-68b59f5e3e8m74d47",
	"state": "stopped",
	"ruleArn": "arn:aws:events:us-west-1:123456789012:rule/InputTransformerTest",
	"ruleName": "InputTransformerTest",
	"originalEvent": {
		"id": "79bb5757-adab-984d-crr1-71af1f67d7894",
		"account": "123456789012",
		"detailType": "EC2 Instance State-change Notification",
		"time": 1652796616000,
		"source": "aws.ec2",
		"region": "us-west-1",
		"resources": ["arn:aws:ec2:us-west-1:123456789012:instance/i-68b59f5e3e8m74d47"],
		"version": "0"
	}
}

As for utilizing Input Transformers when sending events to another event bus, you are correct that this is not supported. When sending events to another event bus, the entire event must be passed as is. As workarounds, you can either:

  1. Send the full event to the target event bus as is, and place the desired Input Transfomer on a rule in the target event bus.

  2. Send the event data to a Lambda function target, and have the Lambda function parse and format the event, and perform the PutEvents API to send the transformed event data to the target event bus.

AWS
支援工程師
已回答 2 年前
  • Neither of these workarounds resolves my use case, which is that i need to add a parameter to the event based on the rule that is passing it to the target event bus. This is easily done with apiDestinations by adding a header, but no obvious way to do it for an eventbus destination. I see that it could possibly be done via lambda in the origin account, but that is not a possibility in my use case (I dont have the option to deploy lambdas in the origin account). Any ideas?

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南