Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -81,12 +82,13 @@ cdk deploy <stack-name>
cdk destroy <stack-name>
```

| 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

Expand All @@ -106,12 +108,13 @@ cdk deploy <stack-name>
cdk destroy <stack-name>
```

| 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

Expand Down Expand Up @@ -156,12 +159,13 @@ terraform destroy -var-file="<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

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AWSSDK.S3" Version="3.7.504.1" />
<PackageReference Include="AWSSDK.Extensions.NETCore.Setup" Version="3.7.301" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -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"]
Original file line number Diff line number Diff line change
@@ -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<IAmazonS3>();

var app = builder.Build();

var awsRegion = Environment.GetEnvironmentVariable("AWS_REGION") ?? "us-east-1";

app.MapGet("/", (ILogger<Program> logger) => HealthCheck(logger));
app.MapGet("/health", (ILogger<Program> logger) => HealthCheck(logger));

static IResult HealthCheck(ILogger<Program> logger)
{
logger.LogInformation("Health check endpoint called");
return Results.Json(new { status = "healthy" });
}

app.MapGet("/api/buckets", async (IAmazonS3 s3Client, ILogger<Program> 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();
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"appName": "DotnetAspnetcoreCdk",
"healthCheckPath": "/health",
"imageName": "dotnet-aspnetcore",
"language": "dotnet",
"port": 5000
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
app_name = "DotnetAspnetcoreTerraform"
image_name = "dotnet-aspnetcore"
language = "dotnet"
port = 5000
health_check_path = "/health"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"appName": "dotnet-aspnetcore-ecs-cdk",
"healthCheckPath": "/health",
"imageName": "dotnet-aspnetcore",
"language": "dotnet",
"port": 5000
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
app_name = "dotnet-aspnetcore-ecs-terraform"
image_name = "dotnet-aspnetcore"
language = "dotnet"
port = 5000
health_check_path = "/health"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"appName": "dotnet-aspnetcore-eks-cdk",
"healthCheckPath": "/health",
"imageName": "dotnet-aspnetcore",
"language": "dotnet",
"port": 5000
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
app_name = "dotnet-aspnetcore-eks-terraform"
image_name = "dotnet-aspnetcore"
language = "dotnet"
port = 5000
health_check_path = "/health"