What a failed update means#
When you update a function's code or configuration, Lambda provisions an instance of the function and its supporting resources; for a function connected to a VPC this can take a minute. During that time you cannot modify the function, but you can still invoke it. LastUpdateStatus moves from InProgress to Successful or Failed, and two companion fields, LastUpdateStatusReason and LastUpdateStatusReasonCode, explain a failure. UpdateFunctionConfiguration · FunctionConfiguration
Invocations continue to use the function's previous code and configuration until the update completes. AWS's description of a failed update is that the change is aborted and the previous code and configuration remain active. So a failed update is not an outage of the old code. It is a release that did not happen, and a pipeline that reported success may be running yesterday's code. Lambda function states · Tracking the state of Lambda functions
Keep LastUpdateStatus apart from the function's State. State Failed means resource configuration or provisioning failed when the function was created; AWS says you must then delete and recreate the function. A failed update leaves State at Active. Lambda function states
Read the configuration Lambda is running#
Use a read-only profile and replace the uppercase placeholders. This read shows the update result and the settings each reason code points at. get-function-configuration
aws lambda get-function-configuration \
--profile PROFILE --region REGION --function-name FUNCTION_NAME \
--query '{state:State,stateCode:StateReasonCode,update:LastUpdateStatus,updateCode:LastUpdateStatusReasonCode,updateReason:LastUpdateStatusReason,modified:LastModified,version:Version,sha:CodeSha256,package:PackageType,runtime:Runtime,vpc:VpcConfig,fileSystems:FileSystemConfigs,kms:KMSKeyArn,imageError:ImageConfigResponse.Error}' \
--output json --no-cli-pager
CodeSha256 is the SHA-256 hash of the deployment package. Compare it with the artifact your pipeline built: after a failed code update, it tells you which package is live. Add --qualifier ALIAS_OR_VERSION to read a published version or the version an alias points at. Avoid get-function with no query when you share output, because its Code.Location is a presigned download link to the package. FunctionCodeLocation
A pipeline can wait for the result instead of polling. The function-updated waiter reads LastUpdateStatus every five seconds, succeeds on Successful and stops with an error on Failed. wait function-updated
aws lambda wait function-updated \
--profile PROFILE --region REGION --function-name FUNCTION_NAME --no-cli-pager
Sort the reason code#
The API defines a fixed list of LastUpdateStatusReasonCode values but documents them only by name; the details are in the free-text LastUpdateStatusReason. Group the code by the resource it names, then read the reason for the specific subnet, image, key or file system. FunctionConfiguration
| Group | Reason codes | Setting to read next |
|---|---|---|
| VPC and network | EniLimitExceeded, SubnetOutOfIPAddresses, InvalidSubnet, InvalidSecurityGroup, DisallowedByVpcEncryptionControl | VpcConfig subnets and security groups |
| Container image | ImageDeleted, ImageAccessDenied, InvalidImage | The image the function references and its repository's permissions |
| KMS | KMSKeyAccessDenied, KMSKeyNotFound, InvalidStateKMSKey, DisabledKMSKey | KMSKeyArn and that key's state and policy |
| EFS | EFSIOError, EFSMountConnectivityError, EFSMountFailure, EFSMountTimeout | FileSystemConfigs and the file system's network path |
| Function initialization | FunctionError and the FunctionError. codes such as FunctionError.InitTimeout, FunctionError.RuntimeInitError, FunctionError.InvalidEntryPoint | The function's own init logs |
| Role, package and runtime | InsufficientRolePermissions, InvalidConfiguration, InvalidRuntime, InvalidZipFileException | The execution role, the package and Runtime |
| Capacity and quota | ServiceQuotaExceededException, VcpuLimitExceeded, CapacityProviderScalingLimitExceeded, InsufficientCapacity, EC2RequestLimitExceeded, IncompatibleAcceleratorInstanceTypes | Account quotas and the function's capacity settings |
| Other | InternalError, DependencyError | LastUpdateStatusReason |
VPC and network codes name the function's subnets, security groups or network interfaces, so start with the subnets in VpcConfig. describe-subnets shows each one's free IPv4 addresses, and it returns an error for a subnet ID that does not exist. Lambda networking troubleshooting · Subnet fields
aws ec2 describe-subnets \
--profile PROFILE --region REGION --subnet-ids SUBNET_ID_1 SUBNET_ID_2 \
--query 'Subnets[].{subnet:SubnetId,zone:AvailabilityZone,vpc:VpcId,free:AvailableIpAddressCount}' \
--output table --no-cli-pager
Image codes point at the container image. For an image function, Lambda resolves the tag to a digest when you update the code; if you later move the tag in Amazon ECR to a new image, Lambda does not follow it. Read the ResolvedImageUri from get-function --query 'Code.{image:ImageUri,resolved:ResolvedImageUri}' and check that the digest still exists in the repository. UpdateFunctionCode
Init codes mean the new code failed while Lambda prepared it. AWS's troubleshooting page for Lambda Managed Instances says a reason code that begins with FunctionError. means the execution environments failed to initialize. The causes are the ones in the init errors guide: packaging, the handler or entry point setting, and init duration. Troubleshooting Lambda Managed Instances
An illustrative example: two failed updates#
These records are fictional. The function orders-api runs CodeSha256 pQ3e… from build 57. The pipeline deploys build 58.
In the first deploy, the change also moves the function into two new private subnets. get-function-configuration returns State Active, LastUpdateStatus Failed, LastUpdateStatusReasonCode SubnetOutOfIPAddresses, and a reason that names one of the new subnets. CodeSha256 is still build 57's hash. describe-subnets shows AvailableIpAddressCount 0 for that subnet, which a batch job filled an hour earlier. The code in build 58 was never tested in production. Fix the subnet choice and deploy again.
In the second, orders-api is an image function. The reason code is ImageAccessDenied. Build 58 pushed its image to a new repository whose policy, in this fixture, does not allow the pull. The image is fine; the repository permission is the fix.
In both cases, orders-api kept serving build 57 throughout. An error rate that looks normal after the deploy is consistent with the new code never running.
Confirm on the next update#
After the fix, deploy again and wait for function-updated. Then check three things in get-function-configuration: LastUpdateStatus is Successful, CodeSha256 matches the new build, and the settings you changed are present. If you publish versions, publish only after the waiter succeeds, and read State on the new version; the published-version-active waiter does that. Then move the alias. Lambda waiters
Where the status misleads#
LastUpdateStatusdescribes only the last update. A later successful update replaces it, and the failed reason is gone. Record it when the pipeline fails.- The reason codes say which resource failed, not why.
ImageAccessDenieddoes not say which policy denies the pull, andInsufficientRolePermissionsdoes not name the missing action; the reason text sometimes does. - An alias or a published version is not updated by a change to the unpublished function. If your traffic goes through an alias, read the version it points at with
--qualifieras well. - A function that stays idle can move to
Inactive; invoking it reactivates it. That is aStatechange, not a failed deploy.
For how this signature fits with the other AWS deployment services, see the signature table.
Questions#
Does a failed Lambda update take my function down?
No. Invocations continue to use the previous code and configuration until an update completes, and a failed update leaves the previous version active. The risk is that your pipeline treats the release as live when it is not.
What is the difference between Lambda State Failed and LastUpdateStatus Failed?
State Failed means the function's resources failed to provision when it was created, and AWS says to delete and recreate it. LastUpdateStatus Failed means a later code or configuration update failed while the function stayed Active.
How do I make my pipeline fail when a Lambda update fails?
Run aws lambda wait function-updated after the update. It succeeds on Successful and returns an error on Failed, so the pipeline step fails at the right point.