What is the difference between AWS and AWS_PROXY in a CloudFormation template with a AWS::ApiGateway::Method - Integration:Type, with a Lambda backend? I was constantly getting 502 errors just now and realized that I needed to respond with a very specifically formatted JSON response. When I created API Gateways from the console I never bumped into this issue. It does work now but I want to know the underlying differences so I can learn.
Here's the part from the CF Template:
VisitorCounterAPIGatewayRootMethod:
Type: AWS::ApiGateway::Method
Properties:
AuthorizationType: NONE
HttpMethod: GET
Integration:
IntegrationHttpMethod: POST
Type: AWS_PROXY #THIS is my question. AWS or AWS_PROXY?
Uri: !Sub
- arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${lambdaArn}/invocations
- lambdaArn: !GetAtt VisitorCountLambda.Arn
ResourceId: !GetAtt VisitorCounterAPIGateway.RootResourceId
RestApiId: !Ref VisitorCounterAPIGateway
And here's the response code from my Lambda function (Python3.7):
apiResponse = {
"isBase64Encoded": False,
"statusCode": 200,
"body": json.dumps({
"visitorCount": int(float(response["Attributes"]["amount"]))
})
}
Thank you.