serverless-heaven / serverless-aws-alias

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

Cannot rename Lambda functions #108

Closed elison-chen closed 6 years ago

elison-chen commented 6 years ago

I get a serverless error when renaming Lambda functions.

For example I have the Lambda function:

functions:
  readingsEmulator:
    name: readings-emulator-${{self:provider.stage}}
    handler: cloud/readings_emulator/readings_emulator.handler

Then I want to change the name (prepending 'gg-')

functions:
  readingsEmulator:
    name: gg-readings-emulator-${{self:provider.stage}}
    handler: cloud/readings_emulator/readings_emulator.handler

When I run my deploy I get the following error:

An error occurred: farm-test - Export farm-test-ReadingsEmulator-LambdaFunctionArn cannot be updated as it is in use by farm-test-test.

What can I do to rename the function? Is it supported?

HyperBrain commented 6 years ago

Hi @elison-chen . Renaming is not supported for this reason: A function can be deployed to different aliases and each of the alias stack references its function arn to protect it from deletion / or renaming in your case. If a function would be renamed its arn would change and thus all aliases referencing that function would break.

Imo the best way is to deprecate a function add a new one (with a new name) and remove the old one from the aliases one after the other. The removal does not have to happen all at once - the function will be removed as soon as the last alias drops it.

elison-chen commented 6 years ago

@HyperBrain Thank you for the quick reply and solution :)