serverless: HTTP Events, cannot add methods for root `/`endpoint
Serverless Framework Version:
1.0.0-alpha.2
Operating System:
OSX 10.11.6
Expected Behavior:
I would expect that I would be able to somehow deploy a method against the root / endpoint. Seems like validations block this from happening? Either that or I missed in the docs how to handle this.
Actual Behavior:
functions:
render:
handler: handler.render
timeout: 6
events:
- http:
path: /
method: get
♪ sls deploy
Serverless: Zipping service...
Serverless: Removing old service versions...
Serverless: Uploading .zip file to S3...
Serverless: Updating Stack...
Validation Error ---------------------------------------
Template format error: Unresolved resource dependencies
[ResourceApigEvent] in the Resources block of the template
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 6
- Comments: 41 (10 by maintainers)
Commits related to this issue
- Allow root method endpoints - proof of concept fix #1738 — committed to nathanlenz/serverless by deleted user 8 years ago
- Allow root method endpoints - proof of concept fix #1738 — committed to davidjnelson/serverless by deleted user 8 years ago
on four get, put , delete, post routes gives me
So based on this from cloud formation:
It appears it may not be possible to attach to the root path with cloud formation
Ah, gotcha. Sorry I thought this was a workaround for that bug! Thanks for confirming it’s still open.
@nathanlenz @jatsrt could you open a quick pull request to see your changes? This would make it easier to look into it and see what we can introduce or what other potential issues could lurk there.
Thanks for looking into this btw!
That’s only possible though a custom domain mapping
I met the same error and finally fixed by add an extra http api gateway trigger:
https://github.com/Jeff-Tian/serverless-space/commit/c86fc59c9c04cd1625c37b4cb7849e2cb0a2dbfa
@bbilger, I’m trying with serverless v1.0.3 with the syntax you described but get the following error:
My serverless.yml:
Am I missing something obvious?
Following these instructions certainly works: http://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-custom-domains.html#how-to-custom-domains-mapping-console
The result if you use an empty base path and specify the environment you are working with is that you get:
https://–hostname–/–endpointname–
which does not have the environment as part of the path. So, the pull request stripping the endpoint name along with following the Custom Domain Mapping guide should make root paths a reality!
I got it working also (sorta). Using your changes. Plus, I had to set the PathPart of the unused resource to something in order to get it to take. It creates the unneeded resource, but actually attaches the lambda function to the / GET.
it’s not pretty but it works
For cases where path === ‘/’
You would have to instead use: