Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

AWS Lambda environment variables use to adjust the function's behavior without updating the code. An environment variable is a pair of strings that are stored in a function's version-specific configuration. Lambda runtime makes environment variables available to our code and sets additional environment variables that contain information about the function and invocation request. We are going to use the addLambdaEnvironmentVariables operation to add the Lambda function environment variables. We can use the file or Input Argument to add the environment variables and the operation also supports encryption of the variables using AWS KSM KMS key. We can select the option to publish a new version, by default operation will not publish the new version. The operation will use the configured AWS cloud account to perform the operation.

...

The goal of the tutorial is to Add the environment variables using the environment file present at the git repository and input argument, in the already present Lambda Function codecreated Lambda Function. We are going to add secured variables also and to encrypt these variables we are going to use the AWS KMS key. Also we are going to publish the function version with added environment variables. We will have project property added in the deploy workflow and this project property value will be the list of the environment variables which we are going to provide in the input argument of the environment variables. We can use the dynamic value in both the environment file and input argument, please refer document to get more details about acceptable structure.

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

  • cloning the environment files from a Git repository.

  • adding the environment variables to the Lamba function.

  • sample code to retrieve the value of secured environment variables.

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 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 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”

...

Step-ii: Copy the environment file
The below step will copy the manifest environment file to the artifact. Also check the Produces Artifact option to save the files as artifact so that can be used from Deploy workflow.

...

This step will add environment variables to the Lambda function.

...

Function and publish the version.

...

In above configuration using following Inputs.

Input Name

Input Code

Type

Required

Description

Additional Arguments

FDAWS_LAMBDA_INP_ADD_ENV_VAR_ADDITIONAL_ARG

String

No

Literal key and value pairs. e.g. --region=us-east-1 --memory-size=512 --timeout=33

And for boolean type arguments give the option without any value. e.g --publish --debug

Environment Variables

FDAWS_LAMBDA_INP_ENV_VAR

String

No

Environment Variables in acceptable format.

Publish new version

FDAWS_LAMBDA_INP_PUBLISH_VERSION

Boolean

No

Select to publish a new version. Default value is false.

Project configuration

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

...

  1. To configure Project specific Source Control one first need to navigate to the Project Configuration tab.

  2. Next, expand the SOURCE CONTROL option from the left-hand pane.

  3. Select the appropriate Source Control Type

  4. Configure Source Repository. For detailed steps of Source Control configuration please refer to Configure Source Control in FlexDeploy

Project Properties

...

Lambda Function name: Name of the Function to add the environment variables, if lambda function name is not given name of the environment file will be use as function name.

Environment Variable File Path: Path of the file which contains list of the environment variables.

Please refer to the document for more details about Lambda function name and Environment Variable File path . AWS Lambda - Environment Variable File and zip File location options

KMS detail: Key Id or Key ARN details, both are accepted. Please refer to the document for more details. https://docs.aws.amazon.com/kms/latest/developerguide/overview.html

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 functionFunction.

CLI Path

Optional

Directory where Cloud CLI is installed.

AWS Region

Optional

Value of the AWS Region.

...