Skip to content
Latchkey

aws lambda update-function-code: Deploy Lambda in CI

Push new Lambda code from a local zip or a container image.

aws lambda update-function-code replaces a function's code with a new zip package or container image. In CI it deploys the build artifact directly; pair --publish to create an immutable version for aliasing.

Common flags

  • --function-name - the function to update (required)
  • --zip-file fileb://function.zip - deploy a local zip (note fileb://)
  • --image-uri - deploy a container image from ECR
  • --s3-bucket / --s3-key - deploy a zip already uploaded to S3
  • --publish - publish a new immutable version

Example in CI

Deploy a zipped build and publish a version.

shell
aws lambda update-function-code --function-name my-api --zip-file fileb://function.zip --publish

Common errors in CI

  • An error occurred (ResourceNotFoundException) - function name does not exist in this region
  • An error occurred (RequestEntityTooLargeException) - zip over 50MB direct upload; use --s3-bucket
  • An error occurred (AccessDeniedException) - role lacks lambda:UpdateFunctionCode
  • Error parsing parameter zip-file - used file:// instead of fileb:// for binary

Key takeaways

  • Use fileb:// (not file://) for the binary zip payload.
  • Direct zip uploads cap at 50MB; deploy via --s3-bucket for larger packages.
  • Add --publish to create an immutable version for alias-based deploys.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →