Rahul
Rahul

Reputation: 185

How to rename the aws lambda function without changing anything in it

Earlier my function in serverless was:

functions:
    fun:
        handler: file.handler
        name: ${opt:stage, self:provider.stage}-lambda-fun
        environment: ${file(env.yml):${self:provider.stage}.lambda-fun}
        timeout : 180
        memorySize : 1024

I want to change fun with some meaningful name, So I changes it as:

Earlier my function in serverless was:

functions:
    my-fun:
        handler: file.handler
        name: ${opt:stage, self:provider.stage}-lambda-fun
        environment: ${file(env.yml):${self:provider.stage}.lambda-fun}
        timeout : 180
        memorySize : 1024

Now When I deployed this function through serverless, Got the below error:

An error occurred while provisioning your stack: my-funLogGroup - /aws/lambda/lambda-fun already exists

Please help me What I can do more to do this.

Upvotes: 4

Views: 3710

Answers (2)

lucrodriguezba
lucrodriguezba

Reputation: 11

It's not the exact same issue but this github issue gives an alternative soulution: Cannot rename Lambda functions #108

I commented the function definition I wanted to rename and the resources with references to it, then sls deploy , uncommented and sls deploy again.

The problem with this is that the first deploy will delete the function so you have to take into account this down time.

Upvotes: 1

Manoj
Manoj

Reputation: 2434

Try removing the stack first using serverless remove and then redeploy.

Upvotes: 4

Related Questions