关于AWS Lambda函数中Deploy与Publish的差异及相关问题咨询
Great question—this is a super common point of confusion when working with Lambda, so let’s break down the differences and your follow-up questions clearly.
Core Definitions
First, let’s get the basics straight:
- Deploy: This is the act of uploading your updated code (or container image) to Lambda. When you deploy, you’re updating the unpublished, mutable version of your function, known as
$LATEST. Think of$LATESTas your "draft" version—you can overwrite it as many times as you want during development, and it’s not meant for production use (since it can change unexpectedly). - Publish: This turns a specific version of your function (usually
$LATEST) into an immutable, numbered release (likev1,v2, etc.). Once published, this version can never be modified—each has a unique ARN, and it’s a fixed snapshot of your code at the time of publishing. This is what you’ll use for production, since it’s stable and predictable.
Your Follow-Up Questions
1. If I only run Deploy, will consuming services pointing to the "latest" function version use the updated code?
Yes—if those services are referencing either:
- The
$LATESTversion directly, or - An alias that’s configured to point to
$LATEST
When you deploy, you’re overwriting $LATEST with your new code, so any traffic targeting $LATEST will immediately start using the updated function. That said, if your consuming services are pointing to a specific numbered version (like v3), deploying won’t affect them at all—those immutable versions stay exactly as they were published.
2. If I only run Publish, will deployment happen automatically?
No—publishing alone doesn’t make your new version active for traffic. Publishing just creates a fixed snapshot of your code, but you still need to route traffic to it. For example:
- If your API Gateway is configured to trigger
v3of your function, publishingv4won’t change that—traffic will still go tov3. - To make the published version live, you’ll need to either:
- Update your alias (like
PROD) to point to the new numbered version, or - Reconfigure your triggers/consuming services to use the new version’s ARN.
- Update your alias (like
Quick Real-World Example
Here’s how this flows in practice:
- You deploy updated code to
$LATESTand test it manually. - Once it’s working, you publish
$LATESTasv4. - You update your
PRODalias fromv3tov4—now production traffic starts using the new version. - If you find a bug, you can quickly switch the
PRODalias back tov3while you fix the issue.
内容的提问来源于stack exchange,提问作者variable

