6
votes

Please point me to the documentation where AWS defines $LATEST of the lambda version, or suggest that it is how AWS uses a terminology without defining it.

Clearly AWS lambda documents say $LATEST is a version.

If you haven't published a version of the selected function, the Versions panel lists only the $LATEST version.

Initially I thought it is like HEAD tag pointing to the latest commit in a Git branch. Git commit is immutable, but lambda version is not.

AWS Lambda Function Versions

A version can be published one which is persistent.

The system creates a new version of your Lambda function each time that you publish the function. ... When you publish a version, the code and most of the settings are locked to ensure a consistent experience for users of that version.

But also it can be unpublished that can be changed and saved.

You can change the function code and settings only on the unpublished version of a function.

So I guess is, since I could not find the definition by AWS, that $LATEST is a temporary snapshot of code+runtime+setting which someone has saved at some point in an AWS account, and has not yet been updated and saved.

I suppose it is like work-in-progress transient artifact in a local git repository. We would not know what the code is because someone may be saving it, and we never know what we are executing if we do not use a published, hence immutable, version as the qualifier at invocation.

And personally believe a version should be immutable. It should not be mutable like Lambda $LATEST. Version 1 as of March 19 3PM or version 1 as of March 20 1PM do not make any sense to me. Version 1 must be unique. If change is made, the it must be version 1.1 or 2.0.

Invoke

POST /2015-03-31/functions/FunctionName/invocations?Qualifier=Qualifier HTTP/1.1

Please advise if this is correct understanding, and we should not use $LATEST for invocation unless only one person is working on and testing.

And if it is so, I suppose having $LATEST serves no practical purpose in a proper engineering where we should be able to consistently identify a revision of a code and reproduce the same result if we re-do the same procedure on the revision.


Update

Currently I believe my confusion was because of the inconsistent and possibly wrong naming by AWS.

Version is immutable if published but mutable if not published in which case called $LATEST.

Version can be a snapshot of a lambda function but it can be a integer number.

$LATEST is pointing to the last saved lambda function which can be changed anytime, hence we cannot know for certain what we are executing or looking at if we use $LATEST. $LATEST I see could be different from what someone else sees. It looks to me working on $LATEST is working on a moving target.

AWS has so many strange "gotchas" like ECS capacity provider is immutable and cannot delete once created and if the ECS cluster is deleted, that capacity provider remains there and invisible, causing errors when trying to create a new capacity provider for a new ECS cluster with the same name (the bug which called "as designed" finally fixed though). I believe $LATEST is one of them.

enter image description here

1
I think there is some confusion. versions (e.g. 1, 2, 3) are immutable. That's why you use aliases in your code, as aliases can be changed to point to different versions.If you use versions in your code, anytime you change your lambda and publish new version, you would have to update your client's code.Marcin
Thanks @Marcin, I thought "version" is immutable like "commit" but $LATEST is also called "version" but it is not immutable. So my question is what is $LATEST "version" which is really confusing me.mon
Searched Lambda Developer Guide PDF top to bottom but could not find a definition what it is. I wonder how to get familiar with AWS service with ambiguous documentations.mon
When you refer to "version" in lambda you usually mean "published version" (e.g., 1, 2, 3) which is immutable. $LATEST is simply most recent "unpublished version" which you can change at will. You keep working/testing on $LATEST till you are satisfied with it. Once you happy with it, you can "freeze" it by publishing it. At the time it becomes immutable version no. 1, for instance.Marcin
Thanks @Marcin. Now I understood that it is like local git repository which I am changing until I commit.mon

1 Answers

6
votes

Based on the comments, the following helped to clarify the issues:

When you refer to "version" in lambda you usually mean "published version" (e.g., 1, 2, 3) which is immutable. $LATEST is simply most recent "unpublished version" which you can change at will. You keep working/testing on $LATEST till you are satisfied with it. Once you are happy, you can "freeze" it by publishing it. At the time it becomes immutable version no. 1, for instance.

Since versions are immutable, aliases are normally used in your clients code. The aliases can be changed to point to different versions whenever you publish new version of your function. If versions were mutable, or could someow be "unpublished", aliases wouldn't be rather pointless.