How to define API Gateway to Eventbridge integration?

0

I am building an API Gateway (v1) integration such that posts to a given endpoint should route the body of the POST to my custom eventbus in Eventbridge. I have created the gateway endpoints, event bus etc but I am struggling with the definition of the integration.

I am doing this in Terraform, which basically wraps the AWS API for PutIntegration and I cannot seem to figure out the correct format of the request-parameters map required by AWS.

since eventbus payloads have a specific structure, I assume I need to build the map to construct that payload. I also saw a post about needing a custom X-Amz-Target header as well. Are there any AWS documented examples of just how to build this integration & mapping?

My attempts invariably lead to an error response along the lines of:
Error updating API Gateway Integration: BadRequestException: Invalid mapping expression specified: Validation Result: warnings : [], errors : [Invalid mapping expression specified: tagmodernization-dev-us-west-2-eventbus-information-reporting, Invalid mapping expression specified: integration.request.body.Entries[0].EventBusName]

mapping variations I have tried include:
integration.request.body.EventBusName
integration.request.body.Entries[0].EventBusName]
EventBusName

I realize I can achieve a similar goal using VTL with the request templates capability, but I am still unclear on the output format of the mapping anyway.

1개 답변
0
수락된 답변
profile pictureAWS
전문가
답변함 2년 전
profile picture
전문가
검토됨 10달 전
  • I was trying to achieve this via request-parameters which does not accept values as described in the linked blog. However, I will pivot to using request templates as described in the blog as I think it will give us more flexibility in the future. update... marking this as accepted. Just one warning to others, velocity templates seem to only function well on leaf node of json object. thus $elem.entry as shown only works because the contents are a string not a json body. if you are not delimiting, expect to see velocity render a string of name value pairs - eg { a= b, c=d} from input of {"a":"b","c":"d"}

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

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

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

관련 콘텐츠