Skip to content
Latchkey

aws lambda update-function-code: Usage & CI Errors

Ship new Lambda function code from a zip or a container image.

aws lambda update-function-code replaces a function’s deployment package with a new zip or container image. It updates only the code, not configuration, making it the core of a simple Lambda deploy step.

What it does

The command points an existing function at new code: a local zip (--zip-file fileb://...), a zip already in S3 (--s3-bucket/--s3-key), or a new container image (--image-uri). It returns immediately but the update is asynchronous - use --publish to cut a version, and wait for the function to become Active before invoking.

Common usage

Terminal
# Deploy a local zip
aws lambda update-function-code \
  --function-name my-fn \
  --zip-file fileb://function.zip --publish

# Deploy a container image
aws lambda update-function-code \
  --function-name my-fn \
  --image-uri 123456789012.dkr.ecr.us-east-1.amazonaws.com/my-fn:latest

# Wait until the update finishes
aws lambda wait function-updated --function-name my-fn

Common error in CI: ResourceConflictException / update in progress

Back-to-back deploys fail with "ResourceConflictException: The operation cannot be performed at this time. An update is in progress" or "Pending" state errors when a second update races the first. Fix: gate the next step on aws lambda wait function-updated --function-name <name> after each code/config change. A different error, "fileb:// not found / InvalidParameterValueException", means you used file:// (text) instead of fileb:// (binary) for the zip. Lambda zips must use fileb://.

Key options

OptionPurpose
--function-nameRequired function name or ARN
--zip-file fileb://Local zip package (binary read)
--s3-bucket / --s3-keyDeploy a zip already in S3
--image-uriDeploy a container image
--publishPublish a new version

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →