Serverless is not able to create IAM role and lambda function after deleting them

I have deployed a lambda function using serverless which created a IAM role and lambda function for me, I manually deleted them from my aws console, when try to redeploy again using serverless, it is throwing an error

Serverless Error ---------------------------------------

 An error occurred while provisioning your stack: HelloLambdaFunction
 - Template error: IAM role aws-nodejs-dev-us-east-1-lambdaRole
 doesn't exist.

I dont know if this is a bug or something, so posted here instead of creating a github issue

If you manually delete resources then Cloud Formation won’t re-create them for you. You generally have three options available.

  1. Manually re-create the resource. This only works for resource identified by name which I think includes IAM.
  2. Remove all references to the resource then deploy. Add the resource back then deploy again. I’ve used this to fix accidentally deleted DynamoDB tables.
  3. Use sls remove to completely remove the application and deploy a new copy.
3 Likes

Thanks, I followed I first one

@buggy I followed the 3rd options it works. Thanks