AWS SAM- Can we deploy code for a single function without deploying the whole stack?
Asked Answered
E

0

8

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?

Erikerika answered 23/1, 2019 at 16:32 Comment(4)
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.Deadlight
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 deploymentErikerika
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 updatingDeadlight
@Deadlight Thank you for clarification!Erikerika

© 2022 - 2024 — McMap. All rights reserved.