Map step function response to the response body of an HTTP API Gateway V2 integration

0

Ive got an HTTP API Gateway V2 invoking a synchronous Express Step Function thru AWS Service Integration via StepFunctions-StartSyncExecution. My problem is that the response from the Step Function seems to always be in the form of:

{
   "billingDetails": { 
      "billedDurationInMilliseconds": number,
      "billedMemoryUsedInMB": number
   },
   "cause": "string",
   "error": "string",
   "executionArn": "string",
   "input": "string",
   "inputDetails": { 
      "included": boolean
   },
   "name": "string",
   "output": "string",
   "outputDetails": { 
      "included": boolean
   },
   "startDate": number,
   "stateMachineArn": "string",
   "status": "string",
   "stopDate": number,
   "traceHeader": "string"
}

And that gets passed as the response to the client calling the API Gateway. I just want the value of the output field (as JSON) from that big JSON blob. As far as I can tell there doesn’t seem to be a way with HTTP API Gateway V2 to transform the integration response into the clean final response. As far as I can tell, parameter mapping will only work for headers, I can’t see how to rewrite the body. I can get the value in Integrations->parameter mapping but there doesn’t seem to be a way to overwrite the body. Only header.* The old v1 REST API gateway had mapping templates, but I can’t find anything like that for V2

Is there a way to do this that I'm missing?

3回答
0
承認された回答

Hi,

Unfortunately it is not possible to receive just the value of the output field from the StepFunctions execution, since it is the expected response format of the StartSyncExecution API operation. As you say, you could filter it using the integration response, but this is just supported on the REST API.

Finally, note that both REST APIs and HTTP APIs are valid RESTful API products, and you should chose depending on your use case needs.

profile picture
エキスパート
回答済み 8ヶ月前
profile picture
エキスパート
レビュー済み 15日前
  • This is an extreme bummer. I hope aws folks are working on a way to make it easy to have API Gateway more seamlessly call Step Functions where a proper response can be had from the Step Function. For now we have to add a Lambda just to act like a proxy.

    And we just realized that the proxy lambda has to keep running (and adding cost) so it can send the response back to the API Gateway

0

Should it be possible to do this with the OpenAPI x-amazon-apigateway-integration and the v2 API HTTP Gateway as per the article How to Build Lightning Fast APIs with AWS Step Functions? It's not clear to me if they are using the v2 API Gateway or not. I might try this when I get a chance.

profile picture
回答済み 8ヶ月前
  • Hi,

    They are using a mapping template (a script expressed in Apache Velocity Template Language) to modify the request and response body, but that is only supported on REST API. HTTP APIs just allows to modify headers or the status code of a response.

0

There is no way to do payload transformation in HTTP API (v2), only in REST API (v1).

profile pictureAWS
エキスパート
Uri
回答済み 8ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ