Open danyfedorov opened 4 years ago
If useful to others: until payload version 2 is supported we can get this to work by specifying version 1 like this:
ApiFunction:
Type: AWS::Serverless::Function
Properties:
# ...
Events:
Http:
Type: HttpApi
Properties:
PayloadFormatVersion: '1.0'
This is the file that needs changes, ya? https://github.com/dougmoscrop/serverless-http/blob/master/lib/provider/aws/create-request.js
If someone can confirm, I can take a stab at this.
I believe the example from @mpvosseller above is for SAM.
If using the serverless framework, the following is a workaround:
resources:
Resources:
Overrides:
Type: AWS::ApiGatewayV2::ApiGatewayManagedOverrides
Properties:
ApiId:
Ref: "HttpApi"
Integration:
PayloadFormatVersion: '1.0'
@TehNrd
With your workaround, I got an error: The CloudFormation template is invalid: Template format error: Unresolved resource dependencies [HttpApi] in the Resources block of the template
Do you have any guess how this could be solved?
@Frans-L What does the rest of your serverless.yml file look like?
@TehNrd
Thanks for helping out. Here is the whole serverless.yml
service:
name: test
app: something-test
org: something
custom:
webpack:
webpackConfig: ./webpack.config.js
includeModules: true
plugins:
- serverless-webpack
- serverless-offline
provider:
name: aws
runtime: nodejs12.x
region: eu-west-3
apiGateway:
minimumCompressionSize: 1024
environment:
AWS_NODEJS_CONNECTION_REUSE_ENABLED: 1
functions:
app:
handler: src/app.handler
events:
- http: ANY /
- http: "ANY /{proxy+}"
@Frans-L You aren't using the new httpApi event. What you have there will create a normal REST API. need to change http
to httpApi
Once you do this you might also need to change the paths as I'm not sure those are valid for httpApi. I think you only need httpApi: '*'
And if you have an Custom Domain sitting in front of this it also needs to be a Regional domain name.
https://serverless.com/framework/docs/providers/aws/events/http-api/
Hmm, so my workaround above isn't working anymore and I am now receiving the following error on deployment.
An error occurred: Overrides - ApiGatewayManagedOverrides can only be associated to APIs created via quick create (Service: null; Status Code: 0; Error Code: null; Request ID: null) (Service: null; Status Code: 404; Error Code: BadRequestException; Request ID: null).
Not sure what changed, maybe something internal to the way serverless framework does deploy.
I started on a PR fix but stopped after finding the workaround, I'll get PR submitted soon.
Hmm, maybe I'm going crazy. Looks like Serverless Framework is setting 1.0 payload and has been for a while.
Not sure how mine got set to 2.0 for my deployment but would still be great it if both were supported so I'll continue on the PR.
PR Submitted! https://github.com/dougmoscrop/serverless-http/pull/150
Definitely open to feedback. :-)
@TehNrd Could this be also due different payload version support. Also how can i check which setting mine api gateway is using
@niteshgrg Not sure if that is related, but here is where you check payload version.
There are also some CORS specific settings you may need to edit as well for your particular issue.
this issue can be closed now ?
I have discovered another scenario for the error ApiGatewayManagedOverrides can only be associated to APIs created via quick create
. This can happen whenTarget
is missed AWS::ApiGatewayV2::Api
, the result is ApiGatewayManagedOverrides
no knowing what to do and throws the above error
curious why no serverless-http
in `plugins' section?
Link with info about version 1 vs version 2.
https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html