Setting X-Amz-Invocation-Type Header for Async AWS API Gateway

According to the AWS docs you need to set in the Integration Request header X-Amz-Invocation-Type set to ‘Event’ (using single quotes) and integration type to AWS Service.

  events:
      - http:
          path: sfNotify
          method: POST
          cors: true
          private: true
          integration: lambda
            request:
              passThrough: WHEN_NO_MATCH
              parameters:
                 headers:
                   'X-Amz-Invocation-Type': "'Event'"

The mapped from value created is method.request.header.X-Amz-Invocation-Type not ‘Event’
What am I doing wrong?

Looking at the cloudformation generated:

What needs to be set in RequestParameters I think is :

“integration.request.header.X-Amz-Invocation-Type”: “‘Event’”

Where and how do you set this in the serverless.yml file?

I solved it by overriding the the CF Resource (https://serverless.com/framework/docs/providers/aws/guide/resources/#override-aws-cloudformation-resource)

Functions looks like this:

 sfProxy:
       handler: com.captech.sf.ProxySFHandler
       package:
          individually: true
          artifact: ./sf-proxy/target/sfproxy-1.0-SNAPSHOT.jar
       events:
         - http:
            path: sfNotify
            method: POST
            cors: true
            private: true
            integration: aws
            request:
               passThrough: WHEN_NO_MATCH
               parameters:
                 headers:
                   'X-Amz-Invocation-Type': "'Event'"

Resource to override looks like this:

 resources:
    Resources:
       ApiGatewayMethodSfnotifyPost:
         Type: AWS::ApiGateway::Method
         Properties:
            HttpMethod: POST
            Integration:
              IntegrationHttpMethod: POST
              Type: "AWS"
              RequestParameters:
                  "integration.request.header.X-Amz-Invocation-Type": "'Event'"
1 Like

Can I ask to reformat all codes with proper indentation?

There has been a feature ticket submitted: https://github.com/serverless/serverless/issues/4862