Skip to content

Commit ef81402

Browse files
authored
Merge branch 'main' into pr/nodejs-express
2 parents fd1e369 + 63a92cd commit ef81402

File tree

9 files changed

+257
-10
lines changed

9 files changed

+257
-10
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ NOTICE @awslabs/mcp-admins
4848
/src/cdk-mcp-server @awslabs/mcp-admins @awslabs/mcp-maintainers @jimini55
4949
/src/cfn-mcp-server @awslabs/mcp-admins @awslabs/mcp-maintainers @scottschreckengaust @krokoko @alexa-perlov # @karamvsingh
5050
/src/cloudtrail-mcp-server @awslabs/mcp-admins @awslabs/mcp-maintainers @rokafella
51-
/src/cloudwatch-applicationsignals-mcp-server @awslabs/mcp-admins @awslabs/mcp-maintainers @yiyuan-he @mxiamxia @syed-ahsan-ishtiaque @thpierce @blairhyy-amazon @vastin
51+
/src/cloudwatch-applicationsignals-mcp-server @awslabs/mcp-admins @awslabs/mcp-maintainers @yiyuan-he @mxiamxia @syed-ahsan-ishtiaque @thpierce @blairhyy-amazon @vastin @wangzlei
5252
/src/cloudwatch-appsignals-mcp-server @awslabs/mcp-admins @awslabs/mcp-maintainers @yiyuan-he @mxiamxia @iismd17 @syed-ahsan-ishtiaque @thpierce
5353
/src/cloudwatch-mcp-server @awslabs/mcp-admins @awslabs/mcp-maintainers @gcacace @shri-tambe @agiuliano @goranmod
5454
/src/code-doc-gen-mcp-server @awslabs/mcp-admins @awslabs/mcp-maintainers @jimini55
@@ -83,7 +83,7 @@ NOTICE @awslabs/mcp-admins
8383

8484
## Samples
8585

86-
/samples/cloudwatch-applicationsignals-mcp @awslabs/mcp-admins @awslabs/mcp-maintainers @yiyuan-he @mxiamxia @syed-ahsan-ishtiaque @thpierce @blairhyy-amazon @vastin
86+
/samples/cloudwatch-applicationsignals-mcp @awslabs/mcp-admins @awslabs/mcp-maintainers @yiyuan-he @mxiamxia @syed-ahsan-ishtiaque @thpierce @blairhyy-amazon @vastin @wangzlei
8787
## Secure the CODEOWNERS file
8888

8989
/.github/CODEOWNERS @awslabs/mcp-admins

samples/cloudwatch-applicationsignals-mcp/get-enablement-guide-samples/README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,11 @@ docker buildx build --platform linux/amd64,linux/arm64 \
4848
.
4949
```
5050

51-
| Language-Framework | App Directory | ECR Repo |
52-
|--------------------|----------------------------|----------------|
53-
| python-flask | docker-apps/python/flask | python-flask |
54-
| nodejs-express | docker-apps/nodejs/express | nodejs-express |
51+
| Language-Framework | App Directory | ECR Repo |
52+
|--------------------|------------------------------|-----------------|
53+
| python-flask | docker-apps/python/flask | python-flask |
54+
| java-springboot | docker-apps/java/spring-boot | java-springboot |
55+
| nodejs-express | docker-apps/nodejs/express | nodejs-express |
5556

5657
##### Deploy & Cleanup Containerized Infrastructure
5758

@@ -68,7 +69,8 @@ cdk deploy <stack-name>
6869
cdk destroy <stack-name>
6970
```
7071

71-
| Language-Framework | Stack Name |
72-
|--------------------|---------------------- |
73-
| python-flask | PythonFlaskCdkStack |
74-
| nodejs-express | NodejsExpressCdkStack |
72+
| Language-Framework | Stack Name |
73+
|--------------------|------------------------|
74+
| python-flask | PythonFlaskCdkStack |
75+
| java-springboot | JavaSpringBootCdkStack |
76+
| nodejs-express | NodejsExpressCdkStack |
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
FROM public.ecr.aws/docker/library/maven:3.9-amazoncorretto-17 AS build
16+
17+
WORKDIR /app
18+
19+
COPY pom.xml .
20+
RUN mvn dependency:go-offline
21+
22+
COPY src ./src
23+
RUN mvn clean package -DskipTests
24+
25+
FROM public.ecr.aws/docker/library/amazoncorretto:17-alpine
26+
27+
RUN apk add --no-cache curl bash && \
28+
addgroup -g 1001 -S appuser && \
29+
adduser -u 1001 -S appuser -G appuser
30+
31+
WORKDIR /app
32+
33+
COPY --from=build /app/target/*.jar app.jar
34+
COPY generate-traffic.sh .
35+
36+
RUN chmod +x generate-traffic.sh && \
37+
chown -R appuser:appuser /app
38+
39+
USER appuser
40+
41+
ENV PORT=8080
42+
43+
EXPOSE 8080
44+
45+
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
46+
CMD curl -f http://localhost:${PORT}/health || exit 1
47+
48+
CMD ["java", "-jar", "app.jar"]
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
PORT=${PORT:-8080}
17+
BASE_URL="http://localhost:${PORT}"
18+
19+
echo "Starting continuous traffic generation to ${BASE_URL}"
20+
21+
while true; do
22+
echo "[$(date '+%H:%M:%S')] Generating traffic..."
23+
24+
curl -sf "${BASE_URL}/health" > /dev/null
25+
if [ $? -ne 0 ]; then
26+
echo "[$(date '+%H:%M:%S')] ERROR: Health check failed!"
27+
fi
28+
29+
curl -sf "${BASE_URL}/api/buckets" > /dev/null
30+
if [ $? -ne 0 ]; then
31+
echo "[$(date '+%H:%M:%S')] ERROR: API call to /api/buckets failed!"
32+
fi
33+
34+
sleep 2
35+
done
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.application</groupId>
8+
<artifactId>springboot-application</artifactId>
9+
<version>1.0.0</version>
10+
<packaging>jar</packaging>
11+
12+
<name>Spring Boot Application</name>
13+
<description>Spring Boot application for AWS Application Signals testing</description>
14+
15+
<parent>
16+
<groupId>org.springframework.boot</groupId>
17+
<artifactId>spring-boot-starter-parent</artifactId>
18+
<version>3.3.0</version>
19+
<relativePath/>
20+
</parent>
21+
22+
<properties>
23+
<java.version>17</java.version>
24+
<maven.compiler.source>17</maven.compiler.source>
25+
<maven.compiler.target>17</maven.compiler.target>
26+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
27+
</properties>
28+
29+
<dependencies>
30+
<dependency>
31+
<groupId>org.springframework.boot</groupId>
32+
<artifactId>spring-boot-starter-web</artifactId>
33+
</dependency>
34+
35+
<dependency>
36+
<groupId>software.amazon.awssdk</groupId>
37+
<artifactId>s3</artifactId>
38+
<version>2.28.0</version>
39+
</dependency>
40+
41+
<dependency>
42+
<groupId>org.springframework.boot</groupId>
43+
<artifactId>spring-boot-starter-logging</artifactId>
44+
</dependency>
45+
</dependencies>
46+
47+
<build>
48+
<plugins>
49+
<plugin>
50+
<groupId>org.springframework.boot</groupId>
51+
<artifactId>spring-boot-maven-plugin</artifactId>
52+
</plugin>
53+
</plugins>
54+
</build>
55+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package com.application.springboot;
16+
17+
import org.springframework.boot.SpringApplication;
18+
import org.springframework.boot.autoconfigure.SpringBootApplication;
19+
20+
@SpringBootApplication
21+
public class Application {
22+
public static void main(String[] args) {
23+
SpringApplication.run(Application.class, args);
24+
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package com.application.springboot;
16+
17+
import com.fasterxml.jackson.databind.ObjectMapper;
18+
import org.slf4j.Logger;
19+
import org.slf4j.LoggerFactory;
20+
import org.springframework.http.MediaType;
21+
import org.springframework.web.bind.annotation.GetMapping;
22+
import org.springframework.web.bind.annotation.RestController;
23+
import software.amazon.awssdk.services.s3.S3Client;
24+
import software.amazon.awssdk.services.s3.model.ListBucketsResponse;
25+
26+
import java.util.List;
27+
import java.util.Map;
28+
import java.util.stream.Collectors;
29+
30+
@RestController
31+
public class Controller {
32+
private static final Logger logger = LoggerFactory.getLogger(Controller.class);
33+
private final S3Client s3Client;
34+
private final ObjectMapper objectMapper;
35+
36+
public Controller() {
37+
this.s3Client = S3Client.builder().build();
38+
this.objectMapper = new ObjectMapper();
39+
}
40+
41+
@GetMapping(value = "/", produces = MediaType.APPLICATION_JSON_VALUE)
42+
public String index() throws Exception {
43+
return healthCheck();
44+
}
45+
46+
@GetMapping(value = "/health", produces = MediaType.APPLICATION_JSON_VALUE)
47+
public String healthCheck() throws Exception {
48+
logger.info("Health check endpoint called");
49+
Map<String, String> response = Map.of("status", "healthy");
50+
return objectMapper.writeValueAsString(response) + "\n";
51+
}
52+
53+
@GetMapping(value = "/api/buckets", produces = MediaType.APPLICATION_JSON_VALUE)
54+
public String listBuckets() throws Exception {
55+
try {
56+
ListBucketsResponse response = s3Client.listBuckets();
57+
List<String> buckets = response.buckets().stream()
58+
.map(bucket -> bucket.name())
59+
.collect(Collectors.toList());
60+
logger.info("Successfully listed " + buckets.size() + " S3 buckets");
61+
Map<String, Object> responseMap = Map.of(
62+
"bucket_count", buckets.size(),
63+
"buckets", buckets
64+
);
65+
return objectMapper.writeValueAsString(responseMap) + "\n";
66+
} catch (Exception e) {
67+
logger.error("Exception thrown when Listing Buckets: " + e.getMessage());
68+
Map<String, String> errorResponse = Map.of("error", "Failed to retrieve S3 buckets");
69+
return objectMapper.writeValueAsString(errorResponse) + "\n";
70+
}
71+
}
72+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
server.port=${PORT:8080}
2+
logging.level.root=INFO
3+
logging.level.com.example.springboot=INFO
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"appName": "JavaSpringBootCdk",
3+
"healthCheckPath": "/health",
4+
"imageName": "java-springboot",
5+
"language": "java",
6+
"port": 8080
7+
}

0 commit comments

Comments
 (0)