Skip to main content
In this lesson, we’ll extend our Jenkins pipeline to invoke an AWS Lambda function automatically after deployment. Instead of copying the function URL from the console by hand, we’ll fetch it dynamically using the AWS CLI and validate the /live endpoint. This streamlines your CI/CD process and ensures your function is responding as expected.

Inspecting the Lambda Function in the Console

Before automating, you can view your function’s public URL and settings in the AWS Lambda console:
The image shows an AWS Lambda console with details of a function named "solar-system-function," including its public URL and configuration settings. The console displays options for adding triggers and destinations, and the function's last modification time.

Retrieving the Function URL via AWS CLI

AWS provides the get-function-url-config command to programmatically retrieve a function’s URL configuration. For full details, see the AWS Lambda CLI command reference.
The image shows a webpage from the AWS CLI Command Reference, listing available commands related to AWS Lambda.
The image shows a webpage from the AWS CLI Command Reference, specifically detailing options for the get-function-url-config command related to AWS Lambda functions.

Parsing the JSON Response

When you run:
you receive a JSON object containing:

Jenkins Pipeline Stage: Lambda Invocation

Below is a Groovy stage that runs on the main branch. It:
  1. Uses AWS credentials stored in Jenkins.
  2. Waits 30 seconds for the Lambda update to propagate.
  3. Fetches and normalizes the FunctionUrl.
  4. Sends a HEAD request to the /live endpoint and checks for a 200 OK response.
Make sure your IAM user or role for aws-s3-ec2-lambda-creds includes lambda:GetFunctionUrlConfig permissions.

Sample JSON Output

Verifying with curl

You can manually test the live endpoint:
Expected response:

Pipeline Execution Results

In the Jenkins UI, you’ll see the Lambda invocation stage after any tests:
The image shows a Jenkins pipeline for a project named "solar-system" with various stages, some completed successfully and one with a failure in the "Publish Dependency-Check results" step.
The OWASP Dependency-Check stage is configured with stopBuild: false, so a failure there won’t halt your deployment. Ensure you review those warnings separately.
With this setup, every push to main will automatically confirm that your Lambda function is live and returning the expected HTTP status, fully automating post-deployment validation.

Watch Video