From 364f8c2d8f54700e11e28c276db0702c8940c870 Mon Sep 17 00:00:00 2001 From: Eric Zhang Date: Fri, 14 Nov 2025 17:21:27 -0800 Subject: [PATCH 1/2] add dotnet files --- .../get-enablement-guide-samples/README.md | 56 +++++++++++-------- .../dotnet/aspnetcore/AspNetCoreApp.csproj | 14 +++++ .../docker-apps/dotnet/aspnetcore/Dockerfile | 39 +++++++++++++ .../docker-apps/dotnet/aspnetcore/Program.cs | 54 ++++++++++++++++++ .../dotnet/aspnetcore/generate-traffic.sh | 39 +++++++++++++ .../ec2/cdk/config/dotnet-aspnetcore.json | 7 +++ .../terraform/config/dotnet-aspnetcore.tfvars | 5 ++ .../ecs/cdk/config/dotnet-aspnetcore.json | 7 +++ .../terraform/config/dotnet-aspnetcore.tfvars | 5 ++ .../eks/cdk/config/dotnet-aspnetcore.json | 7 +++ .../terraform/config/dotnet-aspnetcore.tfvars | 5 ++ 11 files changed, 214 insertions(+), 24 deletions(-) create mode 100644 mcp-testing/get-enablement-guide-samples/docker-apps/dotnet/aspnetcore/AspNetCoreApp.csproj create mode 100644 mcp-testing/get-enablement-guide-samples/docker-apps/dotnet/aspnetcore/Dockerfile create mode 100644 mcp-testing/get-enablement-guide-samples/docker-apps/dotnet/aspnetcore/Program.cs create mode 100755 mcp-testing/get-enablement-guide-samples/docker-apps/dotnet/aspnetcore/generate-traffic.sh create mode 100644 mcp-testing/get-enablement-guide-samples/infrastructure/ec2/cdk/config/dotnet-aspnetcore.json create mode 100644 mcp-testing/get-enablement-guide-samples/infrastructure/ec2/terraform/config/dotnet-aspnetcore.tfvars create mode 100644 mcp-testing/get-enablement-guide-samples/infrastructure/ecs/cdk/config/dotnet-aspnetcore.json create mode 100644 mcp-testing/get-enablement-guide-samples/infrastructure/ecs/terraform/config/dotnet-aspnetcore.tfvars create mode 100644 mcp-testing/get-enablement-guide-samples/infrastructure/eks/cdk/config/dotnet-aspnetcore.json create mode 100644 mcp-testing/get-enablement-guide-samples/infrastructure/eks/terraform/config/dotnet-aspnetcore.tfvars diff --git a/mcp-testing/get-enablement-guide-samples/README.md b/mcp-testing/get-enablement-guide-samples/README.md index 1d0cb7fab..526820422 100644 --- a/mcp-testing/get-enablement-guide-samples/README.md +++ b/mcp-testing/get-enablement-guide-samples/README.md @@ -57,12 +57,13 @@ docker buildx build --platform linux/amd64,linux/arm64 \ . ``` -| Language-Framework | App Directory | ECR Repo | -|--------------------|------------------------------|-----------------| -| python-flask | docker-apps/python/flask | python-flask | -| python-django | docker-apps/python/django | python-django | -| java-springboot | docker-apps/java/spring-boot | java-springboot | -| nodejs-express | docker-apps/nodejs/express | nodejs-express | +| Language-Framework | App Directory | ECR Repo | +|--------------------|-------------------------------|-------------------| +| dotnet-aspnetcore | docker-apps/dotnet/aspnetcore | dotnet-aspnetcore | +| python-flask | docker-apps/python/flask | python-flask | +| python-django | docker-apps/python/django | python-django | +| java-springboot | docker-apps/java/spring-boot | java-springboot | +| nodejs-express | docker-apps/nodejs/express | nodejs-express | ## Deployment Platforms @@ -81,12 +82,13 @@ cdk deploy cdk destroy ``` -| Language-Framework | Stack Name | -|--------------------|------------------------| -| python-flask | PythonFlaskCdkStack | -| python-django | PythonDjangoCdkStack | -| java-springboot | JavaSpringBootCdkStack | -| nodejs-express | NodejsExpressCdkStack | +| Language-Framework | Stack Name | +|--------------------|--------------------------| +| dotnet-aspnetcore | DotnetAspnetcoreCdkStack | +| python-flask | PythonFlaskCdkStack | +| python-django | PythonDjangoCdkStack | +| java-springboot | JavaSpringBootCdkStack | +| nodejs-express | NodejsExpressCdkStack | ### EKS Deployment @@ -106,12 +108,13 @@ cdk deploy cdk destroy ``` -| Language-Framework | Stack Name | -|--------------------|---------------------------| -| python-flask | PythonFlaskEksCdkStack | -| python-django | PythonDjangoEksCdkStack | -| java-springboot | JavaSpringBootEksCdkStack | -| nodejs-express | NodejsExpressEksCdkStack | +| Language-Framework | Stack Name | +|--------------------|------------------------------| +| dotnet-aspnetcore | DotnetAspnetcoreEksCdkStack | +| python-flask | PythonFlaskEksCdkStack | +| python-django | PythonDjangoEksCdkStack | +| java-springboot | JavaSpringBootEksCdkStack | +| nodejs-express | NodejsExpressEksCdkStack | #### Using Terraform @@ -156,12 +159,13 @@ terraform destroy -var-file="" ##### Configuration Reference -| Language-Framework | Variables File | -|--------------------|-------------------------------| -| python-flask | config/python-flask.tfvars | -| python-django | config/python-django.tfvars | -| java-springboot | config/java-springboot.tfvars | -| nodejs-express | config/nodejs-express.tfvars | +| Language-Framework | Variables File | +|--------------------|----------------------------------| +| dotnet-aspnetcore | config/dotnet-aspnetcore.tfvars | +| python-flask | config/python-flask.tfvars | +| python-django | config/python-django.tfvars | +| java-springboot | config/java-springboot.tfvars | +| nodejs-express | config/nodejs-express.tfvars | ### Lambda @@ -206,6 +210,7 @@ cdk destroy | Language | Config File | Stack Name | Function Name | Build Output | |----------|--------------|----------------------|-----------------|---------------------------| +| dotnet | dotnet.json | DotnetLambdaCdkStack | DotnetLambdaCdk | builds/dotnet-lambda.zip | | python | python.json | PythonLambdaCdkStack | PythonLambdaCdk | builds/python-lambda.zip | | nodejs | nodejs.json | NodejsLambdaCdkStack | NodejsLambdaCdk | builds/nodejs-lambda.zip | | java | java.json | JavaLambdaCdkStack | JavaLambdaCdk | builds/java-lambda.zip | @@ -225,6 +230,7 @@ terraform destroy -var="config_file=" | Language | Config File | Function Name | Build Output | |----------|--------------|------------------------|---------------------------| +| dotnet | dotnet.json | DotnetLambdaTerraform | builds/dotnet-lambda.zip | | python | python.json | PythonLambdaTerraform | builds/python-lambda.zip | | nodejs | nodejs.json | NodejsLambdaTerraform | builds/nodejs-lambda.zip | | java | java.json | JavaLambdaTerraform | builds/java-lambda.zip | @@ -237,11 +243,13 @@ After deployment, manually invoke the Lambda function to start generating intern ```bash # For CDK: +aws lambda invoke --function-name DotnetLambdaCdk --invocation-type Event /dev/stdout aws lambda invoke --function-name PythonLambdaCdk --invocation-type Event /dev/stdout aws lambda invoke --function-name NodejsLambdaCdk --invocation-type Event /dev/stdout aws lambda invoke --function-name JavaLambdaCdk --invocation-type Event /dev/stdout # For Terraform: +aws lambda invoke --function-name DotnetLambdaTerraform --invocation-type Event /dev/stdout aws lambda invoke --function-name PythonLambdaTerraform --invocation-type Event /dev/stdout aws lambda invoke --function-name NodejsLambdaTerraform --invocation-type Event /dev/stdout aws lambda invoke --function-name JavaLambdaTerraform --invocation-type Event /dev/stdout diff --git a/mcp-testing/get-enablement-guide-samples/docker-apps/dotnet/aspnetcore/AspNetCoreApp.csproj b/mcp-testing/get-enablement-guide-samples/docker-apps/dotnet/aspnetcore/AspNetCoreApp.csproj new file mode 100644 index 000000000..eb3341f36 --- /dev/null +++ b/mcp-testing/get-enablement-guide-samples/docker-apps/dotnet/aspnetcore/AspNetCoreApp.csproj @@ -0,0 +1,14 @@ + + + + net9.0 + enable + enable + + + + + + + + \ No newline at end of file diff --git a/mcp-testing/get-enablement-guide-samples/docker-apps/dotnet/aspnetcore/Dockerfile b/mcp-testing/get-enablement-guide-samples/docker-apps/dotnet/aspnetcore/Dockerfile new file mode 100644 index 000000000..263d8ca3c --- /dev/null +++ b/mcp-testing/get-enablement-guide-samples/docker-apps/dotnet/aspnetcore/Dockerfile @@ -0,0 +1,39 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM mcr.microsoft.com/dotnet/sdk:9.0 + +WORKDIR /app + +# Install curl for traffic generation +RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* + +COPY AspNetCoreApp.csproj . +RUN dotnet restore AspNetCoreApp.csproj + +COPY . . +RUN dotnet publish AspNetCoreApp.csproj -c Release -o out + +# Create non-root user for security +RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app +USER appuser + +ENV ASPNETCORE_URLS=http://+:5000 + +EXPOSE 5000 + +HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ + CMD curl -f http://localhost:5000/health || exit 1 + +CMD ["dotnet", "out/AspNetCoreApp.dll"] \ No newline at end of file diff --git a/mcp-testing/get-enablement-guide-samples/docker-apps/dotnet/aspnetcore/Program.cs b/mcp-testing/get-enablement-guide-samples/docker-apps/dotnet/aspnetcore/Program.cs new file mode 100644 index 000000000..553c67f2b --- /dev/null +++ b/mcp-testing/get-enablement-guide-samples/docker-apps/dotnet/aspnetcore/Program.cs @@ -0,0 +1,54 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Amazon.S3; +using Amazon.S3.Model; + +var builder = WebApplication.CreateBuilder(args); + +// Configure AWS S3 client +builder.Services.AddAWSService(); + +var app = builder.Build(); + +var awsRegion = Environment.GetEnvironmentVariable("AWS_REGION") ?? "us-east-1"; + +app.MapGet("/", (ILogger logger) => HealthCheck(logger)); +app.MapGet("/health", (ILogger logger) => HealthCheck(logger)); + +static IResult HealthCheck(ILogger logger) +{ + logger.LogInformation("Health check endpoint called"); + return Results.Json(new { status = "healthy" }); +} + +app.MapGet("/api/buckets", async (IAmazonS3 s3Client, ILogger logger) => +{ + try + { + var response = await s3Client.ListBucketsAsync(); + var buckets = response.Buckets.Select(b => b.BucketName).ToList(); + + logger.LogInformation("Successfully listed {BucketCount} S3 buckets", buckets.Count); + + return Results.Json(new { bucket_count = buckets.Count, buckets }); + } + catch (Exception ex) + { + logger.LogError(ex, "S3 client error: {ErrorMessage}", ex.Message); + return Results.Json(new { error = "Failed to retrieve S3 buckets" }, statusCode: 500); + } +}); + +app.Run(); \ No newline at end of file diff --git a/mcp-testing/get-enablement-guide-samples/docker-apps/dotnet/aspnetcore/generate-traffic.sh b/mcp-testing/get-enablement-guide-samples/docker-apps/dotnet/aspnetcore/generate-traffic.sh new file mode 100755 index 000000000..4a5f5f1f4 --- /dev/null +++ b/mcp-testing/get-enablement-guide-samples/docker-apps/dotnet/aspnetcore/generate-traffic.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Traffic generator script for ASP.NET Core application +PORT=${PORT:-5000} +BASE_URL="http://localhost:${PORT}" + +echo "Starting continuous traffic generation to ${BASE_URL}" + +while true; do + echo "[$(date '+%H:%M:%S')] Generating traffic..." + + # Health check + curl -sf "${BASE_URL}/health" > /dev/null + if [ $? -ne 0 ]; then + echo "[$(date '+%H:%M:%S')] ERROR: Health check failed!" + fi + + # API call (S3 buckets) + curl -sf "${BASE_URL}/api/buckets" > /dev/null + if [ $? -ne 0 ]; then + echo "[$(date '+%H:%M:%S')] ERROR: API call to /api/buckets failed!" + fi + + # Sleep between requests + sleep 2 +done \ No newline at end of file diff --git a/mcp-testing/get-enablement-guide-samples/infrastructure/ec2/cdk/config/dotnet-aspnetcore.json b/mcp-testing/get-enablement-guide-samples/infrastructure/ec2/cdk/config/dotnet-aspnetcore.json new file mode 100644 index 000000000..55674283b --- /dev/null +++ b/mcp-testing/get-enablement-guide-samples/infrastructure/ec2/cdk/config/dotnet-aspnetcore.json @@ -0,0 +1,7 @@ +{ + "appName": "DotnetAspnetcoreCdk", + "healthCheckPath": "/health", + "imageName": "dotnet-aspnetcore", + "language": "dotnet", + "port": 5000 +} \ No newline at end of file diff --git a/mcp-testing/get-enablement-guide-samples/infrastructure/ec2/terraform/config/dotnet-aspnetcore.tfvars b/mcp-testing/get-enablement-guide-samples/infrastructure/ec2/terraform/config/dotnet-aspnetcore.tfvars new file mode 100644 index 000000000..e9f8f7809 --- /dev/null +++ b/mcp-testing/get-enablement-guide-samples/infrastructure/ec2/terraform/config/dotnet-aspnetcore.tfvars @@ -0,0 +1,5 @@ +app_name = "DotnetAspnetcoreTerraform" +image_name = "dotnet-aspnetcore" +language = "dotnet" +port = 5000 +health_check_path = "/health" \ No newline at end of file diff --git a/mcp-testing/get-enablement-guide-samples/infrastructure/ecs/cdk/config/dotnet-aspnetcore.json b/mcp-testing/get-enablement-guide-samples/infrastructure/ecs/cdk/config/dotnet-aspnetcore.json new file mode 100644 index 000000000..a9b52a781 --- /dev/null +++ b/mcp-testing/get-enablement-guide-samples/infrastructure/ecs/cdk/config/dotnet-aspnetcore.json @@ -0,0 +1,7 @@ +{ + "appName": "dotnet-aspnetcore-ecs-cdk", + "healthCheckPath": "/health", + "imageName": "dotnet-aspnetcore", + "language": "dotnet", + "port": 5000 +} \ No newline at end of file diff --git a/mcp-testing/get-enablement-guide-samples/infrastructure/ecs/terraform/config/dotnet-aspnetcore.tfvars b/mcp-testing/get-enablement-guide-samples/infrastructure/ecs/terraform/config/dotnet-aspnetcore.tfvars new file mode 100644 index 000000000..bedf83c56 --- /dev/null +++ b/mcp-testing/get-enablement-guide-samples/infrastructure/ecs/terraform/config/dotnet-aspnetcore.tfvars @@ -0,0 +1,5 @@ +app_name = "dotnet-aspnetcore-ecs-terraform" +image_name = "dotnet-aspnetcore" +language = "dotnet" +port = 5000 +health_check_path = "/health" \ No newline at end of file diff --git a/mcp-testing/get-enablement-guide-samples/infrastructure/eks/cdk/config/dotnet-aspnetcore.json b/mcp-testing/get-enablement-guide-samples/infrastructure/eks/cdk/config/dotnet-aspnetcore.json new file mode 100644 index 000000000..c8b02e1b9 --- /dev/null +++ b/mcp-testing/get-enablement-guide-samples/infrastructure/eks/cdk/config/dotnet-aspnetcore.json @@ -0,0 +1,7 @@ +{ + "appName": "dotnet-aspnetcore-eks-cdk", + "healthCheckPath": "/health", + "imageName": "dotnet-aspnetcore", + "language": "dotnet", + "port": 5000 +} \ No newline at end of file diff --git a/mcp-testing/get-enablement-guide-samples/infrastructure/eks/terraform/config/dotnet-aspnetcore.tfvars b/mcp-testing/get-enablement-guide-samples/infrastructure/eks/terraform/config/dotnet-aspnetcore.tfvars new file mode 100644 index 000000000..cf9ed3076 --- /dev/null +++ b/mcp-testing/get-enablement-guide-samples/infrastructure/eks/terraform/config/dotnet-aspnetcore.tfvars @@ -0,0 +1,5 @@ +app_name = "dotnet-aspnetcore-eks-terraform" +image_name = "dotnet-aspnetcore" +language = "dotnet" +port = 5000 +health_check_path = "/health" \ No newline at end of file From dd24dd8791a01a7987b38a66aed8e4e3473e2cf0 Mon Sep 17 00:00:00 2001 From: Eric Zhang Date: Mon, 17 Nov 2025 12:52:47 -0800 Subject: [PATCH 2/2] remove lambda readme components --- .../samples/get-enablement-guide-samples/README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/mcp-testing/evals/tasks/applicationsignals/samples/get-enablement-guide-samples/README.md b/mcp-testing/evals/tasks/applicationsignals/samples/get-enablement-guide-samples/README.md index 526820422..d3160e2e6 100644 --- a/mcp-testing/evals/tasks/applicationsignals/samples/get-enablement-guide-samples/README.md +++ b/mcp-testing/evals/tasks/applicationsignals/samples/get-enablement-guide-samples/README.md @@ -210,7 +210,6 @@ cdk destroy | Language | Config File | Stack Name | Function Name | Build Output | |----------|--------------|----------------------|-----------------|---------------------------| -| dotnet | dotnet.json | DotnetLambdaCdkStack | DotnetLambdaCdk | builds/dotnet-lambda.zip | | python | python.json | PythonLambdaCdkStack | PythonLambdaCdk | builds/python-lambda.zip | | nodejs | nodejs.json | NodejsLambdaCdkStack | NodejsLambdaCdk | builds/nodejs-lambda.zip | | java | java.json | JavaLambdaCdkStack | JavaLambdaCdk | builds/java-lambda.zip | @@ -230,7 +229,6 @@ terraform destroy -var="config_file=" | Language | Config File | Function Name | Build Output | |----------|--------------|------------------------|---------------------------| -| dotnet | dotnet.json | DotnetLambdaTerraform | builds/dotnet-lambda.zip | | python | python.json | PythonLambdaTerraform | builds/python-lambda.zip | | nodejs | nodejs.json | NodejsLambdaTerraform | builds/nodejs-lambda.zip | | java | java.json | JavaLambdaTerraform | builds/java-lambda.zip | @@ -243,13 +241,11 @@ After deployment, manually invoke the Lambda function to start generating intern ```bash # For CDK: -aws lambda invoke --function-name DotnetLambdaCdk --invocation-type Event /dev/stdout aws lambda invoke --function-name PythonLambdaCdk --invocation-type Event /dev/stdout aws lambda invoke --function-name NodejsLambdaCdk --invocation-type Event /dev/stdout aws lambda invoke --function-name JavaLambdaCdk --invocation-type Event /dev/stdout # For Terraform: -aws lambda invoke --function-name DotnetLambdaTerraform --invocation-type Event /dev/stdout aws lambda invoke --function-name PythonLambdaTerraform --invocation-type Event /dev/stdout aws lambda invoke --function-name NodejsLambdaTerraform --invocation-type Event /dev/stdout aws lambda invoke --function-name JavaLambdaTerraform --invocation-type Event /dev/stdout