Lambda function states - AWS Lambda (original) (raw)

Lambda includes a State field in the function configuration for all functions to indicate when your function is ready to invoke. State provides information about the current status of the function, including whether you can successfully invoke the function. Function states do not change the behavior of function invocations or how your function runs the code.

In many cases, a DynamoDB table is an ideal way to retain state between invocations since it provides low-latency data access and can scale with the Lambda service. You can also store data in Amazon EFS for Lambda if you are using this service, and this provides low-latency access to file system storage.

Function states include:

If you are using SDK-based automation workflows or calling Lambda’s service APIs directly, ensure that you check a function's state before invocation to verify that it is active. You can do this with the Lambda API action GetFunction, or by configuring a waiter using the AWS SDK for Java 2.0.

aws lambda get-function --function-name my-function --query 'Configuration.[State, LastUpdateStatus]'

You should see the following output:

[ "Active", "Successful" ]

The following operations fail while function creation is pending:

Function states during updates

Lambda has two operations for updating functions:

Lambda uses the LastUpdateStatus attribute to track the progress of these update operations. While an update is in progress (when "LastUpdateStatus": "InProgress"):

Example GetFunctionConfiguration response

The following example is the result of GetFunctionConfiguration request on a function undergoing an update.

{
    "FunctionName": "my-function",
    "FunctionArn": "arn:aws:lambda:us-east-1:123456789012:function:my-function",
    "Runtime": "nodejs22.x",
    "VpcConfig": {
        "SubnetIds": [
            "subnet-071f712345678e7c8",
            "subnet-07fd123456788a036",
            "subnet-0804f77612345cacf"
        ],
        "SecurityGroupIds": [
            "sg-085912345678492fb"
        ],
        "VpcId": "vpc-08e1234569e011e83"
    },
    "State": "Active",
    "LastUpdateStatus": "InProgress",
    ...
}