7

I am new to Serverless and AWS SAM. I have tried creating a template.yaml for my new lambda functions and api gateway's of my application and deployed to AWS using AWS SAM. It worked fine. But my question is for every deploy, we got to create new cloud formation stack but is there a way we can update the individual lambda codes for a function without deploying whole stack using AWS SAM?

I did check Serverless framework as well in which we can use below command to individually deploy lambda function without creating new stack serverless deploy function -f functionName

Is there any such flexibility using SAM ?I did check SAM CLI which provides local environment for testing the api's and lambda functions, but haven't seen any individual deploy function for lambda. Could someone help me out?

merla
  • 489
  • 1
  • 5
  • 12
  • 2
    When you re-deploy an already existing cloud formation stack with some changes, only the resources with changes will be affected. It won't create a new stack, it will simply update the existing one with the changes to the template. So if you have a stack with lambda A, and you add lambda B and re-deploy, lambda A will not be affected. – Deiv Jan 23 '19 at 16:35
  • 1
    my question is, I am not going to change the template.but say if I want to update only lambda A code which is already created.How can I individually deploy this lambda function irrespective of the stack deployment – merla Jan 23 '19 at 16:49
  • 4
    If you make a change to the lambda and deploy it alongside the template, then the changes would only affect that lambda. If you want to make the changes without deploying the stack, then you have to manually do so somehow, but it's not recommended. Cloudformation was designed to account for changes made, so if you make changes to the lambda it's best to re-deploy the stack, and let cloudformation take care of what needs updating – Deiv Jan 23 '19 at 16:52
  • @Deiv Thank you for clarification! – merla Jan 23 '19 at 17:12

0 Answers0