serverless-step-functions icon indicating copy to clipboard operation
serverless-step-functions copied to clipboard

Handle Output Transformations

Open andrewhertog opened this issue 6 years ago • 4 comments

This is a Feature Proposal

Description

For feature proposals:

  • What is the use case that should be solved. The more detail you describe this in the easier it is to understand for us.
  • If there is additional config how would it look

API Gateway allows users to modify the response body and headers based on content from the response from lambda, or the step functions. In the case of the step functions the output always appears to be: { "executionArn": "arn:aws:states:us-east-1:111111111111:execution:Name:ID", "startDate": epochTimeStamp }

I would like to be able to suppress this output and change the http response code to 201 or 204.

andrewhertog avatar Jan 02 '18 14:01 andrewhertog

Thank you for the proposal @andrewhertog :+1: Sounds a good idea, but you cannot implement the feature since there is a restriction on AWS end. The output body is generated automatically on AWS side, so we are not really sure how to customize the response code.

We would love to get any feedback how to implement it :smile:

horike37 avatar Jan 03 '18 09:01 horike37

Perhaps you try like you did with IntegrationRequest? If I add this to the resources this seems to work

    ApiGatewayMethodSubscriptionBrandVarPost:
      Properties:
        Integration:
            IntegrationResponses:
              - StatusCode: 200
                SelectionPattern: '[1-5]\d\d'
                ResponseTemplates:
                  application/json: '{"rules":[]}'

With ApiGatewayMethodSubscriptionBrandVarPost being defined als the stepfunction http event

xonstone avatar Aug 02 '18 13:08 xonstone

@issuehuntfest has funded $20.00 to this issue. See it on IssueHunt

IssueHuntBot avatar Dec 06 '18 10:12 IssueHuntBot

@horike37 @xonstone Has this gone anywhere? I need to modify the Integration Response as well.. had no luck so far figuring it out.

EDIT: okay, got it to work, LOL

  ApiGatewayMethodVersionPost:
    Type: AWS::ApiGateway::Method
    Properties:
      Integration:
        IntegrationResponses:
          - StatusCode: 200
            ResponseTemplates:
              application/json: '{"key":"value"}'
      ResourceId:
        Ref: ApiGatewayResourceVersion
      RestApiId:
        Ref: ApiGatewayRestApi

kotowick avatar Jul 30 '19 20:07 kotowick