This section explains various other operations associated with lambda.
Lambdas can have aliases. The precondition is to have a lambda with valid version.
Lets create an alias for helloLambdaCLIWorld.
➜ aws lambda create-alias --function-name helloLambdaCLIWorld \
--profile "$AWS_PROFILE" \
--function-version "1" \
--name "cliLambda"output : Notice the alias has an ARN of its own.
{
"AliasArn": "arn:aws:lambda:us-east-1:919191919191:function:helloLambdaCLIWorld:cliLambda",
"Name": "cliLambda",
"FunctionVersion": "1",
"Description": "",
"RevisionId": "a123b456-789c-0123-4def-g5hij6k789l0"
}The aliases for a lambda can be listed as below.
➜ aws lambda list-aliases --function-name helloLambdaCLIWorld --profile "$AWS_PROFILE"output : Notice the alias has an ARN of its own.
{"Aliases": [{
"AliasArn": "arn:aws:lambda:us-east-1:919191919191:function:helloLambdaCLIWorld:cliLambda",
"Name": "cliLambda",
"FunctionVersion": "1",
"Description": "",
"RevisionId": "123b9999-a1bb-3456-9a3b-777r2220a222"
}]}The alias can be updated to a different version of the lambda.
➜ aws lambda update-alias --name cliLambda \
--function-name helloLambdaCLIWorld \
--profile "$AWS_PROFILE" \
--function-version 2output : Notice the alias has an ARN of its own.
{
"AliasArn": "arn:aws:lambda:us-east-1:919191919191:function:helloLambdaCLIWorld:cliLambda",
"Name": "cliLambda",
"FunctionVersion": "2",
"Description": "",
"RevisionId": "a123b456-789c-0123-4def-g5hij6k789l0"
}Following will delete the aliases that we created in last few steps.
➜ aws lambda delete-alias --function-name helloLambdaCLIWorld --name cliLambda
Account level information like function count, code size etc., can be obtained as below.
➜ aws lambda get-account-settings --profile "$AWS_PROFILE"output : Notice the ConcurrentExecutions and UnreservedConcurrentExecutions. This is our next topic.
{
"AccountLimit": {
"TotalCodeSize": 60556036800,
"CodeSizeUnzipped": 162144000,
"CodeSizeZipped": 32426600,
"ConcurrentExecutions": 1000,
"UnreservedConcurrentExecutions": 1000
},
"AccountUsage": {
"TotalCodeSize": 14122429,
"FunctionCount": 28
}
}Concurrency is the number of instances in execution for a given lambda, at any given time. Concurrency limits are region specific.
Following command will reserve concurrency limit for a given function
➜ aws lambda put-function-concurrency \
--function-name helloLambdaCLIWorld \
--reserved-concurrent-executions 100 \
--profile "$AWS_PROFILE"
output :
{ "ReservedConcurrentExecutions": 100 }
Now, if you look at UnreservedConcurrentExecutions in account settings, it would have reduced by 100 to 900.
➜ aws lambda get-account-settings --profile "$AWS_PROFILE"
{
"AccountLimit": {
"TotalCodeSize": 60556036800,
"CodeSizeUnzipped": 162144000,
"CodeSizeZipped": 32426600,
"ConcurrentExecutions": 1000,
"UnreservedConcurrentExecutions": 900
},
"AccountUsage": {
"TotalCodeSize": 14122429,
"FunctionCount": 28
}
}
➜ aws lambda delete-function-concurrency --function-name helloLambdaCLIWorld --profile "$AWS_PROFILE"
This will bring the UnreservedConcurrentExecutions back to 1000.
Lambda can be deleted as below. We will delete the formatCurrencyLambda created in (4).
➜ aws lambda delete-function --function-name helloLambdaCLIWorld --profile "$AWS_PROFILE"
🏁 Congrats ! You learnt the basic functions for managing AWS Lambda. 🏁
Next: Integrate with S3