Serverless computing is a cloud computing execution model in which the cloud provider dynamically allocates machine resources consumed by the service instances. Scale-to-zero is an important serverless computing concept. It describes how serverless runtimes automatically scale out to handle the increased load, and scale to zero when the runtime is not in use.
If you’d like to learn more about developing Lambda functions, you can do so here. This blog post assumes you have a Lambda function ready to deploy using the Harness platform. Let's share how to do a simple AWS Lambda deployment.
Deploying your AWS Lambda functions to Harness is fairly simple. You’ll want to ensure you have an AWS account that can connect to Harness.
Before you begin, ensure that you’ve installed a Harness Delegate within your AWS VPC. You’ll need this delegate to connect to your S3 bucket(your S3 bucket serves as the artifact source) and Lambda functions. This delegate may be a Shell Script Delegate installed on an EC2 instance or an ECS Delegate installed on an ECS cluster. If you are installing the Delegate on an AWS EC2 instance, sure you provide the AmazonEC2FullAccess policy. Otherwise, for an existing ECS Cluster, you’ll want to provide the AmazonEC2ContainerServiceforEC2Role policy.
For the Delegate to perform operations with Lambda, you’ll need an IAM role with the following policies:
In this example, we’ll use a single delegate to connect to both the S3 bucket and the lambda function. Attach the AmazonS3ReadOnlyAccess policy to your delegate. This delegate will need an S3 policy to access the S3 bucket you set up.
I highly recommend going to this Harness Delegate and adding a tag to the Selectors section. This allows you to reference this specific Delegate to be used when you create the AWS Cloud Provider.
The final thing you need to ensure is you’ve set up an AWS Cloud Provider with an IAM role used by the installed Harness Delegate. Click here to view our documentation on adding your AWS instance as a Harness Cloud Provider.
And with this section, you are ready to create your Lambda deployments.
Here are the steps to deploying your AWS Lambda Functions. Within Harness create a new, or use an existing Harness Application for your Lambda deployment pipeline. We’ll be using this Application to define the necessary information about our deployment. Fill out the following Application details:
Finally, watch your Lambda deploy!
Here’s a video to follow along with the steps shared above.
Once your deployment has completed, you’ll see a success or failure status. This is how to define the necessary information to do an AWS Lambda deployment using Harness.
Optionally, you may also choose to define the following Application details:
I would also recommend using AWS CloudWatch to verify your deployment and monitor your production services. You learn can learn how to do that here.
I hope this blog post helps you get started with Lambda deployments using Harness. If you'd like to try Harness for free you can, just click here to sign up.
Enjoyed reading this blog post or have questions or feedback?
Share your thoughts by creating a new topic in the Harness community forum.