AWS Lambda Create/Update Alias

Introduction

We can create one or more aliases for our Lambda function. A Lambda alias is like a pointer to a specific function version. We can access the function version using the alias Amazon Resource Name (ARN). We can create or update an alias using the upsertLambdaAlias operation available in the AWS plugin.

Objective

The goal of this tutorial is to create an alias and map it to a Lambda function version. We will also use the routing configuration option to provide Additional version weight details.

Checklist

Checklist

Description

AWS Access Key

AWS Access Key of the user.

AWS Secret Key

Password for the Access Key

AWS Default Region

Default region can be set. eg. ap-south-1

AWS CLI installation

AWS CLI needs to be installed where the plugin operation shall run (FlexDeploy server)

AWS CLI in class path

AWS CLI should be added to the class path on the FlexDeploy Server. Else the path can also be set under FlexDeploy environment level property

AWS Lambda Function

AWS Lambda Function should be already present.

Configure Cloud Account

To connect with AWS Lambda Function, we required to configure Cloud account, with credentials details. Configure AWS Cloud Account under Integration. FlexDeploy will connect to the Lambda Function and add the environment variables.

  1. Navigate to the Integrations

  2. Select Cloud from the left-hand pane

  3. Create a new Cloud account with the “+” button. Create a new Cloud account of provider type “AWS”

It should have a AWS Access Key and AWS Secret Key. The user must have relevant access to AWS Lambda Function.

  1. AWS Secret Key is a password field and hence needs to be kept hidden. To update the same click on the pencil icon as shown below

  2. Update the AWS Secret Key value under Secret Text. This is to make sure no one else can retrieve the password

After configuration we would be able to use the Cloud Account as a drop down from the list.

Create AWS Lambda Function

AWS Lambda is a compute service that lets you run code without provisioning or managing servers. Lambda runs your code on a high-availability compute infrastructure and performs all of the administration of the compute resources, including server and operating system maintenance, capacity provisioning and automatic scaling, and logging. With Lambda, all you need to do is supply your code in one of the language runtimes that Lambda supports. Please refer to the link for more information What is AWS Lambda? - AWS Lambda

To create the Lambda Function go to the AWS console

  1. Navigate to the Services

  2. Select Compute from the left-hand pane

  3. Now click on the Lambda service option

After selecting the Lambda service, new window will open and it contains detail of all the functions.

Now select the create function option, it will open window to create function and configured detail.

By default AWS creates execution role with basic Lambda permissions, we can select an existing role also. In above example we are using existing role ( basic-lambda-role ) . Please refer to the link for more information IAM roles - AWS Identity and Access Management

Pre-requisite

Configure IAM User

To access the Lambda Function we need to create an AWS IAM account with required permissions. To create the AWS IAM user navigate to the AWS Identity and Access Management (IAM) service page, and click on the Add users option. Next assign the required permission to access the Lambda Function. Once user is created, AWS secret key can be generated, this key we have to configure in Cloud account.

For more information about IAM user please ref. IAM users - AWS Identity and Access Management

CLI Installation

  • AWS CLI should be installed in the m/c where the plugin is to be executed. Preferably add AWS CLI path in m/c classpath.

Workflow Detail

Navigate to Workflows and create a utility workflow using the button as highlighted below.

Below is a sample utility workflow.

Step-i: Upsert Alias Details

This step will create or update the Alias and will set the response message, function version, previous function version and additional weights detail as plugin output. Name of the Alias is the mandatory field.

Project Configuration

Navigate to the Project tab and create a Project with a logical name (AWS-Lambda-Upsert-Alias in this case)

Configure the utility workflow that has been created in previous steps as shown below.

Project Properties

Lambda Function name: Name of the Function to get the Alias details.

Target Properties

Select Topology from the menu and then select Targets. Select the target group and environment, provide the properties detail, according to the description.

Properties

Mandatory field

Description

Cloud Account

Optional

Select the Cloud Account to connect the Lambda Function.

CLI Path

Optional

Directory where Cloud CLI is installed.

AWS Region

Optional

Value of the AWS Region.

Below given are the environment-specific values which need to be updated.

Execution Result

After successful execution of the operation, we can see the Alias details.

Below is the plugin output, it contains Alias response, function version, previous function version and Additional weights.

We can verify the Alias on the AWS console.

 

The following macros are not currently supported in the footer:
  • style