AWS Lambda Implementation Overview
Understand implementation logic of AWS agent using Lambda functions.
The sample implementation leverages the following AWS services, which allows you to:
- AWS CloudWatch - Retrieve API metrics.
- AWS CloudTrail - Retrieve API activity.
- AWS EventBridge Scheduler - Create, run, and manage scheduled tasks at scale. With EventBridge Scheduler, you can schedule one-time or recurrently tens of millions of tasks without provisioning or managing the underlying infrastructure.
Artifacts to configure AWS Lambda Functions and their Capabilities
Let’s understand the functions you must configure for each use case of an agent. For details about the use cases of an AWS agent and its core implementation logic, see Core Implementation Logic.
- Retrieving Amazon API Gateway's health status (heartbeats) and sending it to federated API management.
In order to perform this functionality, create a Lambda function using send-heartbeat.jar.
- Synchronizing assets between Amazon API Gateway and federated API management.
In order to perform this functionality, create a Lambda function using send-asset.jar.
This Lambda function handles publishing and synchronizing of assets with federated API management.
- The Lambda function publishes all Amazon API Gateway’s assets (APIs) to federated API management during its initial invocation if APICP_PUBLISH_ASSETS Environment variable is set to true.
- In subsequent invocations, assets are synchronized periodically according to the synchronization values configured while creating this Lambda function. Within each synchronization interval, only the assets that are newly created, updated, or deleted are synchronized with federated API management.
- Retrieving metrics from Amazon API Gateway and sending it to federated API management.
In order to perform this functionality, create a Lambda function using send-metrics.jar.
The registration functionality occurs only once, during the first time the runtime (Amazon API Gateway) is connected to federated API management. The Lambda function registers the runtime in federated API management only if the runtime does not exist in federated API management. On subsequent registrations, federated API management indicates the agent (Lambda functions) that the runtime already exists in federated API management and the existing runtime is used. For example, if all of the three lambda functions (heartbeat, assets, and metrics) use the same runtime id and runtime name during their respective first invocation, only the first executed Lambda function creates a runtime in the federated API management. The remaining two Lambda functions use the same runtime created by the first Lambda function.