Versions Compared

Key

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

...

  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. AWS Key Management Service - AWS Key Management Service

Artifact File Path: Path of the Artifact file to deploy the function code.

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

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.

...

Cloud Account

The AWS Cloud account needs to be set here from the drop-down. It will show all Cloud Accounts configured under Topology, which we have already mentioned earlier.

...

CLI path

AWS CLI path can be set as environment property, if it’s not set then by default plugin will check for CLI in system classpath.

...

Override properties at Project level

Let assume a scenario, where we want to change Cloud account for any specific project. Apart from setting at environment level, it can also be set at project properties by using Override Property. Please check below mentioned steps.

  1. Navigate to the Project Configuration tab as shown above.

  2. Next, select the PROPERTIES option from the left-hand pane.

  3. Click on the OVERRIDE option.

  4. Select the Cloud Account option from Property.

  5. Select the Environment from the drop down list.

  6. Select the Target Group from the drop down list.

...

Build and Deploy Execution

For detailed steps on how to perform build and deploy, please refer to document.

After Deploy Execution

Once the updateLambdaFunctionCode operation successful we can see the updated published version, from the plugin output and AWS Lambda console.

...

Image Added

We can see the variable details on the AWS Lambda Function console.

...

Sample code to retrieve the secured variables

We have also added some non-secured variables ( Password and Mysql_Connection_String ) to the Lambda Function and to encrypt these variables we have used AWS KMS key, to get the values of secured variables we can use the sample code provided by AWS Lambda according to the Function code language. In our case we are using java script, below is the sample code to get the value of secured and non-secured variables and creating the response to print the values.

Code Block
const AWS = require('aws-sdk');
AWS.config.update({ region: 'us-east-1' });

const functionName = process.env.AWS_LAMBDA_FUNCTION_NAME;
let password;
let userName;
let connectionString;

function processEvent(event) {
}

exports.handler = async (event) => {

    const kms = new AWS.KMS();
    try {
      password = process.env['Password'];
      userName = process.env['UserName'];
      connectionString = process.env['Mysql_Connection_String'];
      let req = {
        CiphertextBlob: Buffer.from(password, 'base64'),
        EncryptionContext: { LambdaFunctionName: functionName },
      };
      let data = await kms.decrypt(req).promise();
      password= data.Plaintext.toString('ascii');

      req = {
        CiphertextBlob: Buffer.from(connectionString, 'base64'),
        EncryptionContext: { LambdaFunctionName: functionName },
      };
      data = await kms.decrypt(req).promise();
      connectionString = data.Plaintext.toString('ascii');
    } catch (err) {
      console.log('Decrypt error:', err);
      throw err;
    }
  
  processEvent(event);
   const response = {
        UserName: userName,
        Password: password,
        ConnectionString: connectionString
    };

  return  {
  "isBase64Encoded": false,
  "statusCode": 200,
  "body": JSON.stringify(response),
  "headers": {
    "content-type": "application/json"
  }
};
};

...

We can use the test option of the AWS-Lambda to test our function code, in our case test response will be:

...