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달 전

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

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

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

관련 콘텐츠