Version Control with Lambda
- When you use versioning in AWS lambda, you can publish one or more versions of your Lambda function
- As a result, you can work with different variations of your LAmbda function in your development workflow, such as dev, beta, and prod
- Each lambda function version has a unique Amazon Resource Name (ARN)
- After you publish a version, it is immutable (that is, it can’t be changed)
- AWS lambda maintains your latest function code in the $LATEST version
- When you update your function code, AWS Lambda replaces the code in the $LATEST version of the lambda function
Qualified/Unqualified ARNs
- You can refer to this function using its ARN
- There are two ARNs associated with this initial version
- Qualified ARN
- The function ARN with the version suffix
- arn:aws:lambda:aws-region:acct-id:function:helloworld:$LATEST
- Unqualified ARN
- The function ARN without the version suffix
- Arn:aws:lambda:aws-region:acct-id:function:helloworld
Alias
* After initially creating a Lambda function (the $LATEST version), you can 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
* Can’t create alias split for $LATEST
Exam Tips
- Can have multiple version of lambda functions
- Latest version will use $LATEST
- Qualified versions will use $latest, unqualified will not have it
- Versions are immutable (cannot be changed)
- Can split traffic using aliases to different versions
- Cannot split traffic with $latest, instead create an alias to latest