serverless-heaven / serverless-aws-alias

Alias support for Serverless 1.x
MIT License
189 stars 68 forks source link

Alias always generates same stack #69

Closed xavicolomer closed 7 years ago

xavicolomer commented 7 years ago

Hi there,

Serverless version: 1.17

For some reason I am always generating the same stack no matter what Alias I put on. I followed the installation instructions and it seems the Alias plugin is giving some feedback while deploying, but its always deploying / overwriting the same content with the same endpoints

I created first the first stage deploy serverless deploy

And then I tried to create aliases for v1 serverless deploy --alias v1

and v2 serverless deploy --alias v2

But I always end up overwriting the API Gateway, Lambdas and everything POST - https://{same_endpoint}.execute-api.eu-west-1.amazonaws.com/...

More info

  1. In my lambda console I only have one version of the lambdas, I would expect to have one version per alias, is that right?

  2. Reading your I understand that API Gateway should contain as many initial resources as aliases and then the master API hanging from there although it doesn't, but this is just a guess

/
  /v1
    /my
      /master
        /api
  /v2
    /my
      /master
        /api 
  1. In my .serverless folder I have 2 new files:

cloudformation-template-update-alias-stack.json cloudformation-template-create-alias-stack.json

Both containing information only about the last alias deployed, in this case v2

Any suggestion?

HyperBrain commented 7 years ago

I did the following with the serverless-aws-alias-example project.

git checkout master
npm install
serverless deploy

git checkout authorizer
npm install
serverless deploy --alias=auth

Cloudformation

The deploy created the main and the alias stacks correctly: image

Nevertheless the message emitted by Serverless does not show the actual alias endpoints but this is only a console output issue in SLS. I can try to fix that in the plugin, so that the correct URLs are shown.

endpoints:
  GET - https://ai49k1bvja.execute-api.us-east-1.amazonaws.com/dev/func1
  POST - https://ai49k1bvja.execute-api.us-east-1.amazonaws.com/dev/func1/update

  GET - https://ai49k1bvja.execute-api.us-east-1.amazonaws.com/dev/func2

Lambda

The Lambda functions are also deployed correctly, and the aliases are set to the correct versions. As an example I show the testfct1 which is available in master and authorize (resp. dev and auth aliases). image

API Gateway

Also the APIs have been deployed correctly for each of the deployed aliases. If you have a look at the deployed stages in API Gateway, you see, that even the defined endpoints (which are different in the master and authorizer branches) are deployed correctly. image

Example

You can access the endpoints that are deployed to the different aliases with:

https://xxxxxx.execute-api.us-east-1.amazonaws.com/auth/...
https://xxxxxx.execute-api.us-east-1.amazonaws.com/dev/...

The endpoint in a specific alias will automatically call the correct aliased Lambda function version that is attached to the endpoint in your ' serverless.yml`.

xavicolomer commented 7 years ago

Hi there,

Sorry for not answering before.

You are right, your plugin works great, the output from the deploy was misleading since I didn't saw any changes.

Thanks

joshuaquek commented 4 years ago

This helped a lot. Thanks.

UPDATE: After looking through again, this truly is an amazing plugin.

joshuaquek commented 4 years ago

@HyperBrain from the example you showed above:

My question would be: Is it possible to have two separate AWS lambda resources instead of one AWS lambda resource, but still being able to share the same API Gateway by utilizing the API Gateway's "stage" feature as you did in your example?

Meaning:

Would this be possible?