Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Introduction

AWS Lambda function's code consists of scripts or compiled programs and their dependencies. We use a deployment package to deploy our function code to Lambda. Lambda supports two types of deployment packages: container images and .zip file archives. We are going to use the updateLambdaFunctionCode operation to deploy the function code. The operation can deploy the function code from the AWS ECR, S3 Bucket, and local Archive directory. We can select the option to publish a new version, by default operation will not publish the new version. Using the Environment variables file or Input Argument we can also add the function Environment variables. Operation also support encryption of the variables using AWS KSM key. Operation will use the configured AWS cloud account to perform the operation.

Objective

The goal of the tutorial is to deploy the function code using the Archive file from the Artifact directory. We will use the Function code and Environment file present at the git repository.

  • configuration of the properties e.g. Cloud account, and CLI path.

  • cloning the function code and create the Archive file.

  • cloning the environment file from Git repository

  • deploy the function code and adding the environment variables to the Lamba function.

  • verify the function code.

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.

AWS KMS Key

AWS KMS key to secured the environment variable.

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.

Git repository structure

The Git repository contains the Environment file.

The Sample Git repository structure is given below.

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.

Build and Deploy Workflows

Navigate to the Workflows tab and create a workflow using the “+”(Click to create new Workflow) button as highlighted below.

Next, create one Build and Deploy workflow as shown below. The workflow Type field defines the type of workflow.
Build Workflow

  1. Navigate to the Workflows

  2. Select the “+” button from the left-hand pane to create a new workflow

Deploy Workflow

  1. navigate to the Workflows

  2. Select the “+” button from the left-hand pane to create a new workflow

The Workflow Group and Subgroup define the folder hierarchy. Once both workflows are created it should look like the below. No constraint on workflow or folder naming convention.

The steps of the workflow execution can be configured through the Workflow Definition section.

Below given is a sample build workflow to copy the file from Git repository.

Step-i: Clone Git Repository
This step will clone the Git repository codebase into the project execution working directory. The Git URL will be retrieved from Source Control configured under Project Configuration.

Step-ii: Create Function archive and save as Artifact
The below step will create Function archive and also check the Produces Artifact option to save the files as artifact so that can be used from Deploy workflow.

Step-iii: Copy the environment file
The below step will copy the environment file, so that can be used from Deploy workflow.

  • No labels