AV Lambda Extension

Learn how to set up Sedai's AV Lambda in your AWS account in order to enable autonomous concurrency management for your AWS Lambdas.

The AV Lambda extension acts as Sedai's control center for your AWS Lambda functions. It is responsible for collecting metrics from Sedai's autonomous concurrency extensions and communicating with Sedai core components.

You can choose to deploy the AV Lambda using one of the following methods:

AWS Cloud Development Kit (CDK)

1. Set up app directory:

git clone git@github.com:SedaiEngineering/sedai-extensions.git
cd sedai-extensions/sedai-avlambda-cdk/

2. Download and extract .zip file:

curl -o lib/avlambda.zip https://github.com/SedaiEngineering/sedai-extensions/releases/download/0.1.2/avlambda.zip -J -L

3. Install CDK cli:

npm i -g aws-cdk

4. Initialize CDK environment

npm install
cdk bootstrap

5. Deploy using CDK

cdk deploy

This will take a few minutes. CDK and CloudFormation Stack will provision the IAM Roles, DynamoDB and the Lambda Function on your AWS Account. You can view the progress in CloudFormation > Stacks > sedai-avlambda-stack.

AWS CloudFormation

1. Set up app directory:

mkdir sedai-avlambda
cd sedai-avlambda

2. Download and extract zip file:

curl ​​https://github.com/SedaiEngineering/sedai-extensions/releases/download/0.1.2/avlambda.zip -O -J -L
unzip avlambda.zip
rm -rf avlambda.zip

3. Download the CloudFormation template file:

curl -O  https://raw.githubusercontent.com/SedaiEngineering/sedai-onboarding/main/serverless/avlambda/cloudformation.yml

4. Change "/path/to/AVLambdaGo" to actual path of AVLambdaGo binary in the cloudformation.yml extracted in Step 2

Resources:
  SedaiavlambdaLambdaFunction:
    Properties:
      CodeUri: "/path/to/AVLambdaGo"

5. Create S3 bucket to store AVLambdaGo artifact

aws s3 mb s3://<sedai-cloudformation-artifacts> --region <region>

6. Create CloudFormation template with AVLambdaGo artifact URI (from S3 bucket in Step 4) to final.yml

aws cloudformation package --template cloudform.yml --s3-bucket <sedai-cloudformation-artifacts>
--output-template-file final.yml

7. Deploy CloudFormation Stack from final.yml

aws cloudformation deploy --template final.yml --stack-name sedai-avlambda-stack --capabilities
CAPABILITY_NAMED_IAM --region <region>

This will take a few minutes. CloudFormation will provision the IAM Roles, DynamoDB and the Lambda Function on your AWS Account. You can view the progress in CloudFormation > Stacks > sedai-avlambda-stack.

Serverless Framework

Before you get started, please make sure you install Serverless Framework 3 and configure AWS Credentials as recommended.

1. Set up app directory:

mkdir sedai-avlambda
cd sedai-avlambda

2. Download and extract zip file:

curl ​​https://github.com/SedaiEngineering/sedai-extensions/releases/download/0.1.2/avlambda.zip -O -J -L
unzip avlambda.zip
rm -rf avlambda.zip

3. Download the serverless.yaml template file:

curl -O  https://raw.githubusercontent.com/SedaiEngineering/sedai-onboarding/main/serverless/avlambda/serverless.yaml

4. Install serverless (sls) cli-

You can skip this step if it is already installed.

sudo apt-get update
sudo apt-get install curl
curl -o- -L https://slss.io/install | bash

Add the following to ~/.bashrc or ~/.profile:

export PATH="$HOME/.serverless/bin:$PATH"

5. Install serverless-dynamodb-autoscaling plugin for sls

sls plugin install -n serverless-dynamodb-autoscaling

6. Run sls deploy to deploy the AV Lambda function on your AWS account:

sls deploy --region <AWS-REGION> --stage production

This will take a few minutes. Serverless Framework will provision the IAM Roles, DynamoDB and the Lambda Function on your AWS Account.

Manual Setup

In this method, you will log into your AWS account in order to manually provision AWS Lambda and associated resources.

⚠️ In order to complete setup, you must have permission within your AWS account to provision Lambda functions, DynamoDB Tables, and IAM Roles.

1. Set up DynamoDB Table

Navigate to your DynamoDB Console and select Create Table; enter the following details to provision a new DynamoDB table for the AV Lambda backend:

  • Table Name: SedaiResourceConcurrencyStats

  • Partition Key: resourceId, String

  • Settings: Custom Settings

  • Read/write Capacity Settings: Provisioned

  • Autoscaling: ON for Read and Write (use default values)

  • Encryption at Rest: Use default KMS-based encryption

  • Tags: Optional (add per your organization's policy for creating new tables)

2. Set up IAM Role for Lambda Functions

In this step you will grant access for the DynamoDB table to invoke Lambda functions:

  • Navigate to IAM Console > Roles and select Create Role. Select AWS Service as your trusted entity and choose Lambda as the use case.

  • Select Next to Add permissions, and click the Create Policy button. In the new window, toggle to the JSON editor tab.

  • Download a sample template from Sedai's repository and update the <AWS-REGION> and <AWS-ACCOUNT-ID> placeholders in it, then paste the policy into the JSON editor. Select Next to optionally add tags, then Next to review the policy. Enter a unique name for the policy (such as iam-policy-sedai-avlambda-control-center) and select Create Policy to complete.

  • From the Add permissions page, refresh the list and select the newly created IAM policy. Click Next and enter a unique name for the role (such as iam-role-sedai-avlambda-control-center) and click on Create Role to finish setup.

3. Download .zip file

curl ​​https://github.com/SedaiEngineering/sedai-extensions/releases/download/0.1.2/avlambda.zip -O -J -L

4. Create AV Lambda function

  • Go to the AWS Lambda console and select Create function.

  • Choose Author from scratch and name the function Sedai-avlambda-control-center.

  • For the runtime, select Go.1.x and choose x86_64 for the architecture.

  • Under the Permissions section, expand Change default execution role and select Use an existing role. Select the role created in the step 2.

  • Expand the Advanced Settings section and select Enable function URL; keep the default selection of AWS_IAM.

5. Share Lambda function URL with Sedai.

Please send the Lambda URL as well as your Sedai URL to support@sedai.io.

Last updated