Ship New Code and Cut an Immutable Version
A 4-step recipe with AWS Lambda. We can help you get access.
Recipe · 4 steps
Ship New Code and Cut an Immutable Version
with AWS Lambda · IT Infrastructure Management
Update function code, verify it, and publish a hash-guarded immutable version.
- Replace the code of the unpublished $LATEST version with the new package. Publish is false because the version is only cut after the smoke test passes, and DryRun is false so the code is actually written.
- Poll the configuration until LastUpdateStatus reports "Successful". Until then Lambda is still provisioning the new code and a published version would snapshot the previous package.
- Invoke the unpublished $LATEST version synchronously to confirm the new code actually runs before it is frozen into a version. Qualifier is deliberately omitted: with no qualifier Lambda invokes $LATEST, which is exactly the code that was j
- Publish an immutable version. CodeSha256 is passed as a guard: Lambda publishes only if the current code hash still matches the package that was just uploaded and tested, so a concurrent deploy cannot be snapshotted by accident.
What you'll need to have ready
- functionName: The name or ARN of the function to update.
- s3Bucket: The S3 bucket holding the new deployment package ZIP.
- s3Key: The S3 key of the new deployment package ZIP.
- s3ObjectVersion: Optional S3 object version of the deployment package, when the bucket is versioned.
- versionDescription: Description recorded against the published version (e.g. a git SHA or release tag).
- smokeTestPayload: The JSON event used to smoke-test the new code before a version is cut.
For your developer
Arazzo workflow aws-lambda:update-code-publish-version, 4 operations: UpdateFunctionCode → GetFunctionConfiguration → Invoke → PublishVersion. Specs on APIs.io.