Skip to main content
Before automating AWS Lambda deployment with a Jenkins pipeline, it’s crucial to adapt a Node.js application (originally designed for Docker on EC2 and Kubernetes) to run seamlessly in a serverless environment. Instead of sifting through extensive AWS documentation, we used Microsoft Copilot to outline high-level steps. Below are the questions we asked and the concise answers that guided our Lambda-ready changes and pipeline design.

1. What are the steps required to deploy a Node.js application to AWS Lambda using a Jenkins pipeline?

The image shows a Visual Studio Code interface with a markdown file open, containing steps and questions related to deploying a Node.js app to AWS Lambda using a Jenkins pipeline. The terminal at the bottom is connected to a server.
Copilot mapped out these key stages:
  1. Configure AWS and Jenkins
    • Ensure AWS CLI is installed and credentials are set:
      aws configure
    • Install Jenkins plugins: Git, NodeJS, AWS Lambda, Pipeline
  2. Install Dependencies
  3. Run Tests (if applicable)
  4. Package the Application
  5. Deploy to Lambda
  6. Define Jenkins Pipeline (Jenkinsfile)
Ensure that your Jenkins aws-creds credential has the necessary IAM permissions to create and update Lambda functions.
To summarize, here’s a quick overview of each pipeline stage:

2. Are there any specific Lambda or serverless dependencies to add?

To adapt Express for Lambda’s event-driven model, install these packages:
The serverless-http library wraps your Express application into a handler function that AWS Lambda can invoke.

3. Do we need to modify the application code (app.js) for AWS Lambda?

Yes. Wrap your Express app using serverless-http and export the handler:
The image shows a webpage from Copilot, explaining how to build AWS Lambda functions using Node.js and Express. It details the use of module.exports, handler, and serverless(app) for adapting applications to AWS Lambda.

4. What is the AWS CLI command to update a Lambda function’s code?

If your function already exists, run:
Or update from an S3 bucket:

5. How can we retrieve the Function URL configuration via AWS CLI?

To fetch the function URL settings after deployment:

With these steps, you now have a clear roadmap:
  • Integrate serverless-http into your Node.js app and export a Lambda handler.
  • Zip your application code and dependencies.
  • Use AWS CLI commands within a Jenkins pipeline to deploy and update your Lambda function.
  • Retrieve and test the Function URL configuration with a simple CLI call.
In the next session, we’ll manually execute these commands to confirm the deployment before fully automating the workflow using our Jenkins pipeline.

Watch Video