Consider the two main responsibilities of the plugin:
Create a lambda function with an alias.
Make an API Gateway entry (like GET /user) which points to that specific alias of the lambda functions (like users:dev)
This works fine if your service fits into one serverless.yml file. But if it does not, based on the documentation easiest way is to manually split your file. Here's an example:
Both these files could be deployed like this (one at a time):
$ sls deploy --region us-east-1 --stage dev --alais dev
And they have to be deployed in the given order. The first one just creates the API Gateway and outputs its ID so it can later be picked up by the second service. The problem is when I deploy the second service, while it creates the lambda function, its alias and the API entry /user but the API entry is pointing to the lambda function without the alias.
Of course, if there's only one file everything will be created as it should and the API entry /user will invoke the lambda function with alias users:dev.
Consider the two main responsibilities of the plugin:
GET /user
) which points to that specific alias of the lambda functions (likeusers:dev
)This works fine if your service fits into one serverless.yml file. But if it does not, based on the documentation easiest way is to manually split your file. Here's an example:
api-gateway/serverless.yml:
users/serverless.yml:
Both these files could be deployed like this (one at a time):
And they have to be deployed in the given order. The first one just creates the API Gateway and outputs its ID so it can later be picked up by the second service. The problem is when I deploy the second service, while it creates the lambda function, its alias and the API entry
/user
but the API entry is pointing to the lambda function without the alias.Of course, if there's only one file everything will be created as it should and the API entry
/user
will invoke the lambda function with aliasusers:dev
.