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 --publishCommon 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
aws lambda invoke: Invoke a Lambda Function in CIaws lambda invoke runs a Lambda function and captures its response. Learn the payload, log-type, and cli-bina…
aws cloudformation deploy: Deploy a Stack in CIaws cloudformation deploy creates or updates a stack via change sets. Learn the parameter-overrides and capab…
aws iam create-role: Create an IAM Role for CIaws iam create-role creates an IAM role with a trust policy - including the OIDC trust used by GitHub Actions…