How to create aliases for lambda functions and stages in API gateway using serverless?

I am trying to deploy lambda function, written in java, using serverless framework. But I am not getting how to create aliases for lambda function and different stages in API gateway using sererless.yml file.

I have mentioned aliases in my serverless.yml file.

part of serverless.yml:

functions:
hello:
handler: com.serverless.Handler

events:
  - http: 
      path: service
      method: post 
   
aliases:
   - FirstFunction

Still, It’s not working. Even I tried serverless deploy --alias myAlias command as mentioned on this page https://www.npmjs.com/package/serverless-aws-alias

Can anyone tell me, how to create aliases for lambda function and stages in API Gateway?

1 Like

I know this is quite an old question, and I hope you have figured it out already. In case you haven’t, what you’re missing is including the plugin in your YAML file.

// serverless.yml
...
plugins:
  - serverless-aws-alias

...

You do not need the aliases property and it should be removed.

1 Like