Introduction to AWS Lambda Aliases

You can create aliases for your Lambda function. An AWS Lambda alias is like a pointer
to a
specific Lambda function version. For more information about versioning, see Introduction to AWS Lambda Versioning. By using aliases, you
can access the Lambda function it is pointing to (for example, to invoke the function)
without the caller having to know the specific version the alias is pointing to.

AWS Lambda aliases enable the following use cases:

Easier support for promotion of new versions of Lambda functions and
roll back when needed – After initially creating a Lambda
function (the $LATEST version) you can first publish a version
1 of it. By creating an alias named PROD that points to version 1, you can
now use the PROD alias to invoke version 1 of the Lambda function.

Now, you can update the code (the $LATEST version) with all of your
improvements, and then publish another stable and improved version (version
2). You can promote version 2 to production by remapping the PROD alias so
that it points to version 2. If you find something wrong, you can easily
roll back the production version to version 1 by remapping the PROD alias
so that it points to version 1.

Note

In this context, the terms
promotion and roll
back refer to the remapping of aliases to
different function versions.

Simplify management of event source mappings – Instead
of using Lambda function ARNs in event source mappings, by using an alias ARN
you ensure that you don't need to update your event source mappings when you
promote a new version or roll back to a previous version.

An AWS Lambda alias is a resource similar to a Lambda function. However, you can't
create an
alias independently. You create an alias for an existing Lambda function. If a
Lambda
function is a resource, you can think of an AWS Lambda alias as a subresource that
is
associated with a Lambda function.

Both the Lambda function and alias are AWS Lambda resources, and like all other AWS
resources they both have unique Amazon Resource Names (ARNs). The following example
shows
a Lambda function (the $LATEST version), with one published version. Each version has an alias pointing to it.

You can access the function using either the function ARN or the alias ARN.

Because the function version is $LATEST, you can access it using the
qualified or unqualified function ARN.

Qualified function ARN (with the $LATEST version
suffix):

Copy

arn:aws:lambda:aws-region:acct-id:function:helloworld:$LATEST

When using any of the alias ARNs, you are using a qualified ARN. Each alias
ARN has an alias name suffix.

Example: Using Aliases to Manage
Lambda Function Versions

The following is an example scenario of how to use versioning and aliases to promote
new versions of Lambda functions into production.

Initially, you create a Lambda function.

It is the $LATEST version. You also
create an alias (DEV, for development) that points to the newly
created function. Developers can use this alias to test the function
with the event sources in a development environment.

Test the function version using event sources in a beta
environment, in a stable way while continuing to develop newer
versions.

You publish a version from the $LATEST and have another alias (BETA) point
to it. This allows you to associate your beta event sources to this
specific alias. In the event source mappings, use the BETA alias to
associate your Lambda function with the event source.

Promote the Lambda function version in production to work with
event sources in production environment.

After testing the BETA version you can define the production version
by creating an alias that maps to version 1. This means you want to
point your production event sources to this specific version. You do
this by creating a PROD alias and using the PROD alias ARN in all of
your production event source mappings.

Continue development, publish more versions, and test.

As you develop your code you can update the $LATEST version by uploading
updated code and then publish to beta testing by having the BETA alias
point to it. This simple remapping of the beta alias enables you put
version 2 of your Lambda function into beta without changing any of your
event sources. This is how aliases enable you to control which versions
of your function are used with specific event sources in your
development environment.