I am using the sam deploy
command with the AWS SAM command line tool to deploy.
Now I made some changes with the web IDE in the AWS Console.
How can I pull the changes to the local machine, so that the next sam deploy
command won't override them? (I am looking for something similar to a git pull I guess)
How can I download/pull lambda code to a local machine from command line?
2.3k views Asked by Crocodile At
2
There are 2 answers
0
On
You should have a single source of truth for your source code. And that should really be your source control repository (Git). If you make changes to your source code in the web IDE then you should copy those changes into your Git repo.
To your original question, to download a Lambda function's source code from the command line, you would use the aws lambda get-function --function-name
command to download information about the function. Part of the information included in the response is a URL to download the function's deployment package, which is valid for 10 minutes. Then you could download the deployment package at that URL using something like curl
.
To do this you will need to use the AWS CLI, the start of this process will require you to use the get-function function in the AWS CLI.
This will return a pre signed URL in the
Code
>Location
structure, if you then download this (using a CLI tool such ascurl
) you can then download a zip file containing the contents of the Lambda function.The expected function would look similar to the below