
This assumes you have already configured the aws command line tool. If not, check out my article on Getting Started with the AWS CLI.
The aws lambda list-functions command can be used to list the Lambda Functions you have created.
aws lambda list-functions
Something like this should be returned.
{
"Functions": [
{
"TracingConfig": {
"Mode": "PassThrough"
},
"Version": "$LATEST",
"CodeSha256": "/ur2jHd199ldQbP+Y20sw3kIHhaWwnPY6CQvSwZ6Kco=",
"FunctionName": "myfunction",
"MemorySize": 128,
"RevisionId": "741c094a-cff2-4cdb-a5b6-110a900e1a43",
"CodeSize": 529507,
"FunctionArn": "arn:aws:lambda:us-east-1:123456789012:function:myfunction",
"Handler": "app.lambda_handler",
"Role": "arn:aws:iam::123456789012:role/myfunction",
"Timeout": 3,
"LastModified": "2023-11-16T02:52:04.978+0000",
"Runtime": "python3.9",
"Description": ""
}
]
}
You can:
- use the aws lambda update-function-configuration command to update your Lambda Function configuration
- use the aws lambda update-function-code command to update your Lambda Function code (this article)
Let's say you want to make a change to the function code. You could download a .zip file of the function from the AWS console. This should get you a zip file that contains the Lambda Function, something like this.
/path/to/lambda.zip
You can unzip the file.
unzip /path/to/lambda.zip -d /tmp/lambda
The extract should contain the contents of the .zip file, which is just a single lamba_function.py Python file in this example.
/tmp/lambda/lambda_function.py
Let's say you make a change to lambda_function.py. You would then create a zip file containing lambda_function.py.
zip lambda.zip /tmp/lambda/lambda_function.py
And then use the aws lambda update-function-code command to deploy the updated lambda.zip file.
]$ aws lambda update-function-code --function-name myfunction --zip-file fileb://lambda.zip
{
"FunctionName": "myfunction",
"FunctionArn": "arn:aws:lambda:us-east-1:123456789012:function:myfunction",
"Runtime": "python3.11",
"Role": "arn:aws:iam::123456789012:role/service-role/my-role",
"Handler": "lambda_function.lambda_handler",
"CodeSize": 1819,
"Description": "",
"Timeout": 3,
"MemorySize": 128,
"LastModified": "2023-12-15T02:54:28.000+0000",
"CodeSha256": "5kHtMyCmdf31fSnR+BaNYhOn59MQp20WHvTJD9W6bCI=",
"Version": "$LATEST",
"TracingConfig": {
"Mode": "PassThrough"
},
"RevisionId": "8bfcca82-e6e0-45e6-a198-67d5eba142d6",
"Layers": [
{
"Arn": "arn:aws:lambda:us-east-1:myfunction:layer:mylayer:1",
"CodeSize": 393575
}
],
"State": "Active",
"LastUpdateStatus": "InProgress",
"LastUpdateStatusReason": "The function is being created.",
"LastUpdateStatusReasonCode": "Creating",
"PackageType": "Zip",
"Architectures": [
"x86_64"
],
"EphemeralStorage": {
"Size": 512
},
"SnapStart": {
"ApplyOn": "None",
"OptimizationStatus": "Off"
},
"RuntimeVersionConfig": {
"RuntimeVersionArn": "arn:aws:lambda:us-east-1::runtime:a3304f2b48f740276b97ad9c52a9cc36a0bd9b44fecf74d0f1416aafb74e92fc"
}
}
Did you find this article helpful?
If so, consider buying me a coffee over at