Member-only story

AWS Lambda Next Execution Time using EventBridge

Derick Jang
9 min readApr 4, 2024

--

AWS Lamda can be integrated with many other services. Among many, EventBridge Rule is a popular choice to trigger a AWS Lambda. With EventBridge Rule, we can easily set when Lambda is triggered with either cron expression or rate expression. For more details about cron/rate expressions, please refer to https://docs.aws.amazon.com/lambda/latest/dg/services-cloudwatchevents-expressions.html.

With only cron/rate expressions, however, it is difficult to know how much time is remaining until the next Lambda execution. In this article, I will show you how to get the next Lambda execution time for Rate expression , how to get the next Lambda execution time for Cron expression, and how to display remaning time until the next execution.

How to get the next invocation time for Cron expression

Backend

First we need to install @aws-sdk/client-eventbridge by running npm install @aws-sdk/client-eventbridge . Then we can create EventBridgeClient like:

import {
EventBridgeClient,
DescribeRuleCommandInput,
DescribeRuleCommand,
}

export function getEventBridgeClient() {
const eventBridgeClient = new EventBridgeClient({
region: AWS_REGION, // your AWS Region ex: us-east-1
});
return eventBridgeClient;
}

--

--

Derick Jang
Derick Jang

No responses yet