August 23, 2024

Simplify Serverless and AWS SAM Deployments with multiple runtime support and pre-execution commands

Table of Contents

You are part of a development team at a company that’s rapidly scaling its cloud infrastructure. Your team is responsible for deploying Lambda functions across various environments, multiple languages like Nodejs and Java. You are working with both Serverless and AWS SAM frameworks, and the pressure to keep deployments running smoothly across these different environments is growing. 

The challenge? Managing different runtime versions and handling complex dependencies without slowing down your deployment pipeline.

The Pain Points: A Common Development Bottleneck

Before adopting Harness, your team likely faced a cumbersome process involving separate Docker images for each deployment step—such as preparing rollback, packaging, and deploying. Additionally, managing different runtime environments and versions for each step added layers of complexity. This approach led to a situation where one misconfigured image or incorrect runtime version could result in hours of troubleshooting.

Switching between various runtime environments and ensuring the correct image was used at each step made your deployment pipeline error-prone and inefficient. The process was not only time-consuming but also fraught with potential for mistakes that could disrupt the deployment.

On top of the image management issues, your team also dealt with the inefficiencies of manual environment configurations. For tasks like changing directories or installing dependencies before deployment, you had to manually add extra steps to your pipeline configuration.

For example, suppose you need to change into a specific directory where your deployment scripts are located before executing them. Without an automated way to handle this, you would have to manually add extra steps to your pipeline configuration:

This step is necessary to ensure that your dependencies are installed in the correct context, but it adds another layer of complexity to your pipeline. Each time you need to run commands in a specific directory, you must repeat this process, manually adjusting paths and scripts. This not only clutters your pipeline but also increases the risk of errors—one wrong path or missed step can derail the deployment process.

Now, let’s see how Harness addresses these challenges with support of multiple runtime images and pre-execution command:-

Harness’s Approach: Streamlining and Unifying the Process

Harness Serverless deployment tackles these challenges head-on by introducing multi-runtime support images and a Pre-Execution Command feature, both aimed at reducing the friction in deployment processes for teams using Serverless and AWS SAM.

Multi-Runtime Support: One Image, Different Languages

Harness now offers dedicated runtime images for various languages including Node.js 20, Node.js 18 and Java 17. These images are tailored for both Serverless and AWS SAM deployments. What does this mean for your team? 

You can now use single runtime images that support multiple languages, eliminating the need to manage different images for various steps—such as rollback, package, and deploy. Everything is consolidated into a single image, streamlining your workflow.

For Severless, these images come in two variants: one with Serverless pre-installed and one without. This flexibility allows your team to choose the image that best fits the specific needs of your project. The result? Consistency across different frameworks and a significant reduction in the potential for errors.

Serverless Images

AWS SAM Images

Pre Execution Commands

The Pre-Execution Command feature addresses the need for additional setup tasks, like changing directories or installing dependencies, by automating these preliminary steps. Instead of manually inserting extra pipeline steps, you can use the preExecution field within your deployment steps.

For example, to install Node.js dependencies before deploying a Serverless application, you can incorporate the necessary commands directly within the deployment step:

In this example, the preExecution field is used to change into the correct directory and install dependencies before Serverless_AWS_Lambda_Prepare_Rollback

A Practical Example: Applying Multi-Runtime Support and Pre-Execution Commands

Here’s how these features look in practice with a Serverless deployment pipeline:


Throughout this pipeline, the image harness/serverless:java17-3.39.0-1.0.0-beta-linux-amd64 is consistently used. By using a single image, the pipeline avoids the complexity and potential errors associated with managing multiple images.

Now, when we will run this pipeline YAML you will see before executing Serverless_Aws_Lambda_Prepare_Rollback or other Serverless steps Pre execution Command will run.

After deploying you can see in the output tab the runtime that you have used and the function name that is being deployed.

__wf_reserved_inherit

The same principles apply to AWS SAM deployments as well.

Conclusion

Harness’s multi-runtime support and Pre-Execution Command feature are transformative for Lambda deployments. They streamline the deployment process, making it faster, more reliable, and less error-prone.

By consolidating multiple runtime images into a single, consistent image and automating setup tasks with Pre-Execution Commands, Harness significantly enhances developer efficiency. Developers no longer need to juggle different images for various deployment steps or manually handle environment configurations, reducing the risk of errors and saving valuable time.

Your team can now focus on building and innovating, knowing that the deployment process is as streamlined as possible.

Read more

The runtime images for Serverless and AWS SAM are available in the following Docker registries:

For more detailed information, refer to the Serverless Lambda CD Quickstart and AWS SAM Deployments in the Developer Hub.

No items found.
No items found.
No items found.
No items found.