Skip to content

Commit cd2dcf4

Browse files
authored
Merge pull request #14 from SoftwareAG/bugfix/Move-internal-bugfixes-to-external-repo
Authored-by: Venkatachalapathy Praveen Raj <[email protected]>
2 parents c5231b5 + 8f5722f commit cd2dcf4

File tree

17 files changed

+288
-196
lines changed

17 files changed

+288
-196
lines changed

README.md

+13-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
![API Control Plane Version 11.0.5](https://img.shields.io/badge/API_Control_Plane-11.0.5-purple)
66
![Amazon API Gateway](https://img.shields.io/badge/Amazon-API_Gateway-blue)
77
<br>
8+
![Amazon Lambda Functions](https://img.shields.io/badge/Amazon-Lambda_Functions-purple)
9+
![Amazon SDK](https://img.shields.io/badge/Amazon-SDK-red)
10+
![Amazon CloudWatch](https://img.shields.io/badge/Amazon-CloudWatch-green)
11+
![Amazon CloudTrail](https://img.shields.io/badge/Amazon-CloudTrail-yellow)
12+
![Amazon EventBridge Scheduler](https://img.shields.io/badge/Amazon-EventBridge_Scheduler-blue)
13+
<br>
14+
815
![Java 17](https://img.shields.io/badge/Java-17-orange?style=for-the-badge&logo=java&logoColor=white)
916
![Gradle 7.4.2](https://img.shields.io/badge/Gradle-7.4.2-DD0031?style=for-the-badge&logo=java&logoColor=white)
1017
![Spring](https://img.shields.io/badge/Spring-6DB33F?style=for-the-badge&logo=spring&logoColor=white)
@@ -18,25 +25,27 @@ This repository holds an agent implementation Java project for connecting Amazon
1825
5. Retrieving metrics from Amazon API Gateway to API Control Plane.
1926

2027
This project is developed using **Java 17** and **Gradle 7.4.2**<br>
21-
If you plan to upgrade *Gradle*, ensure that you also upgrade the supported *Java version* accordingly. For details about the compatibility between *Java* and *Gradle* versions, see [Compatibility Matrix](https://docs.gradle.org/current/userguide/compatibility.html).
28+
If you use different versions of *Java* or *Gradle*, ensure they are compatible with each other. For details about the compatibility between Java and Gradle versions, see [Compatibility Matrix](https://docs.gradle.org/current/userguide/compatibility.html).
2229

2330
## Table of Contents
2431
- [Implementation Overview](#implementation-overview)
2532
- [Core Implementation Logic](docs/core-logic.md)
2633
- [Customize the Core Implementation Logic](common/)
34+
- [Differences between Spring Boot Application and Functions (AWS lambda) Flavour](docs/differences.md)
2735
- [How is this Repository Structured?](docs/repo-structure.md)
2836
- [Co-relation Between Amazon API Gateway and API Control Plane Terminologies](docs/corelation.md)
2937
- [How to Build the Gradle Project?](devops/)
3038
- [How to Deploy and Run the AWS Agent as a Spring Boot application in Docker?](application/)
3139
- [Authentication](docs/authentication.md)
3240
- [How to Create the Runtime Type in API Control Plane?](docs/runtime_service_mgmt_api.md)
3341
- [How to Deploy and Run the AWS Agent in AWS Lambda?](functions/)
42+
- [Lambda Functions-Environment variables](docs/lambda-properties.md)
3443
- [Best Practices](docs/best-practices.md)
3544

3645

3746
## Implementation Overview
3847

39-
The implementation utilizes the **Manual** approach of Agent SDK and provides options for deploying the AWS agent as a stand-alone application. For details about the approaches and deployment modes, see [Agent SDK](https://docs.webmethods.io/apicontrolplane/agent_sdk/chapter2wco/#gsc.tab=0) documentation.
48+
The implementation utilizes the **Manual** approach of Agent SDK and provides options for deploying the AWS agent as a stand-alone application. For details about the approaches and deployment modes, see **Agent** section in [API Control Plane](https://docs.webmethods.io/#api-management-saas) documentation.
4049
The implementation leverages the following Amazon services:
4150
- **AWS SDK** for connection management and authentication.
4251
- **Amazon CloudWatch** service for retrieving API metrics.
@@ -49,6 +58,8 @@ The AWS agent can be deployed in the following ways:
4958
- **Spring Boot application**
5059
- **AWS Lambda**<br>
5160

61+
To understand the differences between Spring Boot application and AWS Lambda deployment modes, see [Differences](docs/differences.md).
62+
5263
For a detailed understanding of how the agent for Amazon API Gateway is implemented, see [Core Implementation Logic](docs/core-logic.md).
5364

5465
The AWS agent developer can utilize this repository in the following ways:

application/build.gradle

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ buildscript {
1111
plugins {
1212
id 'java'
1313
id 'org.springframework.boot' version '3.1.6'
14-
id 'io.spring.dependency-management' version '1.1.4'
1514
id "io.freefair.lombok" version "6.4.3"
1615
}
1716

application/readme.md

+50-52
Large diffs are not rendered by default.

application/src/main/java/com/softwareag/controlplane/agent/aws/configuration/AWSProperties.java

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.softwareag.controlplane.agent.aws.configuration;
22

3+
import jakarta.validation.constraints.Min;
34
import lombok.Getter;
45
import lombok.Setter;
56
import org.springframework.boot.context.properties.ConfigurationProperties;
@@ -20,6 +21,7 @@ public class AWSProperties {
2021
private String stage;
2122
@NotNull
2223
private String metricsByDataOrStatistics;
24+
@Min(600)
2325
private int metricsSyncBufferIntervalSeconds;
2426
private int assetsSyncBufferIntervalSeconds;
2527
}

application/src/main/resources/application.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ spring.main.web-application-type=NONE
22
aws.region=
33
aws.stage=
44
aws.metrics-by-data-or-statistics=statistics
5-
aws.metrics-sync-buffer-interval-seconds=60
5+
aws.metrics-sync-buffer-interval-seconds=600
66
aws.assets-sync-buffer-interval-seconds=300
77
apicp.publish-assets=true
88
apicp.sync-assets=true

dependencies.gradle

+29-30
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
ext {
2-
jacksonVersion = '2.15.2'
3-
micrometerVersion = '1.11.3'
4-
log4jVersion = '2.22.0'
5-
nettyVersion = '4.1.97.Final'
6-
nettyCodecVersion = '4.1.100.Final'
7-
nettyHandlerVersion = '4.1.101.Final'
8-
springVersion = '6.0.14'
9-
springBootVersion = '3.1.3'
10-
springSecurityVersion = '6.1.3'
11-
junitPlatformVersion = '1.9.3'
12-
junitJupiterVersion = '5.9.3'
13-
junitMockitoVersion = '5.3.1'
14-
bytebuddyVersion = '1.14.6'
15-
apacheCommonsLang3Version = '3.12.0'
16-
apacheLog4jTemplateVersion = '2.20.0'
2+
jacksonVersion = '2.17.1'
3+
micrometerVersion = '1.13.1'
4+
log4jVersion = '2.23.1'
5+
nettyVersion = '4.1.111.Final'
6+
springVersion = '6.1.10'
7+
springSecurityVersion = '6.3.1'
8+
springBootVersion = '3.3.1'
9+
junitPlatformVersion = '1.10.2'
10+
junitJupiterVersion = '5.10.2'
11+
junitMockitoVersion = '5.11.0'
12+
bytebuddyVersion = '1.14.17'
13+
apacheCommonsLang3Version = '3.14.0'
14+
apacheLog4jTemplateVersion = '2.23.1'
1715
awsAuthVersion = '2.17.267'
1816
awsSdkVersion = '2.23.18'
19-
tomcatVersion = '10.1.16'
20-
elasticsearchVersion = '7.17.15'
17+
tomcatVersion = '10.1.25'
18+
elasticsearchVersion = '8.13.4'
2119

2220
junit = [
2321
"org.junit.platform:junit-platform-commons:${junitPlatformVersion}",
@@ -38,12 +36,12 @@ ext {
3836

3937
apache = [
4038
"org.apache.commons:commons-lang3:$apacheCommonsLang3Version",
41-
'commons-codec:commons-codec:1.11',
39+
'commons-codec:commons-codec:1.16.1',
4240
"org.apache.logging.log4j:log4j-layout-template-json:$apacheLog4jTemplateVersion",
4341
]
4442

4543
json = [
46-
'org.json:json:20231013'
44+
'org.json:json:20240303'
4745
]
4846

4947
awsApiGateway = [
@@ -92,12 +90,14 @@ ext {
9290
"org.springframework.boot:spring-boot-actuator:$springBootVersion",
9391
"org.springframework.boot:spring-boot:$springBootVersion",
9492
"org.springframework.boot:spring-boot-starter-tomcat:$springBootVersion",
95-
"org.springframework.session:spring-session-core:3.0.1",
93+
"org.springframework.session:spring-session-core:$springBootVersion",
9694
"org.springframework.boot:spring-boot-starter-data-elasticsearch:$springBootVersion",
9795
"org.springframework.boot:spring-boot-starter-validation:$springBootVersion",
9896
"org.springframework.boot:spring-boot-starter-security:$springBootVersion",
9997
"org.springframework.boot:spring-boot-starter-webflux:$springBootVersion",
10098
"org.springframework.boot:spring-boot-starter-reactor-netty:$springBootVersion",
99+
"org.elasticsearch.client:elasticsearch-rest-client:$elasticsearchVersion",
100+
"co.elastic.clients:elasticsearch-java:$elasticsearchVersion",
101101
]
102102

103103
spring = [
@@ -138,7 +138,7 @@ ext {
138138
]
139139

140140
log4j = [
141-
"org.slf4j:slf4j-api:2.0.9",
141+
"org.slf4j:slf4j-api:2.0.13",
142142
"org.apache.logging.log4j:log4j-core:$log4jVersion",
143143
"org.apache.logging.log4j:log4j-api:$log4jVersion",
144144
]
@@ -155,10 +155,10 @@ ext {
155155
"io.netty:netty-buffer:$nettyVersion",
156156
"io.netty:netty-transport:$nettyVersion",
157157
"io.netty:netty-resolver:$nettyVersion",
158-
"io.netty:netty-codec:$nettyCodecVersion",
159-
"io.netty:netty-handler:$nettyHandlerVersion",
158+
"io.netty:netty-codec:$nettyVersion",
159+
"io.netty:netty-handler:$nettyVersion",
160160
"io.netty:netty-transport-native-unix-common:$nettyVersion",
161-
"io.netty:netty-codec-http2:$nettyCodecVersion",
161+
"io.netty:netty-codec-http2:$nettyVersion",
162162
"io.netty:netty-resolver-dns:$nettyVersion",
163163
"io.netty:netty-codec-dns:$nettyVersion",
164164
"io.netty:netty-resolver-dns-native-macos:$nettyVersion",
@@ -170,11 +170,11 @@ ext {
170170
]
171171

172172
reactor = [
173-
"io.projectreactor.netty:reactor-netty:1.0.33",
174-
"io.projectreactor:reactor-core:3.5.9",
173+
"io.projectreactor.netty:reactor-netty:1.1.20",
174+
"io.projectreactor:reactor-core:3.6.7",
175175
"org.reactivestreams:reactive-streams:1.0.4",
176-
"io.projectreactor.netty:reactor-netty-http:1.1.13",
177-
"io.projectreactor.netty:reactor-netty-core:1.1.10",
176+
"io.projectreactor.netty:reactor-netty-http:1.1.20",
177+
"io.projectreactor.netty:reactor-netty-core:1.1.20",
178178
]
179179

180180
lambdaFunctions = [
@@ -195,6 +195,7 @@ ext {
195195
]
196196

197197
springBootApplication = [
198+
"org.apache.logging.log4j:log4j-slf4j2-impl:$log4jVersion",
198199
spring,
199200
springBoot,
200201
apache,
@@ -244,5 +245,3 @@ ext {
244245
]
245246

246247
}
247-
248-

devops/docker-compose/.env

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ AWS_METRICS_BY_DATA_OR_STATISTICS=statistics
1010
# Time taken in seconds for the API metrics in AWS API Gateway to sync to AWS CloudWatch
1111
AWS_METRICS_SYNC_BUFFER_INTERVAL_SECONDS=60
1212
# Time taken in seconds for the API events in AWS API Gateway to sync to AWS CloudTrail
13-
AWS_ASSETS_SYNC_BUFFER_INTERVAL_SECONDS=300
13+
AWS_ASSETS_SYNC_BUFFER_INTERVAL_SECONDS=600
1414

1515

1616
# AWS Agent Configurations

devops/docker-compose/docker-compose.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ services:
1414
- aws.metrics-sync-buffer-interval-seconds=${AWS_METRICS_SYNC_BUFFER_INTERVAL_SECONDS}
1515
- apicp.publish-assets=${APICP_PUBLISH_ASSETS}
1616
- apicp.sync-assets=${APICP_SYNC_ASSETS}
17-
- apicp.sync-metrics=${APICP_SEND_METRICS}
18-
- apicp.heartbeat-sync-interval-seconds=${APICP_HEARTBEAT_SEND_INTERVAL_SECONDS}
17+
- apicp.send-metrics=${APICP_SEND_METRICS}
18+
- apicp.heart-beat-send-interval-seconds=${APICP_HEART_BEAT_SEND_INTERVAL_SECONDS}
1919
- apicp.assets-sync-interval-seconds=${APICP_ASSETS_SYNC_INTERVAL_SECONDS}
20-
- apicp.metrics-sync-interval-seconds=${APICP_METRICS_SEND_INTERVAL_SECONDS}
20+
- apicp.metrics-send-interval-seconds=${APICP_METRICS_SEND_INTERVAL_SECONDS}
2121
- apicp.runtime.name=${APICP_RUNTIME_NAME}
2222
- apicp.runtime.description=${APICP_RUNTIME_DESCRIPTION}
2323
- apicp.runtime.region=${APICP_RUNTIME_REGION}

devops/readme.md

+14-5
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@ Let’s look at a sample scenario through which you can build a Gradle project u
55

66
**Pre-requisites**
77

8-
Ensure that you have:
8+
Ensure that you have
99

1010
- Cloned **webmethods-api-control-plane-agent-aws** Git Hub repository using any GIT client.
11-
- Downloaded the **IBM webMethods API Control Plane 3rd Party Runtime Agent SDK** zip file from [IBM Integration Community](https://community.ibm.com/community/user/integration/communities/community-home/all-news?communitykey=82b75916-ed06-4a13-8eb6-0190da9f1bfa&LibraryFolderKey=&DefaultView=&8e5b3238-cf51-4036-aa29-601a6cd3e1b3=eyJsaWJyYXJ5ZW50cnkiOiJhMDAxMzc2Ni0wMWNiLTQ3ZDUtYmQ3Yi0wMTkyNDllNDZjYzIifQ==).
12-
- Copy and pasted the Agent SDK (api, core, and model) Jars from the extracted folder into the [Libs](../libs) directory in the cloned (api-controlplane-agent-aws) repository.
11+
- Empower portal login credentials to download the Agent SDK Jars. For details, see [How to access Agent SDK Jars](https://docs.webmethods.io/apicontrolplane/agent_sdk/chapter2wco#ta-implementing_agentsdk).
12+
- Installed **Java 17** and Gradle **7.4.2**<br>
13+
If you use different versions of *Java* or *Gradle*, ensure they are compatible with each other. For details about the compatibility between Java and Gradle versions, see [Compatibility Matrix](https://docs.gradle.org/current/userguide/compatibility.html).
1314

1415

1516
**To build the Gradle project**
1617

17-
1. Unzip Agent SDK folder downloaded from IBM Integration Community and place the (api, core, and model) Jars under *lib* folder in the cloned repository.
18+
1. Unzip Agent SDK folder downloaded from the Empower portal and place the (api, core, and model) Jars under *lib* folder in the cloned repository.
1819

1920
2. Open Visual Studio Code editor.
2021

@@ -28,11 +29,19 @@ Ensure that you have:
2829

2930
*Build Successful* message appears, and the following Jars are created for the application and Lambda functions:
3031

31-
**Spring Boot application**: **application-<version>-SNAPSHOT** is created at *application / build / libs* <br>
32+
**Spring Boot application**: **application-version-SNAPSHOT** is created at *application / build / libs* <br>
3233

3334
**AWS Lambda**: <br>
3435
- **lambda-layer.zip** is created at *functions / build / libs*, which includes all dependencies to run lambda function.<br>
3536
- **send-asset.jar** is created at *functions / send–asset / build / libs* <br>
3637
- **send-heartbeat.jar** is created at *functions / send-heartbeat / build / libs* <br>
3738
- **send-metrics.jar** is created at *functions / send-metrics / build / libs*
39+
40+
**Troubleshooting Tips**: For permission denied issues: <br>
41+
1. Verify if the Gradle has execution permissions. <br>
42+
2. Run ``` gradle build ``` (or) ``` ./gradlew build ```<br>
43+
3. If the issue persists, run:
44+
``` sh ./gradlew build ```
45+
(or)
46+
``` bash ./gradlew build ```
3847

docs/core-logic.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ Let’s understand the logic of how the agent for Amazon API Gateway is implemen
99
2. **Retrieving Amazon API Gateway’s health status and sending it to API Control Plane**.
1010

1111
1. The agent retrieves all REST APIs from the Amazon API Gateway.
12-
2. For each API, the agent verifies if the API is associated with the specified stage (from the properties).
13-
3. If the API is associated with the stage, the agent sends the health status (heartbeat) of the runtime (stage) as *active* to API Control Plane.<br><br>
12+
2. The agent verifies if at least one API is deployed to the specified stage in the given region (as per the properties). If an API is deployed, the agent sends the runtime (stage) health status as *active* to the API Control Plane.<br><br>
1413

1514
3. **Publishing Amazon API Gateway’s assets to API Control Plane**.
1615

docs/corelation.md

+2-35
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,6 @@
44
| Amazon API Gateway | API Control Plane | Description |
55
|--------------------|-------------------|-------------|
66
| Stage |Runtime | A stage in Amazon API Gateway is considered as a runtime in API Control Plane. |
7-
| Deployment | API Versions | A deployment in Amazon API Gateway is a snapshot that tracks an API's version. An API in Amazon API Gateway can have multiple deployments, but only one can be active per stage at a time. <br><br> In the API Control Plane, each deployment is called an API version. For example, if an API has two deployments published to two different stages, it is treated as two different versions of the same API in API Control Plane. |
8-
9-
## How to identify a unique stage in Amazon Gateway?
10-
11-
Every unique *stage* within each region in AWS API Gateway is considered as a separate runtime in the API Control Plane. Hence, you must deploy an agent for each unique stage.
12-
13-
For example: Assume that you have two accounts in **AWS** and each account has **AWS API Gateway** with APIs in the following regions and stages:
14-
15-
**Account 1**:
16-
- *Region 1*: us-east-1
17-
- *Stage*: dev (In APICP, this stage appears as **dev-account1-ue1** runtime from account 1 in region us-east-1)
18-
- *API*s: API1, API2
19-
- *Stage*: qa (In APICP, this stage appears as **qa-account1-ue1** runtime from account 1 in region us-east-1)
20-
- *APIs*: API1, API2
21-
- *Region 2*: us-east-2
22-
- *Stage*: dev (In APICP, this stage appears as **dev-account1-uw2** runtime from account 1 in region us-east-2)
23-
- APIs: API3
24-
- *Stage*: preprod (In APICP, this stage appears as **preprod-account1-uw2** runtime from account 1 in region us-east-2)
25-
- *APIs*: API3
26-
- *Stage*: prod (In APICP, this stage appears as **prod-account1-uw2** runtime from account 1 in region us-east-2)
27-
- *APIs*: API3
28-
29-
**Account 2**:
30-
- *Region 1*: us-east-1
31-
- *Stage*: dev (In APICP, this stage appears as **dev-account2-ue1** runtime from account 2 in region us-east-1)
32-
- *APIs*: API4
33-
- *Stage*: prod (In APICP, this stage appears as **prod-account2-ue1** runtime from account 2 in region us-east-1)
34-
- *APIs*: API4
35-
36-
37-
Please see the following diagram to understand how the stages are treated as different runtimes in the API Control Plane.
38-
39-
![](../docs/images/aws_stages.png)
40-
41-
7+
| Deployment | API Versions | A deployment in Amazon API Gateway is a snapshot that tracks an API's version. An API in Amazon API Gateway can have multiple deployments, but only one can be active per stage at a time. <br><br> In the API Control Plane, each deployment is called an API version. For example, if an API has two deployments published to two different stages, it is treated as two different versions of the same API in API Control Plane.<br>When there are multiple deployments of an API to a stage, only the active deployment is synchronized with API Control Plane. |
428

9+
A *Stage* in Amazon API Gateway created within a *region* and belonging to an *AWS account* is treated as an *individual runtime* in API Control Plane. As per the current implementation of the AWS agent, it requires one agent to be deployed for every stage-runtime mapping.

docs/differences.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## Differences between Spring Boot Application and Functions (AWS lambda) Flavour
2+
3+
The following table lists the differences between the Spring Boot Application and Functions (AWS lambda) Flavour
4+
5+
6+
| **Key Points** | **Spring Boot Application** | **Functions (AWS Lambda)** |
7+
|------------------|-----------------------------|----------------------------|
8+
| **Deployment** | Deployed like a regular server. | Deployed as Function as a Service (FaaS) on AWS Lambda|
9+
| **Maintenance and Availability** | **High maintenance**<br> User must manage deployment for full availability. | **Low maintenance**<br> For FaaS flavours, cloud hosting service providers such as *AWS* handles availability once deployed. |
10+
| **Resource Consumption and Cost** | Server runs 24x7, even with sparse utilization. | AWS provider manages and runs the code only when invoked. Charges are incurred only based on number of invocations and runtime. <br> More **cost effective** compared to regular hosted solutions.|
11+
| **Implementation** | A *single implementation* of spring boot application handles all three use cases of an agent: *assets synchronization*, *heartbeats synchronization*, and *metrics synchronization*. | Each Lambda function handles one use case of an agent. To achieve *assets synchronization*, *heartbeats synchronization*, and *metrics synchronization*, deploy three separate Lambda functions. |
12+
| **Schedule** | The frequency of the synchronization of heartbeats, assets, and metrics from the runtime to API Control Plane is maintained by the agent application code. Each activity gets triggered based on the *configured synchronization intervals*. | The schedule of the Lambda function is maintained in AWS component, **Amazon EventBridge**. The Lambda function gets triggered based on the intervals configured in EventBridge.<br> The schedule configured in EventBridge should match with with the synchronization intervals configured in the Lambda environment properties for smooth functioning. |
13+
| **Suitability** | Ideal for on-prem deployment flavour. | Suitable for hosted solutions. <br>Best in terms of maintenance and cost compared to other hosted flavours. |

0 commit comments

Comments
 (0)