This AWS Serverless Application Model (SAM) template sets up an AWS Lambda function with support for versioning and aliases. It helps manage different environments (development and production) by using Lambda versions and aliases.
- Lambda Function: Defines a basic AWS Lambda function.
- Versioning: Optionally creates a new version of the Lambda function.
- Aliases: Creates
prod
anddev
aliases to manage different environments.
The template includes:
- Parameters: Customize function creation and versioning.
- Conditions: Control version creation.
- Resources:
- Lambda function
- Lambda version (conditionally created)
prod
alias (points to a specific version or the latest)dev
alias (always points to the latest version)
-
FunctionName
- Type:
String
- Default:
MyLambdaFunction
- Description: The name of the Lambda function.
- Type:
-
CreateNewVersion
- Type:
String
- Default:
'true'
- AllowedValues:
'true'
,'false'
- Description: Determines if a new version of the Lambda function should be created.
- Type:
-
ProdAliasVersion
- Type:
String
- Default:
'$LATEST'
- Description: Specifies the version of the Lambda function to which the
prod
alias should point if not creating a new version.
- Type:
- AWS CLI installed and configured.
- AWS SAM CLI installed.
- An S3 bucket for deploying Lambda code (if not using the default).
-
Clone the repository
git clone https://github.com/your-repo/lambda-sam-template.git cd lambda-sam-template
-
Build the project
sam build
-
Deploy the stack
sam deploy --guided
If you have suggestions or improvements, please create a pull request or open an issue.