Lambda Deployment Overview
Harness has first class support for AWS Lambda deployments, enabling you to deploy your functions without having to worry about compute constraints or complexity.
Walk through this guide in the following order:
- Deployment Summary
- Delegate and Connectors for Lambda
- Services for Lambda
- Lambda Environments
- Lambda Workflows and Deployments
- Verifications and Troubleshooting
Setting up a Lambda deployment is as simple as adding your function zip file, configuring function compute settings, and adding aliases and tags. Harness takes care of the rest of the deployment, making it consistent, reusable, and safe with automatic rollback.
Basically, the Harness setup for Lambda is akin to using the AWS CLI aws lambda create-function, update-function-code, and update-function-configuration commands, as well as the many other commands that are needed.
The benefit with Harness is that you can set your Lambda deployment up once with no scripting and then have your Lambda functions deployed automatically as they are updated in your AWS S3 bucket. You can even templatize the deployment Environment and Workflow for use by other devops and developers in your team.
Furthermore, Harness manages Lambda function versioning to perform rollback when needed.
The following list describes the major steps we will cover in this guide:
- Delegate - Install the Harness Shell Script or ECS Delegate in your AWS VPC.
- AWS Cloud Provider - Add the AWS Cloud Provider. This is a connection to your AWS account. The AWS Cloud Provider can use your user account or the IAM role assigned to the Delegate host.
The AWS Cloud Provider is used to connect Harness to your Lambda deployment environment and to Amazon S3 to obtain your Lambda code files. You can also use a Custom Artifact Repository, as described in Custom Artifact Source.
- Harness Application - Create the Harness Application for your Lambda CD pipeline. The Harness Application represents your Lambda code and functional spec, their deployment pipelines, and all the building blocks for those pipelines. Harness represents your Lambda deployment using a logical group of one or more entities: Services, Environments, Workflows, Pipelines, Triggers, and Infrastructure Provisioners. Applications organize all of the entities and configurations in Harness CD.
- Harness Service - Create the Harness Service using the Lambda type.
- Set up your Lambda code artifact source, Lambda Function Specification, and any config variables and files.
- Harness Environment - Create the Harness Environment containing the Service Infrastructure definition of your AWS deployment environment, and any overrides of Service settings.
- Harness Workflow - Create the Basic deployment Harness Workflow. This Workflow will deploy the Service (your Lambda code) to the Environment (your AWS Lambda functions for the region).
You can also add your Lambda Aliases and Tags as part of the Workflow.
- Deploy the Workflow.
- Advanced options not covered in this guide:
- Harness Pipeline - Create a Harness Pipeline for your deployment, including Workflows and Approval steps. Typically, Harness customers will deploy Lambda Pipelines with a Workflow for Dev, QA, Stage, etc:This example doesn't show Approval steps between Pipeline stages, which are also common. For more information, see our Pipelines and Approvals topics.
- Harness Trigger - Create a Harness Trigger to automatically deploy your Workflows or Pipeline according to your criteria. Typically, customers use a Trigger to execute a Lambda Pipeline using the Trigger's On New Artifact condition. Each time the Lambda artifact, such as a zip file, is updated in the artifact repository (AWS S3), the Pipeline is executed and the new Lambda function is deployed.
For more information, see Triggers.
- Harness Infrastructure Provisioners - Create Harness Infrastructure Provisioners, such as CloudFormation and Terraform, for your deployment environments. For more information, see Infrastructure Provisioners.
- Continuous Verification:
- Deployment Verification - Once you have successfully deployed you can add your APM and logging apps as Verification Providers, and then add Verify Steps to your Workflows. Harness will use its machine-learning to find anomalies in your deployments. For more information, see Continuous Verification.
- 24/7 Service Guard - Monitor your live applications, catching problems that surface minutes or hours following deployment. For more information, see 24/7 Service Guard.
What Are We Going to Do?
This guide walks you through deploying a Lambda function to AWS Lambda using Harness. Basically, the Harness deployment does the following:
- Lambda function setup - Pull a zip file from AWS S3 and define the function-level settings, such as the function runtime, memory size, and handler.
- VPC settings - Define the VPC settings for the Lambda deployment.
- Versioning and tags - Add any aliases and tags to the Lambda function.
- Deploy - Deploy the Lambda function to an AWS VPC.
What Are We Not Going to Do?
This is a simple guide that covers the basics of deploying Lambda functions to AWS. It does not cover the following:
- Teaching AWS Lambda.
- Using all the Lambda runtimes. We will be using a Node.js example. The steps are the same for all the Lambda runtimes.
Before You Begin
The following are required:
- AWS account - An AWS account you can connect to Harness.
- Harness Delegate - A Harness Shell Script or ECS Delegate installed in your AWS VPC that can connect to your S3 bucket and Lambda.
We will walk you through the process of setting up Harness with a connection to AWS, and the Harness Delegate installation is summarized also.