diff --git a/.vscode/extensions.json b/.vscode/extensions.json
index f9b011b..85d694b 100644
--- a/.vscode/extensions.json
+++ b/.vscode/extensions.json
@@ -1,9 +1,9 @@
{
- "recommendations": [
- "fernandoescolar.vscode-solution-explorer",
- "pkief.material-icon-theme",
- "k--kato.docomment",
- "jorgeserrano.vscode-csharp-snippets",
- "ms-dotnettools.csharp"
- ]
-}
\ No newline at end of file
+ "recommendations": [
+ "fernandoescolar.vscode-solution-explorer",
+ "pkief.material-icon-theme",
+ "k--kato.docomment",
+ "jorgeserrano.vscode-csharp-snippets",
+ "ms-dotnettools.csharp"
+ ]
+}
diff --git a/.vscode/launch.json b/.vscode/launch.json
index 6dbda1f..070deaa 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -1,35 +1,35 @@
{
- "version": "0.2.0",
- "configurations": [
- {
- // Use IntelliSense to find out which attributes exist for C# debugging
- // Use hover for the description of the existing attributes
- // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
- "name": ".NET Core Launch (web)",
- "type": "coreclr",
- "request": "launch",
- "preLaunchTask": "build",
- // If you have changed target frameworks, make sure to update the program path.
- "program": "${workspaceFolder}/WebAPI/src/apps/SampleWebApp/bin/Debug/net6.0/SampleWebApp.dll",
- "args": [],
- "cwd": "${workspaceFolder}/WebAPI/src/apps/SampleWebApp",
- "stopAtEntry": false,
- // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
- "serverReadyAction": {
- "action": "openExternally",
- "pattern": "\\bNow listening on:\\s+(https?://\\S+)"
- },
- "env": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- },
- "sourceFileMap": {
- "/Views": "${workspaceFolder}/Views"
- }
- },
- {
- "name": ".NET Core Attach",
- "type": "coreclr",
- "request": "attach"
- }
- ]
-}
\ No newline at end of file
+ "version": "0.2.0",
+ "configurations": [
+ {
+ // Use IntelliSense to find out which attributes exist for C# debugging
+ // Use hover for the description of the existing attributes
+ // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
+ "name": ".NET Core Launch (web)",
+ "type": "coreclr",
+ "request": "launch",
+ "preLaunchTask": "build",
+ // If you have changed target frameworks, make sure to update the program path.
+ "program": "${workspaceFolder}/SampleWebApp/bin/Debug/net6.0/SampleWebApp.dll",
+ "args": [],
+ "cwd": "${workspaceFolder}/SampleWebApp",
+ "stopAtEntry": false,
+ // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
+ "serverReadyAction": {
+ "action": "openExternally",
+ "pattern": "\\bNow listening on:\\s+(https?://\\S+)"
+ },
+ "env": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ },
+ "sourceFileMap": {
+ "/Views": "${workspaceFolder}/Views"
+ }
+ },
+ {
+ "name": ".NET Core Attach",
+ "type": "coreclr",
+ "request": "attach"
+ }
+ ]
+}
diff --git a/.vscode/solution-explorer/class.cs-template b/.vscode/solution-explorer/class.cs-template
deleted file mode 100644
index 20c7109..0000000
--- a/.vscode/solution-explorer/class.cs-template
+++ /dev/null
@@ -1,5 +0,0 @@
-namespace {{namespace}};
-
-public class {{name}}
-{
-}
diff --git a/.vscode/solution-explorer/class.ts-template b/.vscode/solution-explorer/class.ts-template
deleted file mode 100644
index ff2edef..0000000
--- a/.vscode/solution-explorer/class.ts-template
+++ /dev/null
@@ -1,3 +0,0 @@
-export class {{name}} {
-
-}
\ No newline at end of file
diff --git a/.vscode/solution-explorer/class.vb-template b/.vscode/solution-explorer/class.vb-template
deleted file mode 100644
index 38ef67f..0000000
--- a/.vscode/solution-explorer/class.vb-template
+++ /dev/null
@@ -1,9 +0,0 @@
-Imports System
-
-Namespace {{namespace}}
-
- Public Class {{name}}
-
- End Class
-
-End Namespace
diff --git a/.vscode/solution-explorer/default.ts-template b/.vscode/solution-explorer/default.ts-template
deleted file mode 100644
index 04af870..0000000
--- a/.vscode/solution-explorer/default.ts-template
+++ /dev/null
@@ -1,3 +0,0 @@
-export default {{name}} {
-
-}
\ No newline at end of file
diff --git a/.vscode/solution-explorer/enum.cs-template b/.vscode/solution-explorer/enum.cs-template
deleted file mode 100644
index 1ded8c0..0000000
--- a/.vscode/solution-explorer/enum.cs-template
+++ /dev/null
@@ -1,5 +0,0 @@
-namespace {{namespace}};
-
-public enum {{name}}
-{
-}
diff --git a/.vscode/solution-explorer/interface.cs-template b/.vscode/solution-explorer/interface.cs-template
deleted file mode 100644
index bf25cbb..0000000
--- a/.vscode/solution-explorer/interface.cs-template
+++ /dev/null
@@ -1,5 +0,0 @@
-namespace {{namespace}};
-
-public interface {{name}}
-{
-}
diff --git a/.vscode/solution-explorer/interface.ts-template b/.vscode/solution-explorer/interface.ts-template
deleted file mode 100644
index 3ea404b..0000000
--- a/.vscode/solution-explorer/interface.ts-template
+++ /dev/null
@@ -1,3 +0,0 @@
-export interface {{name}} {
-
-}
\ No newline at end of file
diff --git a/.vscode/solution-explorer/template-list.json b/.vscode/solution-explorer/template-list.json
deleted file mode 100644
index 2849622..0000000
--- a/.vscode/solution-explorer/template-list.json
+++ /dev/null
@@ -1,46 +0,0 @@
-{
- "templates": [
- {
- "name": "Class",
- "extension": "cs",
- "file": "./class.cs-template",
- "parameters": "./template-parameters.js"
- },
- {
- "name": "Interface",
- "extension": "cs",
- "file": "./interface.cs-template",
- "parameters": "./template-parameters.js"
- },
- {
- "name": "Enum",
- "extension": "cs",
- "file": "./enum.cs-template",
- "parameters": "./template-parameters.js"
- },
- {
- "name": "Class",
- "extension": "ts",
- "file": "./class.ts-template",
- "parameters": "./template-parameters.js"
- },
- {
- "name": "Interface",
- "extension": "ts",
- "file": "./interface.ts-template",
- "parameters": "./template-parameters.js"
- },
- {
- "name": "Default",
- "extension": "ts",
- "file": "./default.ts-template",
- "parameters": "./template-parameters.js"
- },
- {
- "name": "Class",
- "extension": "vb",
- "file": "./class.vb-template",
- "parameters": "./template-parameters.js"
- }
- ]
-}
\ No newline at end of file
diff --git a/.vscode/solution-explorer/template-parameters.js b/.vscode/solution-explorer/template-parameters.js
deleted file mode 100644
index daba8b2..0000000
--- a/.vscode/solution-explorer/template-parameters.js
+++ /dev/null
@@ -1,17 +0,0 @@
-var path = require("path");
-
-module.exports = function(filename, projectPath, folderPath) {
- var namespace = "Unknown";
- if (projectPath) {
- namespace = path.basename(projectPath, path.extname(projectPath));
- if (folderPath) {
- namespace += "." + folderPath.replace(path.dirname(projectPath), "").substring(1).replace(/[\\\/]/g, ".");
- }
- namespace = namespace.replace(/[\\\-]/g, "_");
- }
-
- return {
- namespace: namespace,
- name: path.basename(filename, path.extname(filename))
- }
-};
\ No newline at end of file
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
index 772386b..8c24093 100644
--- a/.vscode/tasks.json
+++ b/.vscode/tasks.json
@@ -1,41 +1,41 @@
{
- "version": "2.0.0",
- "tasks": [
- {
- "label": "build",
- "command": "dotnet",
- "type": "process",
- "args": [
- "build",
- "${workspaceFolder}/DemoSolution.sln",
- "/property:GenerateFullPaths=true",
- "/consoleloggerparameters:NoSummary"
- ],
- "problemMatcher": "$msCompile"
- },
- {
- "label": "publish",
- "command": "dotnet",
- "type": "process",
- "args": [
- "publish",
- "${workspaceFolder}/WebAPI/src/apps/SampleWebApp/SampleWebApp.csproj",
- "/property:GenerateFullPaths=true",
- "/consoleloggerparameters:NoSummary"
- ],
- "problemMatcher": "$msCompile"
- },
- {
- "label": "watch",
- "command": "dotnet",
- "type": "process",
- "args": [
- "watch",
- "run",
- "--project",
- "${workspaceFolder}/WebAPI/src/apps/SampleWebApp/SampleWebApp.csproj"
- ],
- "problemMatcher": "$msCompile"
- }
- ]
-}
\ No newline at end of file
+ "version": "2.0.0",
+ "tasks": [
+ {
+ "label": "build",
+ "command": "dotnet",
+ "type": "process",
+ "args": [
+ "build",
+ "${workspaceFolder}/DemoSolution.sln",
+ "/property:GenerateFullPaths=true",
+ "/consoleloggerparameters:NoSummary"
+ ],
+ "problemMatcher": "$msCompile"
+ },
+ {
+ "label": "publish",
+ "command": "dotnet",
+ "type": "process",
+ "args": [
+ "publish",
+ "${workspaceFolder}/SampleWebApp/SampleWebApp.csproj",
+ "/property:GenerateFullPaths=true",
+ "/consoleloggerparameters:NoSummary"
+ ],
+ "problemMatcher": "$msCompile"
+ },
+ {
+ "label": "watch",
+ "command": "dotnet",
+ "type": "process",
+ "args": [
+ "watch",
+ "run",
+ "--project",
+ "${workspaceFolder}/SampleWebApp/SampleWebApp.csproj"
+ ],
+ "problemMatcher": "$msCompile"
+ }
+ ]
+}
diff --git a/Common/Amazon.CDK.AWS.ECS.MyExtention/Amazon.CDK.AWS.ECS.MyExtensions.csproj b/Common/Amazon.CDK.AWS.ECS.MyExtention/Amazon.CDK.AWS.ECS.MyExtensions.csproj
deleted file mode 100644
index 3cb93da..0000000
--- a/Common/Amazon.CDK.AWS.ECS.MyExtention/Amazon.CDK.AWS.ECS.MyExtensions.csproj
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
- net6.0
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/DemoSolution.code-workspace b/DemoSolution.code-workspace
deleted file mode 100644
index b82bea4..0000000
--- a/DemoSolution.code-workspace
+++ /dev/null
@@ -1,32 +0,0 @@
-{
- "folders": [
- {
- "name": "Common",
- "path": "Common/Amazon.CDK.AWS.ECS.MyExtention"
- },
- {
- "name": "WorkerDb",
- "path": "ServicesWorkerDb/src/apps/WorkerDb"
- },
- {
- "name": "WorkerDb-Infra",
- "path": "ServicesWorkerDb/src/infra"
- },
- {
- "name": "WorkerIntegration",
- "path": "ServicesWorkerIntegration/src/apps/WorkerIntegration"
- },
- {
- "name": "WorkerIntegration-Infra",
- "path": "ServicesWorkerIntegration/src/Infra"
- },
- {
- "name": "SampleWebApp",
- "path": "WebAPI/src/apps/SampleWebApp"
- },
- {
- "name": "SampleWebApp-Infra",
- "path": "WebAPI/src/infra"
- },
- ]
-}
\ No newline at end of file
diff --git a/DemoSolution.sln b/DemoSolution.sln
index 28648d5..3d13448 100644
--- a/DemoSolution.sln
+++ b/DemoSolution.sln
@@ -7,21 +7,17 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Apps", "Apps", "{19D7C420-E
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infra", "Infra", "{5881D2F2-2866-4262-9909-DC5BDF539DF8}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleWebApp", "WebAPI\src\apps\SampleWebApp\SampleWebApp.csproj", "{C25C7F7F-6B71-45B1-BF0F-28975ED0EEB8}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleWebApp", "src\SampleWebApp\SampleWebApp.csproj", "{C25C7F7F-6B71-45B1-BF0F-28975ED0EEB8}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InfraSampleWebApp", "WebAPI\src\infra\src\Infra\InfraSampleWebApp.csproj", "{D0135CD7-9A0C-4BDA-A316-8741B3E556CE}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InfraSampleWebApp", "src\infra\src\Infra\InfraSampleWebApp.csproj", "{D0135CD7-9A0C-4BDA-A316-8741B3E556CE}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WorkerDb", "ServicesWorkerDb\src\apps\WorkerDb\WorkerDb.csproj", "{7FE3829D-3D80-4639-A665-14B7FED4DB51}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WorkerDb", "src\WorkerDb\WorkerDb.csproj", "{7FE3829D-3D80-4639-A665-14B7FED4DB51}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InfraWorkerDb", "ServicesWorkerDb\src\infra\src\Infra\InfraWorkerDb.csproj", "{DA4AADEB-6F5A-4125-BE50-85E31974CCC9}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WorkerIntegration", "ServicesWorkerIntegration\src\apps\WorkerIntegration\WorkerIntegration.csproj", "{FFE68605-33E6-44D7-A3F8-4B66DDC3AD5E}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InfraWorkerIntegration", "ServicesWorkerIntegration\src\infra\src\Infra\InfraWorkerIntegration.csproj", "{6D2D05F8-CD9A-49B9-9F0B-7EDF19E75FFB}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WorkerIntegration", "src\WorkerIntegration\WorkerIntegration.csproj", "{FFE68605-33E6-44D7-A3F8-4B66DDC3AD5E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{4FDEFB79-4CF9-478A-A729-5EC346445BFC}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Amazon.CDK.AWS.ECS.MyExtensions", "Common\Amazon.CDK.AWS.ECS.MyExtention\Amazon.CDK.AWS.ECS.MyExtensions.csproj", "{EEFCD529-46DF-4490-8015-E66658EC4E33}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Amazon.CDK.AWS.ECS.MyExtensions", "src\Common\Amazon.CDK.AWS.ECS.MyExtention\Amazon.CDK.AWS.ECS.MyExtensions.csproj", "{EEFCD529-46DF-4490-8015-E66658EC4E33}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -41,18 +37,10 @@ Global
{7FE3829D-3D80-4639-A665-14B7FED4DB51}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7FE3829D-3D80-4639-A665-14B7FED4DB51}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7FE3829D-3D80-4639-A665-14B7FED4DB51}.Release|Any CPU.Build.0 = Release|Any CPU
- {DA4AADEB-6F5A-4125-BE50-85E31974CCC9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {DA4AADEB-6F5A-4125-BE50-85E31974CCC9}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {DA4AADEB-6F5A-4125-BE50-85E31974CCC9}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {DA4AADEB-6F5A-4125-BE50-85E31974CCC9}.Release|Any CPU.Build.0 = Release|Any CPU
{FFE68605-33E6-44D7-A3F8-4B66DDC3AD5E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FFE68605-33E6-44D7-A3F8-4B66DDC3AD5E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FFE68605-33E6-44D7-A3F8-4B66DDC3AD5E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FFE68605-33E6-44D7-A3F8-4B66DDC3AD5E}.Release|Any CPU.Build.0 = Release|Any CPU
- {6D2D05F8-CD9A-49B9-9F0B-7EDF19E75FFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {6D2D05F8-CD9A-49B9-9F0B-7EDF19E75FFB}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {6D2D05F8-CD9A-49B9-9F0B-7EDF19E75FFB}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {6D2D05F8-CD9A-49B9-9F0B-7EDF19E75FFB}.Release|Any CPU.Build.0 = Release|Any CPU
{EEFCD529-46DF-4490-8015-E66658EC4E33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EEFCD529-46DF-4490-8015-E66658EC4E33}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EEFCD529-46DF-4490-8015-E66658EC4E33}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -65,9 +53,7 @@ Global
{C25C7F7F-6B71-45B1-BF0F-28975ED0EEB8} = {19D7C420-ED87-40B7-9874-D3C731198BD1}
{D0135CD7-9A0C-4BDA-A316-8741B3E556CE} = {5881D2F2-2866-4262-9909-DC5BDF539DF8}
{7FE3829D-3D80-4639-A665-14B7FED4DB51} = {19D7C420-ED87-40B7-9874-D3C731198BD1}
- {DA4AADEB-6F5A-4125-BE50-85E31974CCC9} = {5881D2F2-2866-4262-9909-DC5BDF539DF8}
{FFE68605-33E6-44D7-A3F8-4B66DDC3AD5E} = {19D7C420-ED87-40B7-9874-D3C731198BD1}
- {6D2D05F8-CD9A-49B9-9F0B-7EDF19E75FFB} = {5881D2F2-2866-4262-9909-DC5BDF539DF8}
{EEFCD529-46DF-4490-8015-E66658EC4E33} = {4FDEFB79-4CF9-478A-A729-5EC346445BFC}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
diff --git a/README.md b/README.md
index 880c7ca..9458570 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# Sample .NET6 Worker Services with AWS CDK and AWS Fargate
-This repository contains a sample implementation of Fanout Architecture using .NET6 Worker Services to process messages from [Amazon Simple Notification Service (SNS)](https://aws.amazon.com/sns/) Topic and [Amazon Simple Queue Service (SQS)](https://aws.amazon.com/sqs/) Queue. Since the Worker Services would have no UI, to operate this solution, you need Observability implemented. In this repository, you can also find sample .NET Observability implementation using the combination of [AWS X-Ray](https://aws.amazon.com/xray/) and [Amazon CloudWatch](https://aws.amazon.com/cloudwatch/). To provision this solution, you can use [AWS Cloud Development Kit (AWS CDK)](https://aws.amazon.com/cdk/) to implement your modern Infrastructure as Code, using .NET C# to provision all AWS Resources your application needs.
+This repository contains a sample implementation of Fanout Architecture using .NET8 Worker Services to process messages from [Amazon Simple Notification Service (SNS)](https://aws.amazon.com/sns/) Topic and [Amazon Simple Queue Service (SQS)](https://aws.amazon.com/sqs/) Queue. Since the Worker Services would have no UI, to operate this solution, you need Observability implemented. In this repository, you can also find sample .NET Observability implementation using the combination of [AWS X-Ray](https://aws.amazon.com/xray/) and [Amazon CloudWatch](https://aws.amazon.com/cloudwatch/). To provision this solution, you can use [AWS Cloud Development Kit (AWS CDK)](https://aws.amazon.com/cdk/) to implement your modern Infrastructure as Code, using .NET C# to provision all AWS Resources your application needs.
## Architecture
@@ -8,9 +8,9 @@ This repository contains a sample implementation of Fanout Architecture using .N
**Componets:**
-1. [.NET6 Web API Microservices](./WebAPI/README.md) - Demo Web API to simulate end-user requests.
-1. [.NET6 Worker Service 1](./ServicesWorkerDb/README.md) - Demo Worker Services that persist on DynamoDB.
-1. [.NET6 Worker Service 2](./ServicesWorkerIntegration/README.md) - Demo Worker Services that persist on S3.
+1. **.NET8 Web API Microservices** (src/SampleWebApp) - Demo Web API to simulate end-user requests.
+1. **.NET8 Worker Service 1** (src/WorkerDb) - Demo Worker Services that persist on DynamoDB.
+1. **.NET8 Worker Service 2** (src/WorkerIntegration) - Demo Worker Services that persist on S3.
1. [SNS](https://aws.amazon.com/sns/) - Fully managed pub/sub messaging for asynchronous processing.
1. [SQS](https://aws.amazon.com/sqs/) - Fully managed message queues for microservices.
1. [Amazon DynamoDb Table](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Introduction.html) - Fast, flexible NoSQL database service for single-digit millisecond performance at any scale.
@@ -27,7 +27,7 @@ Define cloud infrastructure using familiar programming languages [(C#)](./WebAPI
Before exploring the code, please ensure you have the following tools to deploy and see the demo working.
-* [_.NET 6_](https://dotnet.microsoft.com/en-us/download/dotnet/6.0)
+* [_.NET 8_](https://dotnet.microsoft.com/en-us/download/dotnet/8.0)
* [_Git CLI_](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
* [_AWS CLI_](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)
* [_AWS CDK v2_](https://docs.aws.amazon.com/cdk/v2/guide/cli.html)
@@ -44,7 +44,7 @@ For: [Bash]
./deploy.sh
```
-For: [Powershel]
+For: [PowerShell]
```PowerShell
.\deploy.ps1
@@ -52,16 +52,15 @@ For: [Powershel]
After completing the deployment, you can copy the printed URL like and jump to test
-
## Test the Solution
-To begin the tests, copy the URL printed by the deployment script. It will look like: “http://WebAp-demos-XXXXXXXX-99999999.us-west-2.elb.amazonaws.com”. Make a POST request to the endpoint http://YOUR_ALB_URL/api/Books using your favorite REST API Client, sending the following JSON payload. You can send multiple requests to have some sample data to visualize the Observability result from AWS CloudWatch console.
+To begin the tests, copy the URL printed by the deployment script. It will look like: “. Make a POST request to the endpoint http://YOUR_ALB_URL/api/Books using your favorite REST API Client, sending the following JSON payload. You can send multiple requests to have some sample data to visualize the Observability result from AWS CloudWatch console.
```json
{
"Year" : 2022,
"Title": "Demo book payload",
- "ISBN": 12345612,
+ "ISBN": "12345612",
"Authors": ["Author1", "Author2"],
"CoverPage": "picture1.jpg"
}
diff --git a/ServicesWorkerDb/README.md b/ServicesWorkerDb/README.md
deleted file mode 100644
index 8120b6b..0000000
--- a/ServicesWorkerDb/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# TODO: Add doc
-
-Add guide
diff --git a/ServicesWorkerDb/src/apps/WorkerDb/.vscode/launch.json b/ServicesWorkerDb/src/apps/WorkerDb/.vscode/launch.json
deleted file mode 100644
index ea532ac..0000000
--- a/ServicesWorkerDb/src/apps/WorkerDb/.vscode/launch.json
+++ /dev/null
@@ -1,29 +0,0 @@
-{
- "version": "0.2.0",
- "configurations": [
- {
- // Use IntelliSense to find out which attributes exist for C# debugging
- // Use hover for the description of the existing attributes
- // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
- "name": ".NET Core Launch (console)",
- "type": "coreclr",
- "request": "launch",
- "preLaunchTask": "build",
- // If you have changed target frameworks, make sure to update the program path.
- "program": "${workspaceFolder}/bin/Debug/net6.0/WorkerDb.dll",
- "args": [],
- "cwd": "${workspaceFolder}",
- // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
- "console": "internalConsole",
- "stopAtEntry": false,
- "env": {
- "WORKER_QUEUE_URL" : "PUT_YOUR_SQS_URL_HERE_FOR_DEBUG"
- }
- },
- {
- "name": ".NET Core Attach",
- "type": "coreclr",
- "request": "attach"
- }
- ]
-}
\ No newline at end of file
diff --git a/ServicesWorkerDb/src/apps/WorkerDb/.vscode/tasks.json b/ServicesWorkerDb/src/apps/WorkerDb/.vscode/tasks.json
deleted file mode 100644
index 10db966..0000000
--- a/ServicesWorkerDb/src/apps/WorkerDb/.vscode/tasks.json
+++ /dev/null
@@ -1,42 +0,0 @@
-{
- "version": "2.0.0",
- "tasks": [
- {
- "label": "build",
- "command": "dotnet",
- "type": "process",
- "args": [
- "build",
- "${workspaceFolder}/WorkerDb.csproj",
- "/property:GenerateFullPaths=true",
- "/consoleloggerparameters:NoSummary"
- ],
- "problemMatcher": "$msCompile"
- },
- {
- "label": "publish",
- "command": "dotnet",
- "type": "process",
- "args": [
- "publish",
- "${workspaceFolder}/WorkerDb.csproj",
- "/property:GenerateFullPaths=true",
- "/consoleloggerparameters:NoSummary"
- ],
- "problemMatcher": "$msCompile"
- },
- {
- "label": "watch",
- "command": "dotnet",
- "type": "process",
- "args": [
- "watch",
- "run",
- "${workspaceFolder}/WorkerDb.csproj",
- "/property:GenerateFullPaths=true",
- "/consoleloggerparameters:NoSummary"
- ],
- "problemMatcher": "$msCompile"
- }
- ]
-}
\ No newline at end of file
diff --git a/ServicesWorkerDb/src/apps/WorkerDb/WorkerDb.csproj b/ServicesWorkerDb/src/apps/WorkerDb/WorkerDb.csproj
deleted file mode 100644
index 04bacd6..0000000
--- a/ServicesWorkerDb/src/apps/WorkerDb/WorkerDb.csproj
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
- net6.0
- dotnet-WorkerDb-2E594750-EFDD-4104-9DE3-1139BE00B0E8
- enable
- WorkerDb
- true
- false
- false
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/ServicesWorkerDb/src/infra/.vscode/launch.json b/ServicesWorkerDb/src/infra/.vscode/launch.json
deleted file mode 100644
index ef7f9fd..0000000
--- a/ServicesWorkerDb/src/infra/.vscode/launch.json
+++ /dev/null
@@ -1,26 +0,0 @@
-{
- "version": "0.2.0",
- "configurations": [
- {
- // Use IntelliSense to find out which attributes exist for C# debugging
- // Use hover for the description of the existing attributes
- // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
- "name": ".NET Core Launch (console)",
- "type": "coreclr",
- "request": "launch",
- "preLaunchTask": "build",
- // If you have changed target frameworks, make sure to update the program path.
- "program": "${workspaceFolder}/src/Infra/bin/Debug/netcoreapp3.1/Infra.dll",
- "args": [],
- "cwd": "${workspaceFolder}/src/Infra",
- // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
- "console": "internalConsole",
- "stopAtEntry": false
- },
- {
- "name": ".NET Core Attach",
- "type": "coreclr",
- "request": "attach"
- }
- ]
-}
\ No newline at end of file
diff --git a/ServicesWorkerDb/src/infra/.vscode/tasks.json b/ServicesWorkerDb/src/infra/.vscode/tasks.json
deleted file mode 100644
index dba8281..0000000
--- a/ServicesWorkerDb/src/infra/.vscode/tasks.json
+++ /dev/null
@@ -1,42 +0,0 @@
-{
- "version": "2.0.0",
- "tasks": [
- {
- "label": "build",
- "command": "dotnet",
- "type": "process",
- "args": [
- "build",
- "${workspaceFolder}/src/Infra/Infra.csproj",
- "/property:GenerateFullPaths=true",
- "/consoleloggerparameters:NoSummary"
- ],
- "problemMatcher": "$msCompile"
- },
- {
- "label": "publish",
- "command": "dotnet",
- "type": "process",
- "args": [
- "publish",
- "${workspaceFolder}/src/Infra/Infra.csproj",
- "/property:GenerateFullPaths=true",
- "/consoleloggerparameters:NoSummary"
- ],
- "problemMatcher": "$msCompile"
- },
- {
- "label": "watch",
- "command": "dotnet",
- "type": "process",
- "args": [
- "watch",
- "run",
- "${workspaceFolder}/src/Infra/Infra.csproj",
- "/property:GenerateFullPaths=true",
- "/consoleloggerparameters:NoSummary"
- ],
- "problemMatcher": "$msCompile"
- }
- ]
-}
\ No newline at end of file
diff --git a/ServicesWorkerDb/src/infra/README.md b/ServicesWorkerDb/src/infra/README.md
deleted file mode 100644
index fee04ca..0000000
--- a/ServicesWorkerDb/src/infra/README.md
+++ /dev/null
@@ -1,14 +0,0 @@
-# Welcome to your CDK C# project!
-
-This is a blank project for C# development with CDK.
-
-The `cdk.json` file tells the CDK Toolkit how to execute your app.
-
-It uses the [.NET Core CLI](https://docs.microsoft.com/dotnet/articles/core/) to compile and execute your project.
-
-## Useful commands
-
-* `dotnet build src` compile this app
-* `cdk deploy` deploy this stack to your default AWS account/region
-* `cdk diff` compare deployed stack with current state
-* `cdk synth` emits the synthesized CloudFormation template
\ No newline at end of file
diff --git a/ServicesWorkerDb/src/infra/cdk.json b/ServicesWorkerDb/src/infra/cdk.json
deleted file mode 100644
index 3276118..0000000
--- a/ServicesWorkerDb/src/infra/cdk.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "app": "dotnet run --project src/Infra/InfraWorkerDb.csproj",
- "context": {}
-}
\ No newline at end of file
diff --git a/ServicesWorkerDb/src/infra/src/Infra.sln b/ServicesWorkerDb/src/infra/src/Infra.sln
deleted file mode 100644
index af04ab1..0000000
--- a/ServicesWorkerDb/src/infra/src/Infra.sln
+++ /dev/null
@@ -1,34 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.26124.0
-MinimumVisualStudioVersion = 15.0.26124.0
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Infra", "Infra\InfraWorkerDb.csproj", "{218E4AA6-6989-4CAF-93F4-91F0FE8E7D87}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Debug|x64 = Debug|x64
- Debug|x86 = Debug|x86
- Release|Any CPU = Release|Any CPU
- Release|x64 = Release|x64
- Release|x86 = Release|x86
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {218E4AA6-6989-4CAF-93F4-91F0FE8E7D87}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {218E4AA6-6989-4CAF-93F4-91F0FE8E7D87}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {218E4AA6-6989-4CAF-93F4-91F0FE8E7D87}.Debug|x64.ActiveCfg = Debug|Any CPU
- {218E4AA6-6989-4CAF-93F4-91F0FE8E7D87}.Debug|x64.Build.0 = Debug|Any CPU
- {218E4AA6-6989-4CAF-93F4-91F0FE8E7D87}.Debug|x86.ActiveCfg = Debug|Any CPU
- {218E4AA6-6989-4CAF-93F4-91F0FE8E7D87}.Debug|x86.Build.0 = Debug|Any CPU
- {218E4AA6-6989-4CAF-93F4-91F0FE8E7D87}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {218E4AA6-6989-4CAF-93F4-91F0FE8E7D87}.Release|Any CPU.Build.0 = Release|Any CPU
- {218E4AA6-6989-4CAF-93F4-91F0FE8E7D87}.Release|x64.ActiveCfg = Release|Any CPU
- {218E4AA6-6989-4CAF-93F4-91F0FE8E7D87}.Release|x64.Build.0 = Release|Any CPU
- {218E4AA6-6989-4CAF-93F4-91F0FE8E7D87}.Release|x86.ActiveCfg = Release|Any CPU
- {218E4AA6-6989-4CAF-93F4-91F0FE8E7D87}.Release|x86.Build.0 = Release|Any CPU
- EndGlobalSection
-EndGlobal
diff --git a/ServicesWorkerDb/src/infra/src/Infra/InfraStackDemo.cs b/ServicesWorkerDb/src/infra/src/Infra/InfraStackDemo.cs
deleted file mode 100644
index ab9e1a6..0000000
--- a/ServicesWorkerDb/src/infra/src/Infra/InfraStackDemo.cs
+++ /dev/null
@@ -1,155 +0,0 @@
-// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
-// SPDX-License-Identifier: MIT-0
-using System.Collections.Generic;
-using System.IO;
-using Amazon.CDK;
-using Amazon.CDK.AWS.DynamoDB;
-using Amazon.CDK.AWS.EC2;
-using Amazon.CDK.AWS.Ecr.Assets;
-using Amazon.CDK.AWS.ECS;
-using Amazon.CDK.AWS.ECS.Patterns;
-using Amazon.CDK.AWS.Logs;
-using Amazon.CDK.AWS.SNS;
-using Amazon.CDK.AWS.SNS.Subscriptions;
-using Amazon.CDK.AWS.SQS;
-using Constructs;
-using Amazon.CDK.AWS.ECS.MyExtensions;
-using System;
-
-namespace InfraWorkerDb
-{
- public class InfraStackDemo : Stack
- {
- internal InfraStackDemo(Construct scope, string id, IStackProps props = null) : base(scope, id, props)
- {
- const string XRAY_DAEMON = "xray-daemon";
- const string CW_AGET = "cwagent";
-
- //Note: For demo' cleanup propose, this Sample Code will set RemovalPolicy == DESTROY
- //this will clean all resources when you cdk destroy
- var cleanUpRemovePolicy = RemovalPolicy.DESTROY;
-
- //Import Resources from other Stack and Local env
- var importedSnsArn = Fn.ImportValue("DemoSnsTopicArn");
- var importedClusterName = Fn.ImportValue("DemoClusterName");
- var importedLogGroupName = Fn.ImportValue("DemoLogGroupName");
- var importedVpcId = System.Environment.GetEnvironmentVariable("DEMO_VPC_ID");
-
- //Import VPC using the value from env variable DEMO_VPC_ID
- var vpc = Vpc.FromLookup(this, "imported-vpc", new VpcLookupOptions
- {
- VpcId = importedVpcId
- });
-
- //Import ECS Cluster using VPC and the imported ClusterName
- var cluster = Cluster.FromClusterAttributes(this, "imported-cluester", new ClusterAttributes
- {
- Vpc = vpc,
- ClusterName = importedClusterName,
- SecurityGroups = Array.Empty(),
- });
-
- //Import SNS Topic created from other Stack
- var topic = Topic.FromTopicArn(this, "imported-topic", importedSnsArn);
-
- //Create SQS for Worker APP that persist data on DynamoDb
- var workerDbQueue = new Queue(this, "worker-db-queue", new QueueProps
- {
- QueueName = "worker-db-queue",
- RemovalPolicy = cleanUpRemovePolicy
- });
-
- //Grant Permission & Subscribe SNS Topic
- topic.AddSubscription(new SqsSubscription(workerDbQueue));
-
- //Create DynamoDb Table
- Table table = new Table(this, "Table", new TableProps
- {
- RemovalPolicy = cleanUpRemovePolicy,
- TableName = "BooksCatalog",
- PartitionKey = new Amazon.CDK.AWS.DynamoDB.Attribute { Name = "Id", Type = AttributeType.STRING },
- Encryption = TableEncryption.AWS_MANAGED
- });
- //Configure AutoScaling for DynamoDb Table
- IScalableTableAttribute readScaling = table.AutoScaleReadCapacity(new EnableScalingProps { MinCapacity = 1, MaxCapacity = 50 });
- readScaling.ScaleOnUtilization(new UtilizationScalingProps
- {
- TargetUtilizationPercent = 75
- });
-
- //Build docker container and publish to ECR
- var asset = new DockerImageAsset(this, "worker-db-image", new DockerImageAssetProps
- {
- Directory = Path.Combine(Directory.GetCurrentDirectory(), "../../src/apps/WorkerDb"),
- File = "Dockerfile",
- Platform = Platform_.LINUX_ARM64,
- });
-
- //Create logDrive to reuse the same AWS CloudWatch Log group created from the other Stack
- var logDriver = LogDriver.AwsLogs(new AwsLogDriverProps
- {
- LogGroup = LogGroup.FromLogGroupName(this, "imported-loggroup", importedLogGroupName),
- StreamPrefix = "ecs/worker-db"
- });
-
- //Autoscaling
- // See: https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-scaling-simple-step.html
- var autoscalingSteps = new Amazon.CDK.AWS.ApplicationAutoScaling.ScalingInterval[]{
- //Step adjustments for scale-out policy
- new Amazon.CDK.AWS.ApplicationAutoScaling.ScalingInterval{
- Lower = 0,
- Upper = 10,
- Change = 0
- },
- new Amazon.CDK.AWS.ApplicationAutoScaling.ScalingInterval{
- Lower = 20,
- Upper = null,
- Change = 3
- },
- new Amazon.CDK.AWS.ApplicationAutoScaling.ScalingInterval{
- Lower = null,
- Upper = -20,
- Change = -3
- },
- };
-
- //Level 3 Construct for SQS Queue processing
- var queueFargateSvc = new QueueProcessingFargateService(this, "queue-fargate-services-db", new QueueProcessingFargateServiceProps
- {
- Cluster = cluster,
- Queue = workerDbQueue,
- MinScalingCapacity = 1,
- MaxScalingCapacity = 100,
- ScalingSteps = autoscalingSteps,
- Cpu = 256,
- MemoryLimitMiB = 512,
- Image = ContainerImage.FromDockerImageAsset(asset),
- Environment = new Dictionary()
- {
- {"WORKER_QUEUE_URL", workerDbQueue.QueueUrl },
- {"AWS_REGION", this.Region},
- {"AWS_XRAY_DAEMON_ADDRESS",$"{XRAY_DAEMON}:2000" },
- {"EMF_LOG_GROUP_NAME", importedLogGroupName }
- },
- LogDriver = logDriver
- });
-
- //Grant permission to DynamoDB table and SQS to consume message from the Queue
- table.GrantWriteData(queueFargateSvc.TaskDefinition.TaskRole);
- table.Grant(queueFargateSvc.TaskDefinition.TaskRole, "dynamodb:DescribeTable");
- workerDbQueue.GrantConsumeMessages(queueFargateSvc.TaskDefinition.TaskRole);
-
- //Custom shared C# Library (reusability of code)
- queueFargateSvc.Service.TaskDefinition
- .AddXRayDaemon(new XRayDaemonProps
- {
- XRayDaemonContainerName = XRAY_DAEMON,
- LogDriver = logDriver
- }).AddCloudWatchAgent(new CloudWatchAgentProps
- {
- AgentContainerName = CW_AGET,
- LogDriver = logDriver,
- });
- }
- }
-}
diff --git a/ServicesWorkerDb/src/infra/src/Infra/InfraWorkerDb.csproj b/ServicesWorkerDb/src/infra/src/Infra/InfraWorkerDb.csproj
deleted file mode 100644
index b0afa32..0000000
--- a/ServicesWorkerDb/src/infra/src/Infra/InfraWorkerDb.csproj
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
- Exe
- net6.0
-
- Major
- true
- true
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/ServicesWorkerDb/src/infra/src/Infra/Program.cs b/ServicesWorkerDb/src/infra/src/Infra/Program.cs
deleted file mode 100644
index 37d958a..0000000
--- a/ServicesWorkerDb/src/infra/src/Infra/Program.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
-// SPDX-License-Identifier: MIT-0
-using Amazon.CDK;
-
-namespace InfraWorkerDb
-{
- sealed class Program
- {
- public static void Main(string[] args)
- {
- var app = new App();
- _ = new InfraStackDemo(app, "WorkerDbInfraStack", new StackProps
- {
- // If you don't specify 'env', this stack will be environment-agnostic.
- // Account/Region-dependent features and context lookups will not work,
- // but a single synthesized template can be deployed anywhere.
-
- // Uncomment the next block to specialize this stack for the AWS Account
- // and Region that are implied by the current CLI configuration.
- /*
- Env = new Amazon.CDK.Environment
- {
- Account = System.Environment.GetEnvironmentVariable("CDK_DEFAULT_ACCOUNT"),
- Region = System.Environment.GetEnvironmentVariable("CDK_DEFAULT_REGION"),
- }
- */
-
- // Uncomment the next block if you know exactly what Account and Region you
- // want to deploy the stack to.
- /**/
- Env = new Amazon.CDK.Environment
- {
- Account = System.Environment.GetEnvironmentVariable("CDK_DEPLOY_ACCOUNT") ??
- System.Environment.GetEnvironmentVariable("CDK_DEFAULT_ACCOUNT"),
- Region = System.Environment.GetEnvironmentVariable("CDK_DEPLOY_REGION") ??
- System.Environment.GetEnvironmentVariable("CDK_DEFAULT_REGION")
- }
-
- // For more information, see https://docs.aws.amazon.com/cdk/latest/guide/environments.html
- });
-
- app.Synth();
- }
- }
-}
diff --git a/ServicesWorkerIntegration/README.md b/ServicesWorkerIntegration/README.md
deleted file mode 100644
index 8120b6b..0000000
--- a/ServicesWorkerIntegration/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# TODO: Add doc
-
-Add guide
diff --git a/ServicesWorkerIntegration/src/apps/WorkerIntegration/.vscode/launch.json b/ServicesWorkerIntegration/src/apps/WorkerIntegration/.vscode/launch.json
deleted file mode 100644
index 5cc0288..0000000
--- a/ServicesWorkerIntegration/src/apps/WorkerIntegration/.vscode/launch.json
+++ /dev/null
@@ -1,26 +0,0 @@
-{
- "version": "0.2.0",
- "configurations": [
- {
- // Use IntelliSense to find out which attributes exist for C# debugging
- // Use hover for the description of the existing attributes
- // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
- "name": ".NET Core Launch (console)",
- "type": "coreclr",
- "request": "launch",
- "preLaunchTask": "build",
- // If you have changed target frameworks, make sure to update the program path.
- "program": "${workspaceFolder}/bin/Debug/net6.0/WorkerIntegration.dll",
- "args": [],
- "cwd": "${workspaceFolder}",
- // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
- "console": "internalConsole",
- "stopAtEntry": false
- },
- {
- "name": ".NET Core Attach",
- "type": "coreclr",
- "request": "attach"
- }
- ]
-}
\ No newline at end of file
diff --git a/ServicesWorkerIntegration/src/apps/WorkerIntegration/.vscode/tasks.json b/ServicesWorkerIntegration/src/apps/WorkerIntegration/.vscode/tasks.json
deleted file mode 100644
index fb456c7..0000000
--- a/ServicesWorkerIntegration/src/apps/WorkerIntegration/.vscode/tasks.json
+++ /dev/null
@@ -1,42 +0,0 @@
-{
- "version": "2.0.0",
- "tasks": [
- {
- "label": "build",
- "command": "dotnet",
- "type": "process",
- "args": [
- "build",
- "${workspaceFolder}/WorkerIntegration.csproj",
- "/property:GenerateFullPaths=true",
- "/consoleloggerparameters:NoSummary"
- ],
- "problemMatcher": "$msCompile"
- },
- {
- "label": "publish",
- "command": "dotnet",
- "type": "process",
- "args": [
- "publish",
- "${workspaceFolder}/WorkerIntegration.csproj",
- "/property:GenerateFullPaths=true",
- "/consoleloggerparameters:NoSummary"
- ],
- "problemMatcher": "$msCompile"
- },
- {
- "label": "watch",
- "command": "dotnet",
- "type": "process",
- "args": [
- "watch",
- "run",
- "${workspaceFolder}/WorkerIntegration.csproj",
- "/property:GenerateFullPaths=true",
- "/consoleloggerparameters:NoSummary"
- ],
- "problemMatcher": "$msCompile"
- }
- ]
-}
\ No newline at end of file
diff --git a/ServicesWorkerIntegration/src/infra/.gitignore b/ServicesWorkerIntegration/src/infra/.gitignore
deleted file mode 100644
index f555633..0000000
--- a/ServicesWorkerIntegration/src/infra/.gitignore
+++ /dev/null
@@ -1,342 +0,0 @@
-# CDK asset staging directory
-.cdk.staging
-cdk.out
-
-# Created by https://www.gitignore.io/api/csharp
-
-### Csharp ###
-## Ignore Visual Studio temporary files, build results, and
-## files generated by popular Visual Studio add-ons.
-##
-## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
-
-# User-specific files
-*.suo
-*.user
-*.userosscache
-*.sln.docstates
-
-# User-specific files (MonoDevelop/Xamarin Studio)
-*.userprefs
-
-# Build results
-[Dd]ebug/
-[Dd]ebugPublic/
-[Rr]elease/
-[Rr]eleases/
-x64/
-x86/
-bld/
-[Bb]in/
-[Oo]bj/
-[Ll]og/
-
-# Visual Studio 2015/2017 cache/options directory
-.vs/
-# Uncomment if you have tasks that create the project's static files in wwwroot
-#wwwroot/
-
-# Visual Studio 2017 auto generated files
-Generated\ Files/
-
-# MSTest test Results
-[Tt]est[Rr]esult*/
-[Bb]uild[Ll]og.*
-
-# NUNIT
-*.VisualState.xml
-TestResult.xml
-
-# Build Results of an ATL Project
-[Dd]ebugPS/
-[Rr]eleasePS/
-dlldata.c
-
-# Benchmark Results
-BenchmarkDotNet.Artifacts/
-
-# .NET Core
-project.lock.json
-project.fragment.lock.json
-artifacts/
-
-# StyleCop
-StyleCopReport.xml
-
-# Files built by Visual Studio
-*_i.c
-*_p.c
-*_i.h
-*.ilk
-*.meta
-*.obj
-*.iobj
-*.pch
-*.pdb
-*.ipdb
-*.pgc
-*.pgd
-*.rsp
-*.sbr
-*.tlb
-*.tli
-*.tlh
-*.tmp
-*.tmp_proj
-*.log
-*.vspscc
-*.vssscc
-.builds
-*.pidb
-*.svclog
-*.scc
-
-# Chutzpah Test files
-_Chutzpah*
-
-# Visual C++ cache files
-ipch/
-*.aps
-*.ncb
-*.opendb
-*.opensdf
-*.sdf
-*.cachefile
-*.VC.db
-*.VC.VC.opendb
-
-# Visual Studio profiler
-*.psess
-*.vsp
-*.vspx
-*.sap
-
-# Visual Studio Trace Files
-*.e2e
-
-# TFS 2012 Local Workspace
-$tf/
-
-# Guidance Automation Toolkit
-*.gpState
-
-# ReSharper is a .NET coding add-in
-_ReSharper*/
-*.[Rr]e[Ss]harper
-*.DotSettings.user
-
-# JustCode is a .NET coding add-in
-.JustCode
-
-# TeamCity is a build add-in
-_TeamCity*
-
-# DotCover is a Code Coverage Tool
-*.dotCover
-
-# AxoCover is a Code Coverage Tool
-.axoCover/*
-!.axoCover/settings.json
-
-# Visual Studio code coverage results
-*.coverage
-*.coveragexml
-
-# NCrunch
-_NCrunch_*
-.*crunch*.local.xml
-nCrunchTemp_*
-
-# MightyMoose
-*.mm.*
-AutoTest.Net/
-
-# Web workbench (sass)
-.sass-cache/
-
-# Installshield output folder
-[Ee]xpress/
-
-# DocProject is a documentation generator add-in
-DocProject/buildhelp/
-DocProject/Help/*.HxT
-DocProject/Help/*.HxC
-DocProject/Help/*.hhc
-DocProject/Help/*.hhk
-DocProject/Help/*.hhp
-DocProject/Help/Html2
-DocProject/Help/html
-
-# Click-Once directory
-publish/
-
-# Publish Web Output
-*.[Pp]ublish.xml
-*.azurePubxml
-# Note: Comment the next line if you want to checkin your web deploy settings,
-# but database connection strings (with potential passwords) will be unencrypted
-*.pubxml
-*.publishproj
-
-# Microsoft Azure Web App publish settings. Comment the next line if you want to
-# checkin your Azure Web App publish settings, but sensitive information contained
-# in these scripts will be unencrypted
-PublishScripts/
-
-# NuGet Packages
-*.nupkg
-# The packages folder can be ignored because of Package Restore
-**/[Pp]ackages/*
-# except build/, which is used as an MSBuild target.
-!**/[Pp]ackages/build/
-# Uncomment if necessary however generally it will be regenerated when needed
-#!**/[Pp]ackages/repositories.config
-# NuGet v3's project.json files produces more ignorable files
-*.nuget.props
-*.nuget.targets
-
-# Microsoft Azure Build Output
-csx/
-*.build.csdef
-
-# Microsoft Azure Emulator
-ecf/
-rcf/
-
-# Windows Store app package directories and files
-AppPackages/
-BundleArtifacts/
-Package.StoreAssociation.xml
-_pkginfo.txt
-*.appx
-
-# Visual Studio cache files
-# files ending in .cache can be ignored
-*.[Cc]ache
-# but keep track of directories ending in .cache
-!*.[Cc]ache/
-
-# Others
-ClientBin/
-~$*
-*~
-*.dbmdl
-*.dbproj.schemaview
-*.jfm
-*.pfx
-*.publishsettings
-orleans.codegen.cs
-
-# Including strong name files can present a security risk
-# (https://github.com/github/gitignore/pull/2483#issue-259490424)
-#*.snk
-
-# Since there are multiple workflows, uncomment next line to ignore bower_components
-# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
-#bower_components/
-
-# RIA/Silverlight projects
-Generated_Code/
-
-# Backup & report files from converting an old project file
-# to a newer Visual Studio version. Backup files are not needed,
-# because we have git ;-)
-_UpgradeReport_Files/
-Backup*/
-UpgradeLog*.XML
-UpgradeLog*.htm
-ServiceFabricBackup/
-*.rptproj.bak
-
-# SQL Server files
-*.mdf
-*.ldf
-*.ndf
-
-# Business Intelligence projects
-*.rdl.data
-*.bim.layout
-*.bim_*.settings
-*.rptproj.rsuser
-
-# Microsoft Fakes
-FakesAssemblies/
-
-# GhostDoc plugin setting file
-*.GhostDoc.xml
-
-# Node.js Tools for Visual Studio
-.ntvs_analysis.dat
-node_modules/
-
-# Visual Studio 6 build log
-*.plg
-
-# Visual Studio 6 workspace options file
-*.opt
-
-# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
-*.vbw
-
-# Visual Studio LightSwitch build output
-**/*.HTMLClient/GeneratedArtifacts
-**/*.DesktopClient/GeneratedArtifacts
-**/*.DesktopClient/ModelManifest.xml
-**/*.Server/GeneratedArtifacts
-**/*.Server/ModelManifest.xml
-_Pvt_Extensions
-
-# Paket dependency manager
-.paket/paket.exe
-paket-files/
-
-# FAKE - F# Make
-.fake/
-
-# JetBrains Rider
-.idea/
-*.sln.iml
-
-# CodeRush
-.cr/
-
-# Python Tools for Visual Studio (PTVS)
-__pycache__/
-*.pyc
-
-# Cake - Uncomment if you are using it
-# tools/**
-# !tools/packages.config
-
-# Tabs Studio
-*.tss
-
-# Telerik's JustMock configuration file
-*.jmconfig
-
-# BizTalk build output
-*.btp.cs
-*.btm.cs
-*.odx.cs
-*.xsd.cs
-
-# OpenCover UI analysis results
-OpenCover/
-
-# Azure Stream Analytics local run output
-ASALocalRun/
-
-# MSBuild Binary and Structured Log
-*.binlog
-
-# NVidia Nsight GPU debugger configuration file
-*.nvuser
-
-# MFractors (Xamarin productivity tool) working folder
-.mfractor/
-
-# Local History for Visual Studio
-.localhistory/
-
-
-# End of https://www.gitignore.io/api/csharp
\ No newline at end of file
diff --git a/ServicesWorkerIntegration/src/infra/.vscode/launch.json b/ServicesWorkerIntegration/src/infra/.vscode/launch.json
deleted file mode 100644
index ef7f9fd..0000000
--- a/ServicesWorkerIntegration/src/infra/.vscode/launch.json
+++ /dev/null
@@ -1,26 +0,0 @@
-{
- "version": "0.2.0",
- "configurations": [
- {
- // Use IntelliSense to find out which attributes exist for C# debugging
- // Use hover for the description of the existing attributes
- // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
- "name": ".NET Core Launch (console)",
- "type": "coreclr",
- "request": "launch",
- "preLaunchTask": "build",
- // If you have changed target frameworks, make sure to update the program path.
- "program": "${workspaceFolder}/src/Infra/bin/Debug/netcoreapp3.1/Infra.dll",
- "args": [],
- "cwd": "${workspaceFolder}/src/Infra",
- // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
- "console": "internalConsole",
- "stopAtEntry": false
- },
- {
- "name": ".NET Core Attach",
- "type": "coreclr",
- "request": "attach"
- }
- ]
-}
\ No newline at end of file
diff --git a/ServicesWorkerIntegration/src/infra/.vscode/tasks.json b/ServicesWorkerIntegration/src/infra/.vscode/tasks.json
deleted file mode 100644
index dba8281..0000000
--- a/ServicesWorkerIntegration/src/infra/.vscode/tasks.json
+++ /dev/null
@@ -1,42 +0,0 @@
-{
- "version": "2.0.0",
- "tasks": [
- {
- "label": "build",
- "command": "dotnet",
- "type": "process",
- "args": [
- "build",
- "${workspaceFolder}/src/Infra/Infra.csproj",
- "/property:GenerateFullPaths=true",
- "/consoleloggerparameters:NoSummary"
- ],
- "problemMatcher": "$msCompile"
- },
- {
- "label": "publish",
- "command": "dotnet",
- "type": "process",
- "args": [
- "publish",
- "${workspaceFolder}/src/Infra/Infra.csproj",
- "/property:GenerateFullPaths=true",
- "/consoleloggerparameters:NoSummary"
- ],
- "problemMatcher": "$msCompile"
- },
- {
- "label": "watch",
- "command": "dotnet",
- "type": "process",
- "args": [
- "watch",
- "run",
- "${workspaceFolder}/src/Infra/Infra.csproj",
- "/property:GenerateFullPaths=true",
- "/consoleloggerparameters:NoSummary"
- ],
- "problemMatcher": "$msCompile"
- }
- ]
-}
\ No newline at end of file
diff --git a/ServicesWorkerIntegration/src/infra/README.md b/ServicesWorkerIntegration/src/infra/README.md
deleted file mode 100644
index fee04ca..0000000
--- a/ServicesWorkerIntegration/src/infra/README.md
+++ /dev/null
@@ -1,14 +0,0 @@
-# Welcome to your CDK C# project!
-
-This is a blank project for C# development with CDK.
-
-The `cdk.json` file tells the CDK Toolkit how to execute your app.
-
-It uses the [.NET Core CLI](https://docs.microsoft.com/dotnet/articles/core/) to compile and execute your project.
-
-## Useful commands
-
-* `dotnet build src` compile this app
-* `cdk deploy` deploy this stack to your default AWS account/region
-* `cdk diff` compare deployed stack with current state
-* `cdk synth` emits the synthesized CloudFormation template
\ No newline at end of file
diff --git a/ServicesWorkerIntegration/src/infra/cdk.json b/ServicesWorkerIntegration/src/infra/cdk.json
deleted file mode 100644
index d81ad89..0000000
--- a/ServicesWorkerIntegration/src/infra/cdk.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "app": "dotnet run --project src/Infra/InfraWorkerIntegration.csproj",
- "context": {}
-}
\ No newline at end of file
diff --git a/ServicesWorkerIntegration/src/infra/src/Infra.sln b/ServicesWorkerIntegration/src/infra/src/Infra.sln
deleted file mode 100644
index 5261c0c..0000000
--- a/ServicesWorkerIntegration/src/infra/src/Infra.sln
+++ /dev/null
@@ -1,34 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.26124.0
-MinimumVisualStudioVersion = 15.0.26124.0
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Infra", "Infra\InfraWorkerIntegration.csproj", "{62A5C49C-CF44-4463-9FBD-9B60759E05F7}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Debug|x64 = Debug|x64
- Debug|x86 = Debug|x86
- Release|Any CPU = Release|Any CPU
- Release|x64 = Release|x64
- Release|x86 = Release|x86
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {62A5C49C-CF44-4463-9FBD-9B60759E05F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {62A5C49C-CF44-4463-9FBD-9B60759E05F7}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {62A5C49C-CF44-4463-9FBD-9B60759E05F7}.Debug|x64.ActiveCfg = Debug|Any CPU
- {62A5C49C-CF44-4463-9FBD-9B60759E05F7}.Debug|x64.Build.0 = Debug|Any CPU
- {62A5C49C-CF44-4463-9FBD-9B60759E05F7}.Debug|x86.ActiveCfg = Debug|Any CPU
- {62A5C49C-CF44-4463-9FBD-9B60759E05F7}.Debug|x86.Build.0 = Debug|Any CPU
- {62A5C49C-CF44-4463-9FBD-9B60759E05F7}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {62A5C49C-CF44-4463-9FBD-9B60759E05F7}.Release|Any CPU.Build.0 = Release|Any CPU
- {62A5C49C-CF44-4463-9FBD-9B60759E05F7}.Release|x64.ActiveCfg = Release|Any CPU
- {62A5C49C-CF44-4463-9FBD-9B60759E05F7}.Release|x64.Build.0 = Release|Any CPU
- {62A5C49C-CF44-4463-9FBD-9B60759E05F7}.Release|x86.ActiveCfg = Release|Any CPU
- {62A5C49C-CF44-4463-9FBD-9B60759E05F7}.Release|x86.Build.0 = Release|Any CPU
- EndGlobalSection
-EndGlobal
diff --git a/ServicesWorkerIntegration/src/infra/src/Infra/InfraStackDemo.cs b/ServicesWorkerIntegration/src/infra/src/Infra/InfraStackDemo.cs
deleted file mode 100644
index 800599a..0000000
--- a/ServicesWorkerIntegration/src/infra/src/Infra/InfraStackDemo.cs
+++ /dev/null
@@ -1,158 +0,0 @@
-// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
-// SPDX-License-Identifier: MIT-0
-using System.Collections.Generic;
-using System.IO;
-using Amazon.CDK;
-using Amazon.CDK.AWS.ApplicationAutoScaling;
-using Amazon.CDK.AWS.EC2;
-using Amazon.CDK.AWS.Ecr.Assets;
-using Amazon.CDK.AWS.ECS;
-using Amazon.CDK.AWS.ECS.MyExtensions;
-using Amazon.CDK.AWS.ECS.Patterns;
-using Amazon.CDK.AWS.IAM;
-using Amazon.CDK.AWS.Logs;
-using Amazon.CDK.AWS.S3;
-using Amazon.CDK.AWS.SNS;
-using Amazon.CDK.AWS.SNS.Subscriptions;
-using Amazon.CDK.AWS.SQS;
-using Constructs;
-
-namespace InfraWorkerIntegration
-{
- public class InfraStackDemo : Stack
- {
- internal InfraStackDemo(Construct scope, string id, IStackProps props = null) : base(scope, id, props)
- {
- const string XRAY_DAEMON = "xray-daemon";
- const string CW_AGET = "cwagent";
-
- //Note: For demo' cleanup propose, this Sample Code will set RemovalPolicy == DESTROY
- //this will clean all resources when you cdk destroy
- var cleanUpRemovePolicy = RemovalPolicy.DESTROY;
-
- //Import Resources
- var importedSnsArn = Fn.ImportValue("DemoSnsTopicArn");
- var importedClusterName = Fn.ImportValue("DemoClusterName");
- var importedLogGroupName = Fn.ImportValue("DemoLogGroupName");
- var importedVpcId = System.Environment.GetEnvironmentVariable("DEMO_VPC_ID");
-
- //Import VPC using the value from env variable DEMO_VPC_ID
- var vpc = Vpc.FromLookup(this, "imported-vpc", new VpcLookupOptions
- {
- VpcId = importedVpcId
- });
-
- //Import ECS Cluster using VPC and the imported ClusterName
- var cluster = Cluster.FromClusterAttributes(this, "imported-cluester", new ClusterAttributes
- {
- Vpc = vpc,
- ClusterName = importedClusterName,
- SecurityGroups = System.Array.Empty()
- });
-
- //Import SNS Topic created from other Stack
- var topic = Topic.FromTopicArn(this, "imported-topic", importedSnsArn);
-
- //SQS for Worker APP that persist data on s3
- var workerIntegrationQueue = new Queue(this, "worker-integration-queue", new QueueProps
- {
- QueueName = "worker-integration-queue",
- RemovalPolicy = cleanUpRemovePolicy,
- Encryption = QueueEncryption.KMS
- });
-
- //Grant Permission & Subscribe
- topic.AddSubscription(new SqsSubscription(workerIntegrationQueue));
-
- //S3 Bucket
- var bucket = new Bucket(this, "demo-bucket", new BucketProps
- {
- Encryption = BucketEncryption.KMS,
- EnforceSSL = true,
- BlockPublicAccess = BlockPublicAccess.BLOCK_ALL,
- RemovalPolicy = cleanUpRemovePolicy,
- AutoDeleteObjects = true //Set to false for Real Env, this is only set for demo cleanup propose
- });
-
- //Build docker container and publish to ECR
- var asset = new DockerImageAsset(this, "worker-integration-image", new DockerImageAssetProps
- {
- Directory = Path.Combine(Directory.GetCurrentDirectory(), "../../src/apps/WorkerIntegration"),
- File = "Dockerfile",
- Platform = Platform_.LINUX_ARM64,
- });
-
- //Create logDrive to reuse the same AWS CloudWatch Log group created from the other Stack
- var logDriver = LogDriver.AwsLogs(new AwsLogDriverProps
- {
- LogGroup = LogGroup.FromLogGroupName(this, "imported-loggroup", importedLogGroupName),
- StreamPrefix = "ecs/worker-integration"
- });
-
- //Autoscaling
- // See: https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-scaling-simple-step.html
- var autoscalingSteps = new Amazon.CDK.AWS.ApplicationAutoScaling.ScalingInterval[]{
- //Step adjustments for scale-out policy
- new Amazon.CDK.AWS.ApplicationAutoScaling.ScalingInterval{
- Lower = 0,
- Upper = 10,
- Change = 0
- },
- new Amazon.CDK.AWS.ApplicationAutoScaling.ScalingInterval{
- Lower = 20,
- Upper = null,
- Change = 3
- },
- //Step adjustments for scale-in policy
- new Amazon.CDK.AWS.ApplicationAutoScaling.ScalingInterval{
- Lower = null,
- Upper = -20,
- Change = -3
- }
- };
-
- //Level 3 Construct for SQS Queue processing
- var queueFargateSvc = new QueueProcessingFargateService(this, "queue-fargate-services", new QueueProcessingFargateServiceProps
- {
- Queue = workerIntegrationQueue,
- MinScalingCapacity = 1,
- MaxScalingCapacity = 100,
- ScalingSteps = autoscalingSteps,
- Cpu = 256,
- MemoryLimitMiB = 512,
- Cluster = cluster,
- Image = ContainerImage.FromDockerImageAsset(asset),
- Environment = new Dictionary()
- {
- {"WORKER_QUEUE_URL", workerIntegrationQueue.QueueUrl },
- {"WORKER_BUCKET_NAME", bucket.BucketName},
- {"AWS_XRAY_DAEMON_ADDRESS",$"{XRAY_DAEMON}:2000" }
- },
- LogDriver = logDriver
- });
-
-
-
- //Grant permission to S3 Bucket and SQS to consume message from the Queue
- bucket.GrantWrite(queueFargateSvc.TaskDefinition.TaskRole);
- workerIntegrationQueue.GrantConsumeMessages(queueFargateSvc.TaskDefinition.TaskRole);
-
- //Custom shared C# Library (reusability of code)
- queueFargateSvc.Service.TaskDefinition
- .AddXRayDaemon(new XRayDaemonProps
- {
- XRayDaemonContainerName = XRAY_DAEMON,
- LogDriver = logDriver
- }).AddCloudWatchAgent(new CloudWatchAgentProps
- {
- AgentContainerName = CW_AGET,
- LogDriver = logDriver,
- });
-
- //Grant permission to write X-Ray segments
- queueFargateSvc.Service.TaskDefinition.TaskRole
- .AddManagedPolicy(ManagedPolicy.FromAwsManagedPolicyName("AWSXRayDaemonWriteAccess"));
-
- }
- }
-}
diff --git a/ServicesWorkerIntegration/src/infra/src/Infra/InfraWorkerIntegration.csproj b/ServicesWorkerIntegration/src/infra/src/Infra/InfraWorkerIntegration.csproj
deleted file mode 100644
index 7bf10d2..0000000
--- a/ServicesWorkerIntegration/src/infra/src/Infra/InfraWorkerIntegration.csproj
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
- Exe
- net6.0
-
- Major
- true
- true
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/ServicesWorkerIntegration/src/infra/src/Infra/Program.cs b/ServicesWorkerIntegration/src/infra/src/Infra/Program.cs
deleted file mode 100644
index 3b5cf79..0000000
--- a/ServicesWorkerIntegration/src/infra/src/Infra/Program.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
-// SPDX-License-Identifier: MIT-0
-using Amazon.CDK;
-
-namespace InfraWorkerIntegration
-{
- sealed class Program
- {
- public static void Main(string[] args)
- {
- var app = new App();
- _ = new InfraStackDemo(app, "WorkerIntegrationInfraStack", new StackProps
- {
- // If you don't specify 'env', this stack will be environment-agnostic.
- // Account/Region-dependent features and context lookups will not work,
- // but a single synthesized template can be deployed anywhere.
-
- // Uncomment the next block to specialize this stack for the AWS Account
- // and Region that are implied by the current CLI configuration.
- /*
- Env = new Amazon.CDK.Environment
- {
- Account = System.Environment.GetEnvironmentVariable("CDK_DEFAULT_ACCOUNT"),
- Region = System.Environment.GetEnvironmentVariable("CDK_DEFAULT_REGION"),
- }
- */
-
- // Uncomment the next block if you know exactly what Account and Region you
- // want to deploy the stack to.
- /**/
- Env = new Amazon.CDK.Environment
- {
- Account = System.Environment.GetEnvironmentVariable("CDK_DEPLOY_ACCOUNT") ??
- System.Environment.GetEnvironmentVariable("CDK_DEFAULT_ACCOUNT"),
- Region = System.Environment.GetEnvironmentVariable("CDK_DEPLOY_REGION") ??
- System.Environment.GetEnvironmentVariable("CDK_DEFAULT_REGION")
- }
-
-
- // For more information, see https://docs.aws.amazon.com/cdk/latest/guide/environments.html
- });
-
- app.Synth();
- }
- }
-}
diff --git a/WebAPI/README.md b/WebAPI/README.md
deleted file mode 100644
index 8120b6b..0000000
--- a/WebAPI/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# TODO: Add doc
-
-Add guide
diff --git a/WebAPI/src/apps/SampleWebApp/.vscode/launch.json b/WebAPI/src/apps/SampleWebApp/.vscode/launch.json
deleted file mode 100644
index 8e996f9..0000000
--- a/WebAPI/src/apps/SampleWebApp/.vscode/launch.json
+++ /dev/null
@@ -1,36 +0,0 @@
-{
- "version": "0.2.0",
- "configurations": [
- {
- // Use IntelliSense to find out which attributes exist for C# debugging
- // Use hover for the description of the existing attributes
- // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
- "name": ".NET Core Launch (web)",
- "type": "coreclr",
- "request": "launch",
- "preLaunchTask": "build",
- // If you have changed target frameworks, make sure to update the program path.
- "program": "${workspaceFolder}/bin/Debug/net6.0/SampleWebApp.dll",
- "args": [],
- "cwd": "${workspaceFolder}",
- "stopAtEntry": false,
- // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
- "serverReadyAction": {
- "action": "openExternally",
- "pattern": "\\bNow listening on:\\s+(https?://\\S+)"
- },
- "env": {
- "ASPNETCORE_ENVIRONMENT": "Development",
- "SNS_TOPIC_ARN":"ADD_YOUR_SNS_TOPIC_ARN_HERE_FOR_DEBUG"
- },
- "sourceFileMap": {
- "/Views": "${workspaceFolder}/Views"
- }
- },
- {
- "name": ".NET Core Attach",
- "type": "coreclr",
- "request": "attach"
- }
- ]
-}
\ No newline at end of file
diff --git a/WebAPI/src/apps/SampleWebApp/.vscode/tasks.json b/WebAPI/src/apps/SampleWebApp/.vscode/tasks.json
deleted file mode 100644
index bb0343d..0000000
--- a/WebAPI/src/apps/SampleWebApp/.vscode/tasks.json
+++ /dev/null
@@ -1,42 +0,0 @@
-{
- "version": "2.0.0",
- "tasks": [
- {
- "label": "build",
- "command": "dotnet",
- "type": "process",
- "args": [
- "build",
- "${workspaceFolder}/SampleWebApp.csproj",
- "/property:GenerateFullPaths=true",
- "/consoleloggerparameters:NoSummary"
- ],
- "problemMatcher": "$msCompile"
- },
- {
- "label": "publish",
- "command": "dotnet",
- "type": "process",
- "args": [
- "publish",
- "${workspaceFolder}/SampleWebApp.csproj",
- "/property:GenerateFullPaths=true",
- "/consoleloggerparameters:NoSummary"
- ],
- "problemMatcher": "$msCompile"
- },
- {
- "label": "watch",
- "command": "dotnet",
- "type": "process",
- "args": [
- "watch",
- "run",
- "${workspaceFolder}/SampleWebApp.csproj",
- "/property:GenerateFullPaths=true",
- "/consoleloggerparameters:NoSummary"
- ],
- "problemMatcher": "$msCompile"
- }
- ]
-}
\ No newline at end of file
diff --git a/WebAPI/src/apps/SampleWebApp/Dockerfile.original b/WebAPI/src/apps/SampleWebApp/Dockerfile.original
deleted file mode 100644
index fe1c1f7..0000000
--- a/WebAPI/src/apps/SampleWebApp/Dockerfile.original
+++ /dev/null
@@ -1,20 +0,0 @@
-#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
-
-FROM mcr.microsoft.com/dotnet/aspnet:6.0.16-bullseye-slim-amd64 AS base
-WORKDIR /app
-EXPOSE 80
-EXPOSE 443
-
-FROM mcr.microsoft.com/dotnet/sdk:6.0.408-bullseye-slim-amd64 AS build
-WORKDIR "/src/SampleWebApp"
-COPY . .
-RUN dotnet restore "SampleWebApp.csproj"
-RUN dotnet build "SampleWebApp.csproj" -c Release -o /app/build
-
-FROM build AS publish
-RUN dotnet publish "SampleWebApp.csproj" -c Release -o /app/publish
-
-FROM base AS final
-WORKDIR /app
-COPY --from=publish /app/publish .
-ENTRYPOINT ["dotnet", "SampleWebApp.dll"]
\ No newline at end of file
diff --git a/WebAPI/src/apps/SampleWebApp/GlobalSuppressions.cs b/WebAPI/src/apps/SampleWebApp/GlobalSuppressions.cs
deleted file mode 100644
index 2fbf037..0000000
--- a/WebAPI/src/apps/SampleWebApp/GlobalSuppressions.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
-// SPDX-License-Identifier: MIT-0
-[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Potential Code Quality Issues", "RECS0026:Possible unassigned object created by 'new'", Justification = "Constructs add themselves to the scope in which they are created")]
-[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Potential Code Analyzer Warning", "CA1014:Mark assemblies with CLSCompliant", Justification = "")]
-[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Potential Code Analyzer Warning", "CA1506:.ctor' is ccoupled", Justification = "")]
-[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Potential Code Analyzer Warning", "CA1848:Use the LoggerMessage delegates", Justification = "")]
diff --git a/WebAPI/src/infra/.gitignore b/WebAPI/src/infra/.gitignore
deleted file mode 100644
index f555633..0000000
--- a/WebAPI/src/infra/.gitignore
+++ /dev/null
@@ -1,342 +0,0 @@
-# CDK asset staging directory
-.cdk.staging
-cdk.out
-
-# Created by https://www.gitignore.io/api/csharp
-
-### Csharp ###
-## Ignore Visual Studio temporary files, build results, and
-## files generated by popular Visual Studio add-ons.
-##
-## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
-
-# User-specific files
-*.suo
-*.user
-*.userosscache
-*.sln.docstates
-
-# User-specific files (MonoDevelop/Xamarin Studio)
-*.userprefs
-
-# Build results
-[Dd]ebug/
-[Dd]ebugPublic/
-[Rr]elease/
-[Rr]eleases/
-x64/
-x86/
-bld/
-[Bb]in/
-[Oo]bj/
-[Ll]og/
-
-# Visual Studio 2015/2017 cache/options directory
-.vs/
-# Uncomment if you have tasks that create the project's static files in wwwroot
-#wwwroot/
-
-# Visual Studio 2017 auto generated files
-Generated\ Files/
-
-# MSTest test Results
-[Tt]est[Rr]esult*/
-[Bb]uild[Ll]og.*
-
-# NUNIT
-*.VisualState.xml
-TestResult.xml
-
-# Build Results of an ATL Project
-[Dd]ebugPS/
-[Rr]eleasePS/
-dlldata.c
-
-# Benchmark Results
-BenchmarkDotNet.Artifacts/
-
-# .NET Core
-project.lock.json
-project.fragment.lock.json
-artifacts/
-
-# StyleCop
-StyleCopReport.xml
-
-# Files built by Visual Studio
-*_i.c
-*_p.c
-*_i.h
-*.ilk
-*.meta
-*.obj
-*.iobj
-*.pch
-*.pdb
-*.ipdb
-*.pgc
-*.pgd
-*.rsp
-*.sbr
-*.tlb
-*.tli
-*.tlh
-*.tmp
-*.tmp_proj
-*.log
-*.vspscc
-*.vssscc
-.builds
-*.pidb
-*.svclog
-*.scc
-
-# Chutzpah Test files
-_Chutzpah*
-
-# Visual C++ cache files
-ipch/
-*.aps
-*.ncb
-*.opendb
-*.opensdf
-*.sdf
-*.cachefile
-*.VC.db
-*.VC.VC.opendb
-
-# Visual Studio profiler
-*.psess
-*.vsp
-*.vspx
-*.sap
-
-# Visual Studio Trace Files
-*.e2e
-
-# TFS 2012 Local Workspace
-$tf/
-
-# Guidance Automation Toolkit
-*.gpState
-
-# ReSharper is a .NET coding add-in
-_ReSharper*/
-*.[Rr]e[Ss]harper
-*.DotSettings.user
-
-# JustCode is a .NET coding add-in
-.JustCode
-
-# TeamCity is a build add-in
-_TeamCity*
-
-# DotCover is a Code Coverage Tool
-*.dotCover
-
-# AxoCover is a Code Coverage Tool
-.axoCover/*
-!.axoCover/settings.json
-
-# Visual Studio code coverage results
-*.coverage
-*.coveragexml
-
-# NCrunch
-_NCrunch_*
-.*crunch*.local.xml
-nCrunchTemp_*
-
-# MightyMoose
-*.mm.*
-AutoTest.Net/
-
-# Web workbench (sass)
-.sass-cache/
-
-# Installshield output folder
-[Ee]xpress/
-
-# DocProject is a documentation generator add-in
-DocProject/buildhelp/
-DocProject/Help/*.HxT
-DocProject/Help/*.HxC
-DocProject/Help/*.hhc
-DocProject/Help/*.hhk
-DocProject/Help/*.hhp
-DocProject/Help/Html2
-DocProject/Help/html
-
-# Click-Once directory
-publish/
-
-# Publish Web Output
-*.[Pp]ublish.xml
-*.azurePubxml
-# Note: Comment the next line if you want to checkin your web deploy settings,
-# but database connection strings (with potential passwords) will be unencrypted
-*.pubxml
-*.publishproj
-
-# Microsoft Azure Web App publish settings. Comment the next line if you want to
-# checkin your Azure Web App publish settings, but sensitive information contained
-# in these scripts will be unencrypted
-PublishScripts/
-
-# NuGet Packages
-*.nupkg
-# The packages folder can be ignored because of Package Restore
-**/[Pp]ackages/*
-# except build/, which is used as an MSBuild target.
-!**/[Pp]ackages/build/
-# Uncomment if necessary however generally it will be regenerated when needed
-#!**/[Pp]ackages/repositories.config
-# NuGet v3's project.json files produces more ignorable files
-*.nuget.props
-*.nuget.targets
-
-# Microsoft Azure Build Output
-csx/
-*.build.csdef
-
-# Microsoft Azure Emulator
-ecf/
-rcf/
-
-# Windows Store app package directories and files
-AppPackages/
-BundleArtifacts/
-Package.StoreAssociation.xml
-_pkginfo.txt
-*.appx
-
-# Visual Studio cache files
-# files ending in .cache can be ignored
-*.[Cc]ache
-# but keep track of directories ending in .cache
-!*.[Cc]ache/
-
-# Others
-ClientBin/
-~$*
-*~
-*.dbmdl
-*.dbproj.schemaview
-*.jfm
-*.pfx
-*.publishsettings
-orleans.codegen.cs
-
-# Including strong name files can present a security risk
-# (https://github.com/github/gitignore/pull/2483#issue-259490424)
-#*.snk
-
-# Since there are multiple workflows, uncomment next line to ignore bower_components
-# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
-#bower_components/
-
-# RIA/Silverlight projects
-Generated_Code/
-
-# Backup & report files from converting an old project file
-# to a newer Visual Studio version. Backup files are not needed,
-# because we have git ;-)
-_UpgradeReport_Files/
-Backup*/
-UpgradeLog*.XML
-UpgradeLog*.htm
-ServiceFabricBackup/
-*.rptproj.bak
-
-# SQL Server files
-*.mdf
-*.ldf
-*.ndf
-
-# Business Intelligence projects
-*.rdl.data
-*.bim.layout
-*.bim_*.settings
-*.rptproj.rsuser
-
-# Microsoft Fakes
-FakesAssemblies/
-
-# GhostDoc plugin setting file
-*.GhostDoc.xml
-
-# Node.js Tools for Visual Studio
-.ntvs_analysis.dat
-node_modules/
-
-# Visual Studio 6 build log
-*.plg
-
-# Visual Studio 6 workspace options file
-*.opt
-
-# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
-*.vbw
-
-# Visual Studio LightSwitch build output
-**/*.HTMLClient/GeneratedArtifacts
-**/*.DesktopClient/GeneratedArtifacts
-**/*.DesktopClient/ModelManifest.xml
-**/*.Server/GeneratedArtifacts
-**/*.Server/ModelManifest.xml
-_Pvt_Extensions
-
-# Paket dependency manager
-.paket/paket.exe
-paket-files/
-
-# FAKE - F# Make
-.fake/
-
-# JetBrains Rider
-.idea/
-*.sln.iml
-
-# CodeRush
-.cr/
-
-# Python Tools for Visual Studio (PTVS)
-__pycache__/
-*.pyc
-
-# Cake - Uncomment if you are using it
-# tools/**
-# !tools/packages.config
-
-# Tabs Studio
-*.tss
-
-# Telerik's JustMock configuration file
-*.jmconfig
-
-# BizTalk build output
-*.btp.cs
-*.btm.cs
-*.odx.cs
-*.xsd.cs
-
-# OpenCover UI analysis results
-OpenCover/
-
-# Azure Stream Analytics local run output
-ASALocalRun/
-
-# MSBuild Binary and Structured Log
-*.binlog
-
-# NVidia Nsight GPU debugger configuration file
-*.nvuser
-
-# MFractors (Xamarin productivity tool) working folder
-.mfractor/
-
-# Local History for Visual Studio
-.localhistory/
-
-
-# End of https://www.gitignore.io/api/csharp
\ No newline at end of file
diff --git a/WebAPI/src/infra/.vscode/launch.json b/WebAPI/src/infra/.vscode/launch.json
deleted file mode 100644
index ef7f9fd..0000000
--- a/WebAPI/src/infra/.vscode/launch.json
+++ /dev/null
@@ -1,26 +0,0 @@
-{
- "version": "0.2.0",
- "configurations": [
- {
- // Use IntelliSense to find out which attributes exist for C# debugging
- // Use hover for the description of the existing attributes
- // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
- "name": ".NET Core Launch (console)",
- "type": "coreclr",
- "request": "launch",
- "preLaunchTask": "build",
- // If you have changed target frameworks, make sure to update the program path.
- "program": "${workspaceFolder}/src/Infra/bin/Debug/netcoreapp3.1/Infra.dll",
- "args": [],
- "cwd": "${workspaceFolder}/src/Infra",
- // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
- "console": "internalConsole",
- "stopAtEntry": false
- },
- {
- "name": ".NET Core Attach",
- "type": "coreclr",
- "request": "attach"
- }
- ]
-}
\ No newline at end of file
diff --git a/WebAPI/src/infra/.vscode/tasks.json b/WebAPI/src/infra/.vscode/tasks.json
deleted file mode 100644
index dba8281..0000000
--- a/WebAPI/src/infra/.vscode/tasks.json
+++ /dev/null
@@ -1,42 +0,0 @@
-{
- "version": "2.0.0",
- "tasks": [
- {
- "label": "build",
- "command": "dotnet",
- "type": "process",
- "args": [
- "build",
- "${workspaceFolder}/src/Infra/Infra.csproj",
- "/property:GenerateFullPaths=true",
- "/consoleloggerparameters:NoSummary"
- ],
- "problemMatcher": "$msCompile"
- },
- {
- "label": "publish",
- "command": "dotnet",
- "type": "process",
- "args": [
- "publish",
- "${workspaceFolder}/src/Infra/Infra.csproj",
- "/property:GenerateFullPaths=true",
- "/consoleloggerparameters:NoSummary"
- ],
- "problemMatcher": "$msCompile"
- },
- {
- "label": "watch",
- "command": "dotnet",
- "type": "process",
- "args": [
- "watch",
- "run",
- "${workspaceFolder}/src/Infra/Infra.csproj",
- "/property:GenerateFullPaths=true",
- "/consoleloggerparameters:NoSummary"
- ],
- "problemMatcher": "$msCompile"
- }
- ]
-}
\ No newline at end of file
diff --git a/WebAPI/src/infra/src/Infra/GlobalSuppressions.cs b/WebAPI/src/infra/src/Infra/GlobalSuppressions.cs
deleted file mode 100644
index 2fbf037..0000000
--- a/WebAPI/src/infra/src/Infra/GlobalSuppressions.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
-// SPDX-License-Identifier: MIT-0
-[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Potential Code Quality Issues", "RECS0026:Possible unassigned object created by 'new'", Justification = "Constructs add themselves to the scope in which they are created")]
-[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Potential Code Analyzer Warning", "CA1014:Mark assemblies with CLSCompliant", Justification = "")]
-[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Potential Code Analyzer Warning", "CA1506:.ctor' is ccoupled", Justification = "")]
-[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Potential Code Analyzer Warning", "CA1848:Use the LoggerMessage delegates", Justification = "")]
diff --git a/WebAPI/src/infra/src/Infra/InfraStackDemo.cs b/WebAPI/src/infra/src/Infra/InfraStackDemo.cs
deleted file mode 100644
index bf022d8..0000000
--- a/WebAPI/src/infra/src/Infra/InfraStackDemo.cs
+++ /dev/null
@@ -1,131 +0,0 @@
-// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
-// SPDX-License-Identifier: MIT-0
-using System.Collections.Generic;
-using System.IO;
-using Amazon.CDK;
-using Amazon.CDK.AWS.EC2;
-using Amazon.CDK.AWS.Ecr.Assets;
-using Amazon.CDK.AWS.ECS;
-using Amazon.CDK.AWS.ECS.MyExtensions;
-using Amazon.CDK.AWS.ECS.Patterns;
-using Amazon.CDK.AWS.Logs;
-using Amazon.CDK.AWS.SNS;
-using Constructs;
-using Amazon.CDK.AWS.ApplicationAutoScaling;
-
-namespace InfraSampleWebApp
-{
- public class InfraStackDemo : Stack
- {
- internal InfraStackDemo(Construct scope, string id, IStackProps props = null) : base(scope, id, props)
- {
- const string XRAY_DAEMON = "xray-daemon";
- const string CW_AGET = "cwagent";
-
- //Note: For demo' cleanup propose, this Sample Code will set RemovalPolicy == DESTROY
- //this will clean all resources when you cdk destroy
- var cleanUpRemovePolicy = RemovalPolicy.DESTROY;
- // VPC
- var vpc = new Vpc(this, "demo-vpc", new VpcProps
- {
- IpAddresses = IpAddresses.Cidr("172.30.0.0/16"),
- MaxAzs = 3
- });
-
- var cluster = new Cluster(this, "demo-cluster", new ClusterProps
- {
- Vpc = vpc,
- ContainerInsights = true
- });
-
- //ECR
- //Build docker image and publish on ECR Repository
- var asset = new DockerImageAsset(this, "web-app-image", new DockerImageAssetProps
- {
- Directory = Path.Combine(Directory.GetCurrentDirectory(), "../../src/apps/SampleWebApp"),
- File = "Dockerfile",
- Platform = Platform_.LINUX_ARM64,
- });
-
- //SNS Topic
- Topic topic = new Topic(this, "Topic", new TopicProps
- {
- DisplayName = "Customer subscription topic",
- TopicName = "demo-web-app-topic"
- });
-
- //CloudWatch LogGroup and ECS LogDriver
- var logGroupName = "/ecs/demo/ecs-fargate-dotnet-microservices";
- var logDriver = LogDriver.AwsLogs(new AwsLogDriverProps
- {
- LogGroup = new LogGroup(this, "demo-log-group", new LogGroupProps
- {
- LogGroupName = logGroupName,
- Retention = RetentionDays.ONE_DAY,
- RemovalPolicy = cleanUpRemovePolicy
- }),
- StreamPrefix = "ecs/web-api"
- });
-
- var albFargateSvc = new ApplicationLoadBalancedFargateService(this, "demo-service", new ApplicationLoadBalancedFargateServiceProps
- {
- Cluster = cluster,
- MemoryLimitMiB = 1024,
- Cpu = 512,
- DesiredCount = 3,
- TaskImageOptions = new ApplicationLoadBalancedTaskImageOptions
- {
- // ContainerImage.FromRegistry("amazon/amazon-ecs-sample"), //
- Image = ContainerImage.FromDockerImageAsset(asset),
- ContainerName = "web",
- EnableLogging = true,
- Environment = new Dictionary()
- {
- {"SNS_TOPIC_ARN", topic.TopicArn },
- {"AWS_EMF_LOG_GROUP_NAME", logGroupName },
- {"ASPNETCORE_URLS","http://+:80"},
- },
- LogDriver = logDriver,
- },
- });
-
- //Autoscaling
- var scalableTarget = albFargateSvc.Service.AutoScaleTaskCount(new EnableScalingProps
- {
- MinCapacity = 1,
- MaxCapacity = 10,
- });
-
- scalableTarget.ScaleOnCpuUtilization("CpuScaling", new Amazon.CDK.AWS.ECS.CpuUtilizationScalingProps
- {
- TargetUtilizationPercent = 60
- });
-
-
- //Grant permission to Publish on the SNS Topic
- topic.GrantPublish(albFargateSvc.Service.TaskDefinition.TaskRole);
-
-
- //Custom shared C# Library (reusability of code)
- albFargateSvc.Service.TaskDefinition
- .AddXRayDaemon(new XRayDaemonProps
- {
- XRayDaemonContainerName = XRAY_DAEMON,
- LogDriver = logDriver
- }).AddCloudWatchAgent(new CloudWatchAgentProps
- {
- AgentContainerName = CW_AGET,
- LogDriver = logDriver,
- });
-
- //Level 1 Cfn Output
- _ = new CfnOutput(this, "DemoSnsTopicArn", new CfnOutputProps { Value = topic.TopicArn, ExportName = "DemoSnsTopicArn" });
- _ = new CfnOutput(this, "DemoClusterName", new CfnOutputProps { Value = cluster.ClusterName, ExportName = "DemoClusterName" });
- _ = new CfnOutput(this, "DemoLogGroupName", new CfnOutputProps { Value = logGroupName, ExportName = "DemoLogGroupName" });
- _ = new CfnOutput(this, "DemoVpcId", new CfnOutputProps { Value = vpc.VpcId, ExportName = "DemoVpcId" });
- _ = new CfnOutput(this, "DemoDeployRegion", new CfnOutputProps { Value = this.Region, ExportName = "DemoDeployRegion" });
- _ = new CfnOutput(this, "DemoServiceServiceURLEndpoint", new CfnOutputProps { Value = $"http://{albFargateSvc.LoadBalancer.LoadBalancerDnsName}/api/Books", ExportName = "DemoServiceServiceURLEndpoint" });
-
- }
- }
-}
diff --git a/WebAPI/src/infra/src/Infra/Program.cs b/WebAPI/src/infra/src/Infra/Program.cs
deleted file mode 100644
index 498fc54..0000000
--- a/WebAPI/src/infra/src/Infra/Program.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
-// SPDX-License-Identifier: MIT-0
-using Amazon.CDK;
-
-namespace InfraSampleWebApp
-{
- sealed class Program
- {
- public static void Main(string[] args)
- {
- var app = new App();
- _ = new InfraStackDemo(app, "WebAppInfraStack", new StackProps
- {
- // If you don't specify 'env', this stack will be environment-agnostic.
- // Account/Region-dependent features and context lookups will not work,
- // but a single synthesized template can be deployed anywhere.
-
- // Uncomment the next block to specialize this stack for the AWS Account
- // and Region that are implied by the current CLI configuration.
- /*
- Env = new Amazon.CDK.Environment
- {
- Account = System.Environment.GetEnvironmentVariable("CDK_DEFAULT_ACCOUNT"),
- Region = System.Environment.GetEnvironmentVariable("CDK_DEFAULT_REGION"),
- }
- */
-
- // Uncomment the next block if you know exactly what Account and Region you
- // want to deploy the stack to.
- /*
- Env = new Amazon.CDK.Environment
- {
- Account = "123456789012",
- Region = "us-east-1",
- }
- */
-
- // For more information, see https://docs.aws.amazon.com/cdk/latest/guide/environments.html
- });
-
- // new InfraMultiTaskStack(app, nameof(InfraMultiTaskStack), new StackProps{
-
- // });
-
- app.Synth();
- }
- }
-}
diff --git a/clean.ps1 b/clean.ps1
index af4d68b..99cb683 100644
--- a/clean.ps1
+++ b/clean.ps1
@@ -1,26 +1,8 @@
-#########################################################
-# Clean resources created for the first Worker Services #
-#########################################################
-# 1. Navigate to the CDK project folder for the Worker Service that persists into DynamoDB
-# 2. Destroy all resources without ask for confirmation before destroying the stacks
-Set-Location ServicesWorkerDb/src/infra/
- cdk destroy -f
- Set-Location ../../../
-
##########################################################
-# Clean resources created for the second Worker Services #
+# Clean resources created for all the CDK Stacks #
##########################################################
-# 1. Navigate to the CDK project folder for the Worker Service that persists into S3
-# 2. Destroy all resources without ask for confirmation before destroying the stacks
-Set-Location ServicesWorkerIntegration/src/infra/
- cdk destroy -f
- Set-Location ../../../
-
-############################################################
-# Clean resources created for the WebAPI #
-############################################################
-# 1. Navigate to the CDK project folder for the WebAPI project
+# 1. Navigate to the CDK project folder
# 2. Destroy all resources without ask for confirmation before destroying the stacks
-Set-Location WebAPI/src/infra/
- cdk destroy -f
- Set-Location ../../../
\ No newline at end of file
+Set-Location src/infra
+ cdk destroy -f --all
+ Set-Location ../../
\ No newline at end of file
diff --git a/clean.sh b/clean.sh
index 4b65973..fa6da0f 100755
--- a/clean.sh
+++ b/clean.sh
@@ -1,26 +1,8 @@
-#########################################################
-# Clean resources created for the first Worker Services #
-#########################################################
-# 1. Navigate to the CDK project folder for the Worker Service that persists into DynamoDB
-# 2. Destroy all resources without ask for confirmation before destroying the stacks
-cd ServicesWorkerDb/src/infra/ \
-&& cdk destroy -f \
-&& cd -
-
##########################################################
-# Clean resources created for the second Worker Services #
+# Clean resources created for all the CDK Stacks #
##########################################################
-# 1. Navigate to the CDK project folder for the Worker Service that persists into S3
-# 2. Destroy all resources without ask for confirmation before destroying the stacks
-cd ServicesWorkerIntegration/src/infra/ \
-&& cdk destroy -f \
-&& cd -
-
-############################################################
-# Clean resources created for the WebAPI #
-############################################################
-# 1. Navigate to the CDK project folder for the WebAPI project
+# 1. Navigate to the CDK project folder
# 2. Destroy all resources without ask for confirmation before destroying the stacks
-cd WebAPI/src/infra/ \
-&& cdk destroy -f \
+cd src/infra \
+&& cdk destroy -f --all \
&& cd -
\ No newline at end of file
diff --git a/deploy.ps1 b/deploy.ps1
index 84199b9..4815e92 100644
--- a/deploy.ps1
+++ b/deploy.ps1
@@ -3,47 +3,14 @@ aws sts get-caller-identity
#############################################################
# Deploy WebAPI microservice: #
#############################################################
-# 1. Navigate to the CDK project folder for the WebAPI;
+# 1. Navigate to the CDK project folder;
# 2. Bootstrap your environment, account, and region to run the CDK project;
# 3. Synthesize the project to validate the implementation and produce the CloudFormation template to be deployed;
# 4. Deploy the CloudFormation Stack after your confirmation;
-# 5. Query the VPC ID created from the first Stack and export it to a local environment variable DEMO_VPC_ID
-# 6. Query the DemoDeployRegion created from the first Stack and export it to a local environment variable CDK_DEPLOY_REGION
-# 7. Navigate back to the root folder
-Set-Location WebAPI/src/infra/
+Set-Location src/infra \
cdk bootstrap
-cdk synth
-cdk deploy --require-approval never
-$Env:DEMO_VPC_ID = $(aws cloudformation describe-stacks --stack-name WebAppInfraStack --output text --query 'Stacks[0].Outputs[?OutputKey==`DemoVpcId`].OutputValue | [0]')
-$Env:CDK_DEPLOY_REGION = $(aws cloudformation describe-stacks --stack-name WebAppInfraStack --output text --query 'Stacks[0].Outputs[?OutputKey==`DemoDeployRegion`].OutputValue | [0]')
-Set-Location ../../../
-
-
-#############################################################
-# Deploy the first Worker Services microservices #
-#############################################################
-# 1. Navigate to the CDK project folder for the Worker Service that persists into DynamoDB
-# 2. Then synthesize
-# 3. and deploy the Stack.
-# 4. Navigate back to the root folder
-Set-Location ServicesWorkerDb/src/infra/
-cdk synth
-cdk deploy --require-approval never
-Set-Location ../../../
-
-
-#############################################################
-# Deploy the second Worker Services microservices #
-#############################################################
-# 1. Navigate to the CDK project folder for the Worker Service that persists into S3 Bucket
-# 2. Then synthesize
-# 3. and deploy the Stack.
-# 4. Navigate back to the root folder
-Set-Location ServicesWorkerIntegration/src/infra/
-cdk synth
-cdk deploy --require-approval never
-Set-Location ../../../
-
+cdk synth --all
+cdk deploy --require-approval never --all
#############################################################
# Echo the WebAPI URL #
@@ -53,5 +20,5 @@ Write-Output "#############################################################"
Write-Output "# the WebAPI URL #"
Write-Output "#############################################################"
Write-Output "`r`n"
-aws cloudformation describe-stacks --stack-name WebAppInfraStack --output text --query 'Stacks[0].Outputs[?contains(OutputKey,`DemoServiceServiceURLEndpoint`)].OutputValue | [0]'
+aws cloudformation describe-stacks --stack-name WebAppStack --output text --query 'Stacks[0].Outputs[?contains(OutputKey,`DemoServiceServiceURLEndpoint`)].OutputValue | [0]'
Write-Output "`r`n"
diff --git a/deploy.sh b/deploy.sh
index 7aaeb28..4a40ee6 100755
--- a/deploy.sh
+++ b/deploy.sh
@@ -1,47 +1,16 @@
-#############################################################
-# Deploy WebAPI microservice: #
-#############################################################
-# 1. Navigate to the CDK project folder for the WebAPI;
+echo "This deployment will use the following User Id and Account: "
+aws sts get-caller-identity
+##############################################################
+# Deploy All the CDK Stacks #
+##############################################################
+# 1. Navigate to the CDK project folder;
# 2. Bootstrap your environment, account, and region to run the CDK project;
# 3. Synthesize the project to validate the implementation and produce the CloudFormation template to be deployed;
# 4. Deploy the CloudFormation Stack after your confirmation;
-# 5. Query the VPC ID created from the first Stack and export it to a local environment variable DEMO_VPC_ID
-# 6. Query the DemoDeployRegion created from the first Stack and export it to a local environment variable CDK_DEPLOY_REGION
-# 7. Navigate back to the root folder
-cd WebAPI/src/infra/ \
+cd src/infra \
&& cdk bootstrap \
-&& cdk synth \
-&& cdk deploy --require-approval never\
-&& export DEMO_VPC_ID=$(aws cloudformation describe-stacks --stack-name WebAppInfraStack --output text --query 'Stacks[0].Outputs[?OutputKey==`DemoVpcId`].OutputValue | [0]') \
-&& export CDK_DEPLOY_REGION=$(aws cloudformation describe-stacks --stack-name WebAppInfraStack --output text --query 'Stacks[0].Outputs[?OutputKey==`DemoDeployRegion`].OutputValue | [0]') \
-&& cd -
-
-
-#############################################################
-# Deploy the first Worker Services microservices #
-#############################################################
-# 1. Navigate to the CDK project folder for the Worker Service that persists into DynamoDB
-# 2. Then synthesize
-# 3. and deploy the Stack.
-# 4. Navigate back to the root folder
-cd ServicesWorkerDb/src/infra/ \
-&& cdk synth \
-&& cdk deploy --require-approval never\
-&& cd -
-
-
-#############################################################
-# Deploy the second Worker Services microservices #
-#############################################################
-# 1. Navigate to the CDK project folder for the Worker Service that persists into S3 Bucket
-# 2. Then synthesize
-# 3. and deploy the Stack.
-# 4. Navigate back to the root folder
-cd ServicesWorkerIntegration/src/infra/ \
-&& cdk synth \
-&& cdk deploy --require-approval never\
-&& cd -
-
+&& cdk synth --all \
+&& cdk deploy --require-approval never --all
#############################################################
# Echo the WebAPI URL #
@@ -51,5 +20,5 @@ echo "#############################################################"
echo "# the WebAPI URL #"
echo "#############################################################"
echo -e "\n"
-echo $(aws cloudformation describe-stacks --stack-name WebAppInfraStack --output text --query 'Stacks[0].Outputs[?contains(OutputKey,`DemoServiceServiceURLEndpoint`)].OutputValue | [0]')
+echo $(aws cloudformation describe-stacks --stack-name WebAppStack --output text --query 'Stacks[0].Outputs[?contains(OutputKey,`DemoServiceServiceURLEndpoint`)].OutputValue | [0]')
echo -e "\n\n"
diff --git a/src/Common/Amazon.CDK.AWS.ECS.MyExtention/Amazon.CDK.AWS.ECS.MyExtensions.csproj b/src/Common/Amazon.CDK.AWS.ECS.MyExtention/Amazon.CDK.AWS.ECS.MyExtensions.csproj
new file mode 100644
index 0000000..d0635ba
--- /dev/null
+++ b/src/Common/Amazon.CDK.AWS.ECS.MyExtention/Amazon.CDK.AWS.ECS.MyExtensions.csproj
@@ -0,0 +1,12 @@
+
+
+
+ net8.0
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Common/Amazon.CDK.AWS.ECS.MyExtention/CloudWatchAgentProps.cs b/src/Common/Amazon.CDK.AWS.ECS.MyExtention/CloudWatchAgentProps.cs
similarity index 100%
rename from Common/Amazon.CDK.AWS.ECS.MyExtention/CloudWatchAgentProps.cs
rename to src/Common/Amazon.CDK.AWS.ECS.MyExtention/CloudWatchAgentProps.cs
diff --git a/Common/Amazon.CDK.AWS.ECS.MyExtention/TaskDefinitionExtensions.cs b/src/Common/Amazon.CDK.AWS.ECS.MyExtention/TaskDefinitionExtensions.cs
similarity index 100%
rename from Common/Amazon.CDK.AWS.ECS.MyExtention/TaskDefinitionExtensions.cs
rename to src/Common/Amazon.CDK.AWS.ECS.MyExtention/TaskDefinitionExtensions.cs
diff --git a/Common/Amazon.CDK.AWS.ECS.MyExtention/XRayDaemonProps.cs b/src/Common/Amazon.CDK.AWS.ECS.MyExtention/XRayDaemonProps.cs
similarity index 100%
rename from Common/Amazon.CDK.AWS.ECS.MyExtention/XRayDaemonProps.cs
rename to src/Common/Amazon.CDK.AWS.ECS.MyExtention/XRayDaemonProps.cs
diff --git a/ServicesWorkerDb/src/apps/WorkerDb/.dockerignore b/src/SampleWebApp/.dockerignore
similarity index 100%
rename from ServicesWorkerDb/src/apps/WorkerDb/.dockerignore
rename to src/SampleWebApp/.dockerignore
diff --git a/WebAPI/src/apps/SampleWebApp/AppLogger/XrayCustomFormatter.cs b/src/SampleWebApp/AppLogger/XrayCustomFormatter.cs
similarity index 98%
rename from WebAPI/src/apps/SampleWebApp/AppLogger/XrayCustomFormatter.cs
rename to src/SampleWebApp/AppLogger/XrayCustomFormatter.cs
index 7b9a753..7424d52 100644
--- a/WebAPI/src/apps/SampleWebApp/AppLogger/XrayCustomFormatter.cs
+++ b/src/SampleWebApp/AppLogger/XrayCustomFormatter.cs
@@ -2,7 +2,6 @@
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Logging.Console;
using Microsoft.Extensions.Options;
-using System.Runtime.InteropServices;
namespace SampleWebApp.AppLogger;
diff --git a/WebAPI/src/apps/SampleWebApp/AppLogger/XrayCustomFormatterOptions.cs b/src/SampleWebApp/AppLogger/XrayCustomFormatterOptions.cs
similarity index 100%
rename from WebAPI/src/apps/SampleWebApp/AppLogger/XrayCustomFormatterOptions.cs
rename to src/SampleWebApp/AppLogger/XrayCustomFormatterOptions.cs
diff --git a/WebAPI/src/apps/SampleWebApp/Controllers/BooksController.cs b/src/SampleWebApp/Controllers/BooksController.cs
similarity index 100%
rename from WebAPI/src/apps/SampleWebApp/Controllers/BooksController.cs
rename to src/SampleWebApp/Controllers/BooksController.cs
diff --git a/WebAPI/src/apps/SampleWebApp/Dockerfile b/src/SampleWebApp/Dockerfile
similarity index 78%
rename from WebAPI/src/apps/SampleWebApp/Dockerfile
rename to src/SampleWebApp/Dockerfile
index 4ed2776..0d2febb 100644
--- a/WebAPI/src/apps/SampleWebApp/Dockerfile
+++ b/src/SampleWebApp/Dockerfile
@@ -1,11 +1,11 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
-FROM mcr.microsoft.com/dotnet/aspnet:6.0.16-alpine3.17-amd64 AS base
+FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
-FROM mcr.microsoft.com/dotnet/sdk:6.0.408-alpine3.17-amd64 AS build
+FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR "/src/SampleWebApp"
COPY . .
RUN dotnet restore "SampleWebApp.csproj"
diff --git a/WebAPI/src/apps/SampleWebApp/Dockerfile.arm b/src/SampleWebApp/Dockerfile.arm
similarity index 79%
rename from WebAPI/src/apps/SampleWebApp/Dockerfile.arm
rename to src/SampleWebApp/Dockerfile.arm
index c4345fc..3a698f5 100644
--- a/WebAPI/src/apps/SampleWebApp/Dockerfile.arm
+++ b/src/SampleWebApp/Dockerfile.arm
@@ -1,11 +1,11 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
-FROM mcr.microsoft.com/dotnet/aspnet:6.0.1-bullseye-slim-arm64v8 AS base
+FROM mcr.microsoft.com/dotnet/aspnet:8.0.3-bookworm-slim-arm64v8 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
-FROM mcr.microsoft.com/dotnet/sdk:6.0.101-bullseye-slim-amd64 AS build
+FROM mcr.microsoft.com/dotnet/sdk:8.0.203-bookworm-slim-arm64v8 AS build
WORKDIR "/src/SampleWebApp"
COPY . .
RUN dotnet restore "SampleWebApp.csproj"
diff --git a/WebAPI/src/apps/SampleWebApp/Entities/Book.cs b/src/SampleWebApp/Entities/Book.cs
similarity index 93%
rename from WebAPI/src/apps/SampleWebApp/Entities/Book.cs
rename to src/SampleWebApp/Entities/Book.cs
index d68bd69..1697212 100644
--- a/WebAPI/src/apps/SampleWebApp/Entities/Book.cs
+++ b/src/SampleWebApp/Entities/Book.cs
@@ -1,7 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT-0
#pragma warning disable CA2227
-using System.Collections.ObjectModel;
using System.Text.Json.Serialization;
namespace SampleWebApp.Entities;
diff --git a/ServicesWorkerDb/src/infra/src/Infra/GlobalSuppressions.cs b/src/SampleWebApp/GlobalSuppressions.cs
similarity index 100%
rename from ServicesWorkerDb/src/infra/src/Infra/GlobalSuppressions.cs
rename to src/SampleWebApp/GlobalSuppressions.cs
diff --git a/WebAPI/src/apps/SampleWebApp/Program.cs b/src/SampleWebApp/Program.cs
similarity index 100%
rename from WebAPI/src/apps/SampleWebApp/Program.cs
rename to src/SampleWebApp/Program.cs
diff --git a/WebAPI/src/apps/SampleWebApp/Properties/launchSettings.json b/src/SampleWebApp/Properties/launchSettings.json
similarity index 100%
rename from WebAPI/src/apps/SampleWebApp/Properties/launchSettings.json
rename to src/SampleWebApp/Properties/launchSettings.json
diff --git a/WebAPI/src/apps/SampleWebApp/SampleWebApp.csproj b/src/SampleWebApp/SampleWebApp.csproj
similarity index 91%
rename from WebAPI/src/apps/SampleWebApp/SampleWebApp.csproj
rename to src/SampleWebApp/SampleWebApp.csproj
index 82e800e..ec0941b 100644
--- a/WebAPI/src/apps/SampleWebApp/SampleWebApp.csproj
+++ b/src/SampleWebApp/SampleWebApp.csproj
@@ -1,7 +1,7 @@
- net6.0
+ net8.0
enable
true
true
@@ -16,7 +16,8 @@
-
+
diff --git a/WebAPI/src/apps/SampleWebApp/appsettings.Development.json b/src/SampleWebApp/appsettings.Development.json
similarity index 100%
rename from WebAPI/src/apps/SampleWebApp/appsettings.Development.json
rename to src/SampleWebApp/appsettings.Development.json
diff --git a/WebAPI/src/apps/SampleWebApp/appsettings.json b/src/SampleWebApp/appsettings.json
similarity index 100%
rename from WebAPI/src/apps/SampleWebApp/appsettings.json
rename to src/SampleWebApp/appsettings.json
diff --git a/ServicesWorkerIntegration/src/apps/WorkerIntegration/.dockerignore b/src/WorkerDb/.dockerignore
similarity index 100%
rename from ServicesWorkerIntegration/src/apps/WorkerIntegration/.dockerignore
rename to src/WorkerDb/.dockerignore
diff --git a/ServicesWorkerDb/src/apps/WorkerDb/Book.cs b/src/WorkerDb/Book.cs
similarity index 97%
rename from ServicesWorkerDb/src/apps/WorkerDb/Book.cs
rename to src/WorkerDb/Book.cs
index f3930d7..feb221b 100644
--- a/ServicesWorkerDb/src/apps/WorkerDb/Book.cs
+++ b/src/WorkerDb/Book.cs
@@ -3,6 +3,7 @@
using Amazon.DynamoDBv2.DataModel;
using System.Text.Json.Serialization;
+namespace WorkerDb;
///
/// A class representing book information to be added to the Amazon DynamoDB
@@ -25,4 +26,4 @@ public class Book
public List BookAuthors { get; set; }
public string CoverPage { get; set; }
-}
+}
\ No newline at end of file
diff --git a/ServicesWorkerDb/src/apps/WorkerDb/Dockerfile b/src/WorkerDb/Dockerfile
similarity index 79%
rename from ServicesWorkerDb/src/apps/WorkerDb/Dockerfile
rename to src/WorkerDb/Dockerfile
index 0a2f324..4e6debf 100644
--- a/ServicesWorkerDb/src/apps/WorkerDb/Dockerfile
+++ b/src/WorkerDb/Dockerfile
@@ -1,18 +1,21 @@
-
-FROM mcr.microsoft.com/dotnet/aspnet:6.0.16-alpine3.17-amd64 AS base
+# Base image
+FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
RUN addgroup --system --gid 1000 app_group \
&& adduser --system --uid 1000 --ingroup app_group --shell /bin/sh app_user
-FROM mcr.microsoft.com/dotnet/sdk:6.0.408-alpine3.17-amd64 AS build
+# Build stage
+FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR "/src/WorkerDb"
COPY . .
RUN dotnet restore "WorkerDb.csproj"
RUN dotnet build "WorkerDb.csproj" -c Release -o /app/build
+# Publish stage
FROM build AS publish
RUN dotnet publish "WorkerDb.csproj" -c Release -o /app/publish
+# Final stage
FROM base AS final
WORKDIR /app
RUN chown 1000:app_group /app
diff --git a/ServicesWorkerDb/src/apps/WorkerDb/PaylaodMsg.cs b/src/WorkerDb/PaylaodMsg.cs
similarity index 97%
rename from ServicesWorkerDb/src/apps/WorkerDb/PaylaodMsg.cs
rename to src/WorkerDb/PaylaodMsg.cs
index 984ca6e..8ba5907 100644
--- a/ServicesWorkerDb/src/apps/WorkerDb/PaylaodMsg.cs
+++ b/src/WorkerDb/PaylaodMsg.cs
@@ -1,5 +1,7 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT-0
+namespace WorkerDb;
+
public class PaylaodMsg
{
public string Type { get; set; }
diff --git a/ServicesWorkerDb/src/apps/WorkerDb/Program.cs b/src/WorkerDb/Program.cs
similarity index 98%
rename from ServicesWorkerDb/src/apps/WorkerDb/Program.cs
rename to src/WorkerDb/Program.cs
index 85d7f54..3e1f536 100644
--- a/ServicesWorkerDb/src/apps/WorkerDb/Program.cs
+++ b/src/WorkerDb/Program.cs
@@ -1,7 +1,8 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT-0
+global using Amazon.DynamoDBv2;
+
using Amazon.CloudWatch.EMF.Logger;
-using Amazon.DynamoDBv2;
using Amazon.SQS;
using Amazon.XRay.Recorder.Core;
using Amazon.XRay.Recorder.Handlers.AwsSdk;
diff --git a/ServicesWorkerDb/src/apps/WorkerDb/Properties/launchSettings.json b/src/WorkerDb/Properties/launchSettings.json
similarity index 100%
rename from ServicesWorkerDb/src/apps/WorkerDb/Properties/launchSettings.json
rename to src/WorkerDb/Properties/launchSettings.json
diff --git a/ServicesWorkerDb/src/apps/WorkerDb/Worker.cs b/src/WorkerDb/Worker.cs
similarity index 93%
rename from ServicesWorkerDb/src/apps/WorkerDb/Worker.cs
rename to src/WorkerDb/Worker.cs
index 313cd30..c015655 100644
--- a/ServicesWorkerDb/src/apps/WorkerDb/Worker.cs
+++ b/src/WorkerDb/Worker.cs
@@ -3,7 +3,6 @@
using Amazon.SQS;
using Amazon.SQS.Model;
using Amazon.DynamoDBv2.DataModel;
-using Amazon.DynamoDBv2;
using System.Text.Json;
using Amazon.XRay.Recorder.Core;
using Amazon.XRay.Recorder.Core.Internal.Entities;
@@ -37,14 +36,17 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
while (!stoppingToken.IsCancellationRequested)
{
AWSXRayRecorder.Instance.BeginSegment(MY_SERVICE_NAME);
- _logger.LogDebug("Worker running at: {time}", DateTimeOffset.Now);
- _logger.LogDebug("The SQS queue's URL is {queueUrl}", queueUrl);
+ _logger.LogDebug("Worker running at: {Time}", DateTimeOffset.Now);
+ _logger.LogDebug("The SQS queue's URL is {QueueUrl}", queueUrl);
try
{
var messageId = await ReceiveAndDeleteMessage(_sqsClient, queueUrl);
var traceEntity = AWSXRayRecorder.Instance.TraceContext.GetEntity();
- _logger.LogInformation("Message ID: {messageId}, TraceId: {TraceId}", messageId, traceEntity.TraceId);
+ _logger.LogInformation("Message ID: {MessageId}, TraceId: {TraceId}",
+ messageId,
+ traceEntity.TraceId
+ );
}
catch (Exception ex)
{
@@ -85,7 +87,7 @@ public async Task ReceiveAndDeleteMessage(IAmazonSQS client, string qu
// Receive a single message from the queue.
var receiveMessageRequest = new ReceiveMessageRequest
{
- AttributeNames = { "All" },
+ MessageSystemAttributeNames = { "All" },
MaxNumberOfMessages = 10,
MessageAttributeNames = { "All" },
QueueUrl = queueUrl,
@@ -128,7 +130,6 @@ await client.DeleteMessageAsync(new DeleteMessageRequest
var elapsedMs = watch.ElapsedMilliseconds;
//Close/Submmit Segment with Propagated TraceId
- // var propagatedSegment = AWSXRayRecorder.Instance.GetEntity();
AWSXRayRecorder.Instance.EndSegment(DateTime.UtcNow);
AWSXRayRecorder.Instance.Emitter.Send(propagatedSegment);
@@ -139,7 +140,7 @@ await client.DeleteMessageAsync(new DeleteMessageRequest
EmitMetrics(msgItem.Attributes, propagatedSegment.TraceId, elapsedMs);
}
- return receivedMessageResponse?.Messages?.Select(s => s.MessageId).ToArray();
+ return receivedMessageResponse.Messages.Select(s => s.MessageId).ToArray();
}
///
diff --git a/src/WorkerDb/WorkerDb.csproj b/src/WorkerDb/WorkerDb.csproj
new file mode 100644
index 0000000..cee4269
--- /dev/null
+++ b/src/WorkerDb/WorkerDb.csproj
@@ -0,0 +1,23 @@
+
+
+
+ net8.0
+ dotnet-WorkerDb-2E594750-EFDD-4104-9DE3-1139BE00B0E8
+ enable
+ WorkerDb
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ServicesWorkerDb/src/apps/WorkerDb/appsettings.Development.json b/src/WorkerDb/appsettings.Development.json
similarity index 100%
rename from ServicesWorkerDb/src/apps/WorkerDb/appsettings.Development.json
rename to src/WorkerDb/appsettings.Development.json
diff --git a/ServicesWorkerDb/src/apps/WorkerDb/appsettings.json b/src/WorkerDb/appsettings.json
similarity index 100%
rename from ServicesWorkerDb/src/apps/WorkerDb/appsettings.json
rename to src/WorkerDb/appsettings.json
diff --git a/WebAPI/src/apps/SampleWebApp/.dockerignore b/src/WorkerIntegration/.dockerignore
similarity index 100%
rename from WebAPI/src/apps/SampleWebApp/.dockerignore
rename to src/WorkerIntegration/.dockerignore
diff --git a/ServicesWorkerIntegration/src/apps/WorkerIntegration/Book.cs b/src/WorkerIntegration/Book.cs
similarity index 88%
rename from ServicesWorkerIntegration/src/apps/WorkerIntegration/Book.cs
rename to src/WorkerIntegration/Book.cs
index f984b43..5733560 100644
--- a/ServicesWorkerIntegration/src/apps/WorkerIntegration/Book.cs
+++ b/src/WorkerIntegration/Book.cs
@@ -2,7 +2,9 @@
// SPDX-License-Identifier: MIT-0
using System.Text.Json.Serialization;
-public class Book
+namespace WorkerIntegration;
+
+public record Book
{
public Guid Id { get; set; }
public string Title { get; set; }
diff --git a/ServicesWorkerIntegration/src/apps/WorkerIntegration/Dockerfile b/src/WorkerIntegration/Dockerfile
similarity index 57%
rename from ServicesWorkerIntegration/src/apps/WorkerIntegration/Dockerfile
rename to src/WorkerIntegration/Dockerfile
index 05d1de6..9fb4ee9 100644
--- a/ServicesWorkerIntegration/src/apps/WorkerIntegration/Dockerfile
+++ b/src/WorkerIntegration/Dockerfile
@@ -1,20 +1,22 @@
-#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
-
-FROM mcr.microsoft.com/dotnet/aspnet:6.0.16-alpine3.17-amd64 AS base
+# Base image
+FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app
USER appuser
-FROM mcr.microsoft.com/dotnet/sdk:6.0.408-alpine3.17-amd64 AS build
+# Build stage
+FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR "/src/WorkerIntegration"
COPY . .
RUN dotnet restore "WorkerIntegration.csproj"
RUN dotnet build "WorkerIntegration.csproj" -c Release -o /app/build
+# Publish stage
FROM build AS publish
RUN dotnet publish "WorkerIntegration.csproj" -c Release -o /app/publish
+# Final stage
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
-ENTRYPOINT ["dotnet", "WorkerIntegration.dll"]
\ No newline at end of file
+ENTRYPOINT ["dotnet", "WorkerIntegration.dll"]
diff --git a/ServicesWorkerIntegration/src/apps/WorkerIntegration/PaylaodMsg.cs b/src/WorkerIntegration/PaylaodMsg.cs
similarity index 90%
rename from ServicesWorkerIntegration/src/apps/WorkerIntegration/PaylaodMsg.cs
rename to src/WorkerIntegration/PaylaodMsg.cs
index 8e8b667..746d696 100644
--- a/ServicesWorkerIntegration/src/apps/WorkerIntegration/PaylaodMsg.cs
+++ b/src/WorkerIntegration/PaylaodMsg.cs
@@ -1,6 +1,8 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT-0
-public class PaylaodMsg
+namespace WorkerIntegration;
+
+public record PaylaodMsg
{
public string Type { get; set; }
public string MessageId { get; set; }
diff --git a/ServicesWorkerIntegration/src/apps/WorkerIntegration/Program.cs b/src/WorkerIntegration/Program.cs
similarity index 90%
rename from ServicesWorkerIntegration/src/apps/WorkerIntegration/Program.cs
rename to src/WorkerIntegration/Program.cs
index f109201..6863e60 100644
--- a/ServicesWorkerIntegration/src/apps/WorkerIntegration/Program.cs
+++ b/src/WorkerIntegration/Program.cs
@@ -1,12 +1,14 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT-0
-using Amazon.CloudWatch.EMF.Logger;
-using Amazon.S3;
-using Amazon.SQS;
-using Amazon.XRay.Recorder.Core;
+global using Amazon.SQS;
+global using Amazon.S3;
+global using Amazon.CloudWatch.EMF.Logger;
+global using Amazon.XRay.Recorder.Core;
+
using Amazon.XRay.Recorder.Handlers.AwsSdk;
-using WorkerIntegration;
using EMF = Amazon.CloudWatch.EMF;
+using WorkerIntegration;
+
IHost host = Host.CreateDefaultBuilder(args)
diff --git a/ServicesWorkerIntegration/src/apps/WorkerIntegration/Properties/launchSettings.json b/src/WorkerIntegration/Properties/launchSettings.json
similarity index 100%
rename from ServicesWorkerIntegration/src/apps/WorkerIntegration/Properties/launchSettings.json
rename to src/WorkerIntegration/Properties/launchSettings.json
diff --git a/ServicesWorkerIntegration/src/apps/WorkerIntegration/Worker.cs b/src/WorkerIntegration/Worker.cs
similarity index 88%
rename from ServicesWorkerIntegration/src/apps/WorkerIntegration/Worker.cs
rename to src/WorkerIntegration/Worker.cs
index 87a2f24..7cd2776 100644
--- a/ServicesWorkerIntegration/src/apps/WorkerIntegration/Worker.cs
+++ b/src/WorkerIntegration/Worker.cs
@@ -1,15 +1,11 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT-0
-using Amazon.SQS;
using Amazon.SQS.Model;
using System.Text.Json;
-using Amazon.S3;
using Amazon.S3.Model;
-using Amazon.XRay.Recorder.Core;
using Amazon.XRay.Recorder.Core.Internal.Entities;
using Amazon.XRay.Recorder.Core.Sampling;
using Amazon.CloudWatch.EMF.Model;
-using Amazon.CloudWatch.EMF.Logger;
namespace WorkerIntegration;
public class Worker : BackgroundService
@@ -37,14 +33,14 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
while (!stoppingToken.IsCancellationRequested)
{
AWSXRayRecorder.Instance.BeginSegment(MY_SERVICE_NAME);
- _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
- _logger.LogInformation("The SQS queue's URL is {queueUrl}", queueUrl);
+ _logger.LogInformation("Worker running at: {Time}", DateTimeOffset.Now);
+ _logger.LogInformation("The SQS queue's URL is {QueueUrl}", queueUrl);
try
{
var messageId = await ReceiveAndDeleteMessage(_sqsClient, queueUrl);
var traceEntity = AWSXRayRecorder.Instance.TraceContext.GetEntity();
- _logger.LogInformation("Message ID: {messageId}, TraceId: {TraceId}", messageId, traceEntity.TraceId);
+ _logger.LogInformation("Message ID: {MessageId}, TraceId: {TraceId}", messageId, traceEntity.TraceId);
}
catch (System.Exception ex)
{
@@ -85,7 +81,7 @@ public async Task ReceiveAndDeleteMessage(IAmazonSQS client, string qu
// Receive a single message from the queue.
var receiveMessageRequest = new ReceiveMessageRequest
{
- AttributeNames = { "All" },
+ MessageSystemAttributeNames = { "All" },
MaxNumberOfMessages = 1,
MessageAttributeNames = { "All" },
QueueUrl = queueUrl,
@@ -125,7 +121,6 @@ await client.DeleteMessageAsync(new DeleteMessageRequest
var elapsedMs = watch.ElapsedMilliseconds;
//Close/Submmit Segment with Propagated TraceId
- //var propagatedSegment = AWSXRayRecorder.Instance.GetEntity();
AWSXRayRecorder.Instance.EndSegment(DateTime.UtcNow);
AWSXRayRecorder.Instance.Emitter.Send(propagatedSegment);
@@ -135,7 +130,7 @@ await client.DeleteMessageAsync(new DeleteMessageRequest
EmitMetrics(msgItem.Attributes, propagatedSegment.TraceId, elapsedMs);
}
- return receivedMessageResponse?.Messages?.Select(s => s.MessageId).ToArray();
+ return receivedMessageResponse.Messages.Select(s => s.MessageId).ToArray();
}
public async Task PerformCRUDOperations(Amazon.SQS.Model.Message message)
@@ -160,7 +155,12 @@ public async Task PerformCRUDOperations(Amazon.SQS.Model.Message message)
};
_ = await _s3Client.PutObjectAsync(putRequest2);
- _logger.LogInformation("Messages saved on S3 Bucket {Key} metadata seved on {Key} SQS Attr {}", putRequest1.Key, putRequest2.Key, JsonSerializer.Serialize(message.Attributes));
+ _logger.LogInformation(
+ "Messages saved on S3 Bucket {Request1Key} metadata seved on {Request2Key} SQS Attr {Attributes}",
+ putRequest1.Key,
+ putRequest2.Key,
+ JsonSerializer.Serialize(message.Attributes)
+ );
}
diff --git a/ServicesWorkerIntegration/src/apps/WorkerIntegration/WorkerIntegration.csproj b/src/WorkerIntegration/WorkerIntegration.csproj
similarity index 50%
rename from ServicesWorkerIntegration/src/apps/WorkerIntegration/WorkerIntegration.csproj
rename to src/WorkerIntegration/WorkerIntegration.csproj
index b741bfa..5a9309d 100644
--- a/ServicesWorkerIntegration/src/apps/WorkerIntegration/WorkerIntegration.csproj
+++ b/src/WorkerIntegration/WorkerIntegration.csproj
@@ -1,23 +1,23 @@
- net6.0
+ net8.0
dotnet-WorkerIntegration-16DA5987-F46F-4341-A563-D76723C9EC3C
enable
WorkerIntegration
true
- fale
- false
+ true
+ true
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ServicesWorkerIntegration/src/apps/WorkerIntegration/appsettings.Development.json b/src/WorkerIntegration/appsettings.Development.json
similarity index 100%
rename from ServicesWorkerIntegration/src/apps/WorkerIntegration/appsettings.Development.json
rename to src/WorkerIntegration/appsettings.Development.json
diff --git a/ServicesWorkerIntegration/src/apps/WorkerIntegration/appsettings.json b/src/WorkerIntegration/appsettings.json
similarity index 100%
rename from ServicesWorkerIntegration/src/apps/WorkerIntegration/appsettings.json
rename to src/WorkerIntegration/appsettings.json
diff --git a/ServicesWorkerDb/src/infra/.gitignore b/src/infra/.gitignore
similarity index 100%
rename from ServicesWorkerDb/src/infra/.gitignore
rename to src/infra/.gitignore
diff --git a/WebAPI/src/infra/README.md b/src/infra/README.md
similarity index 68%
rename from WebAPI/src/infra/README.md
rename to src/infra/README.md
index 25ccb2e..422c7a5 100644
--- a/WebAPI/src/infra/README.md
+++ b/src/infra/README.md
@@ -15,7 +15,7 @@ It uses the [.NET Core CLI](https://docs.microsoft.com/dotnet/articles/core/) to
```bash
-export DEMO_VPC_ID=$(aws cloudformation describe-stacks --stack-name WebAppInfraStack --output text --query 'Stacks[0].Outputs[?OutputKey==`DemoVpcId`].OutputValue | [0]')
+export DEMO_VPC_ID=$(aws cloudformation describe-stacks --stack-name WebAppStack --output text --query 'Stacks[0].Outputs[?OutputKey==`DemoVpcId`].OutputValue | [0]')
-aws cloudformation describe-stacks --stack-name WebAppInfraStack --output text --query 'Stacks[0].Outputs[?contains(OutputKey,`demoserviceServiceURL`)].OutputValue | [0]'
+aws cloudformation describe-stacks --stack-name WebAppStack --output text --query 'Stacks[0].Outputs[?contains(OutputKey,`demoserviceServiceURL`)].OutputValue | [0]'
```
diff --git a/WebAPI/src/infra/cdk.json b/src/infra/cdk.json
similarity index 100%
rename from WebAPI/src/infra/cdk.json
rename to src/infra/cdk.json
diff --git a/src/infra/output.yaml b/src/infra/output.yaml
new file mode 100644
index 0000000..56fd052
--- /dev/null
+++ b/src/infra/output.yaml
@@ -0,0 +1,792 @@
+Resources:
+ demovpc6A63F275:
+ Type: AWS::EC2::VPC
+ Properties:
+ CidrBlock: 172.30.0.0/16
+ EnableDnsHostnames: true
+ EnableDnsSupport: true
+ InstanceTenancy: default
+ Tags:
+ - Key: Name
+ Value: WebAppInfraStack/demo-vpc
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-vpc/Resource
+ demovpcPublicSubnet1Subnet59C04EC3:
+ Type: AWS::EC2::Subnet
+ Properties:
+ CidrBlock: 172.30.0.0/18
+ VpcId:
+ Ref: demovpc6A63F275
+ AvailabilityZone:
+ Fn::Select:
+ - 0
+ - Fn::GetAZs: ""
+ MapPublicIpOnLaunch: true
+ Tags:
+ - Key: aws-cdk:subnet-name
+ Value: Public
+ - Key: aws-cdk:subnet-type
+ Value: Public
+ - Key: Name
+ Value: WebAppInfraStack/demo-vpc/PublicSubnet1
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-vpc/PublicSubnet1/Subnet
+ demovpcPublicSubnet1RouteTable51989EA1:
+ Type: AWS::EC2::RouteTable
+ Properties:
+ VpcId:
+ Ref: demovpc6A63F275
+ Tags:
+ - Key: Name
+ Value: WebAppInfraStack/demo-vpc/PublicSubnet1
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-vpc/PublicSubnet1/RouteTable
+ demovpcPublicSubnet1RouteTableAssociationFF9AFCBE:
+ Type: AWS::EC2::SubnetRouteTableAssociation
+ Properties:
+ RouteTableId:
+ Ref: demovpcPublicSubnet1RouteTable51989EA1
+ SubnetId:
+ Ref: demovpcPublicSubnet1Subnet59C04EC3
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-vpc/PublicSubnet1/RouteTableAssociation
+ demovpcPublicSubnet1DefaultRouteDE177143:
+ Type: AWS::EC2::Route
+ Properties:
+ RouteTableId:
+ Ref: demovpcPublicSubnet1RouteTable51989EA1
+ DestinationCidrBlock: 0.0.0.0/0
+ GatewayId:
+ Ref: demovpcIGW56AC0B57
+ DependsOn:
+ - demovpcVPCGWF2B48F8C
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-vpc/PublicSubnet1/DefaultRoute
+ demovpcPublicSubnet1EIPCA80177D:
+ Type: AWS::EC2::EIP
+ Properties:
+ Domain: vpc
+ Tags:
+ - Key: Name
+ Value: WebAppInfraStack/demo-vpc/PublicSubnet1
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-vpc/PublicSubnet1/EIP
+ demovpcPublicSubnet1NATGatewayAB5E6BBE:
+ Type: AWS::EC2::NatGateway
+ Properties:
+ SubnetId:
+ Ref: demovpcPublicSubnet1Subnet59C04EC3
+ AllocationId:
+ Fn::GetAtt:
+ - demovpcPublicSubnet1EIPCA80177D
+ - AllocationId
+ Tags:
+ - Key: Name
+ Value: WebAppInfraStack/demo-vpc/PublicSubnet1
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-vpc/PublicSubnet1/NATGateway
+ demovpcPublicSubnet2Subnet4F3C6289:
+ Type: AWS::EC2::Subnet
+ Properties:
+ CidrBlock: 172.30.64.0/18
+ VpcId:
+ Ref: demovpc6A63F275
+ AvailabilityZone:
+ Fn::Select:
+ - 1
+ - Fn::GetAZs: ""
+ MapPublicIpOnLaunch: true
+ Tags:
+ - Key: aws-cdk:subnet-name
+ Value: Public
+ - Key: aws-cdk:subnet-type
+ Value: Public
+ - Key: Name
+ Value: WebAppInfraStack/demo-vpc/PublicSubnet2
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-vpc/PublicSubnet2/Subnet
+ demovpcPublicSubnet2RouteTable034FAB8B:
+ Type: AWS::EC2::RouteTable
+ Properties:
+ VpcId:
+ Ref: demovpc6A63F275
+ Tags:
+ - Key: Name
+ Value: WebAppInfraStack/demo-vpc/PublicSubnet2
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-vpc/PublicSubnet2/RouteTable
+ demovpcPublicSubnet2RouteTableAssociation39E6991E:
+ Type: AWS::EC2::SubnetRouteTableAssociation
+ Properties:
+ RouteTableId:
+ Ref: demovpcPublicSubnet2RouteTable034FAB8B
+ SubnetId:
+ Ref: demovpcPublicSubnet2Subnet4F3C6289
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-vpc/PublicSubnet2/RouteTableAssociation
+ demovpcPublicSubnet2DefaultRoute5D66C9AC:
+ Type: AWS::EC2::Route
+ Properties:
+ RouteTableId:
+ Ref: demovpcPublicSubnet2RouteTable034FAB8B
+ DestinationCidrBlock: 0.0.0.0/0
+ GatewayId:
+ Ref: demovpcIGW56AC0B57
+ DependsOn:
+ - demovpcVPCGWF2B48F8C
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-vpc/PublicSubnet2/DefaultRoute
+ demovpcPublicSubnet2EIPEA9A73CA:
+ Type: AWS::EC2::EIP
+ Properties:
+ Domain: vpc
+ Tags:
+ - Key: Name
+ Value: WebAppInfraStack/demo-vpc/PublicSubnet2
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-vpc/PublicSubnet2/EIP
+ demovpcPublicSubnet2NATGateway9A5582EA:
+ Type: AWS::EC2::NatGateway
+ Properties:
+ SubnetId:
+ Ref: demovpcPublicSubnet2Subnet4F3C6289
+ AllocationId:
+ Fn::GetAtt:
+ - demovpcPublicSubnet2EIPEA9A73CA
+ - AllocationId
+ Tags:
+ - Key: Name
+ Value: WebAppInfraStack/demo-vpc/PublicSubnet2
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-vpc/PublicSubnet2/NATGateway
+ demovpcPrivateSubnet1Subnet60C4FF92:
+ Type: AWS::EC2::Subnet
+ Properties:
+ CidrBlock: 172.30.128.0/18
+ VpcId:
+ Ref: demovpc6A63F275
+ AvailabilityZone:
+ Fn::Select:
+ - 0
+ - Fn::GetAZs: ""
+ MapPublicIpOnLaunch: false
+ Tags:
+ - Key: aws-cdk:subnet-name
+ Value: Private
+ - Key: aws-cdk:subnet-type
+ Value: Private
+ - Key: Name
+ Value: WebAppInfraStack/demo-vpc/PrivateSubnet1
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-vpc/PrivateSubnet1/Subnet
+ demovpcPrivateSubnet1RouteTable00225A39:
+ Type: AWS::EC2::RouteTable
+ Properties:
+ VpcId:
+ Ref: demovpc6A63F275
+ Tags:
+ - Key: Name
+ Value: WebAppInfraStack/demo-vpc/PrivateSubnet1
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-vpc/PrivateSubnet1/RouteTable
+ demovpcPrivateSubnet1RouteTableAssociation7FF17595:
+ Type: AWS::EC2::SubnetRouteTableAssociation
+ Properties:
+ RouteTableId:
+ Ref: demovpcPrivateSubnet1RouteTable00225A39
+ SubnetId:
+ Ref: demovpcPrivateSubnet1Subnet60C4FF92
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-vpc/PrivateSubnet1/RouteTableAssociation
+ demovpcPrivateSubnet1DefaultRouteC02957FA:
+ Type: AWS::EC2::Route
+ Properties:
+ RouteTableId:
+ Ref: demovpcPrivateSubnet1RouteTable00225A39
+ DestinationCidrBlock: 0.0.0.0/0
+ NatGatewayId:
+ Ref: demovpcPublicSubnet1NATGatewayAB5E6BBE
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-vpc/PrivateSubnet1/DefaultRoute
+ demovpcPrivateSubnet2Subnet53D6A690:
+ Type: AWS::EC2::Subnet
+ Properties:
+ CidrBlock: 172.30.192.0/18
+ VpcId:
+ Ref: demovpc6A63F275
+ AvailabilityZone:
+ Fn::Select:
+ - 1
+ - Fn::GetAZs: ""
+ MapPublicIpOnLaunch: false
+ Tags:
+ - Key: aws-cdk:subnet-name
+ Value: Private
+ - Key: aws-cdk:subnet-type
+ Value: Private
+ - Key: Name
+ Value: WebAppInfraStack/demo-vpc/PrivateSubnet2
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-vpc/PrivateSubnet2/Subnet
+ demovpcPrivateSubnet2RouteTable15934A3F:
+ Type: AWS::EC2::RouteTable
+ Properties:
+ VpcId:
+ Ref: demovpc6A63F275
+ Tags:
+ - Key: Name
+ Value: WebAppInfraStack/demo-vpc/PrivateSubnet2
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-vpc/PrivateSubnet2/RouteTable
+ demovpcPrivateSubnet2RouteTableAssociation8A33EBE6:
+ Type: AWS::EC2::SubnetRouteTableAssociation
+ Properties:
+ RouteTableId:
+ Ref: demovpcPrivateSubnet2RouteTable15934A3F
+ SubnetId:
+ Ref: demovpcPrivateSubnet2Subnet53D6A690
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-vpc/PrivateSubnet2/RouteTableAssociation
+ demovpcPrivateSubnet2DefaultRoute93C66FBE:
+ Type: AWS::EC2::Route
+ Properties:
+ RouteTableId:
+ Ref: demovpcPrivateSubnet2RouteTable15934A3F
+ DestinationCidrBlock: 0.0.0.0/0
+ NatGatewayId:
+ Ref: demovpcPublicSubnet2NATGateway9A5582EA
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-vpc/PrivateSubnet2/DefaultRoute
+ demovpcIGW56AC0B57:
+ Type: AWS::EC2::InternetGateway
+ Properties:
+ Tags:
+ - Key: Name
+ Value: WebAppInfraStack/demo-vpc
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-vpc/IGW
+ demovpcVPCGWF2B48F8C:
+ Type: AWS::EC2::VPCGatewayAttachment
+ Properties:
+ VpcId:
+ Ref: demovpc6A63F275
+ InternetGatewayId:
+ Ref: demovpcIGW56AC0B57
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-vpc/VPCGW
+ democluster9F0F8BE1:
+ Type: AWS::ECS::Cluster
+ Properties:
+ ClusterSettings:
+ - Name: containerInsights
+ Value: enabled
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-cluster/Resource
+ TopicBFC7AF6E:
+ Type: AWS::SNS::Topic
+ Properties:
+ DisplayName: Customer subscription topic
+ TopicName: demo-web-app-topic
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/Topic/Resource
+ demologgroupF8EFF667:
+ Type: AWS::Logs::LogGroup
+ Properties:
+ LogGroupName: /ecs/demo/ecs-fargate-dotnet-microservices
+ RetentionInDays: 1
+ UpdateReplacePolicy: Delete
+ DeletionPolicy: Delete
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-log-group/Resource
+ demoserviceLB4B2B1BF2:
+ Type: AWS::ElasticLoadBalancingV2::LoadBalancer
+ Properties:
+ LoadBalancerAttributes:
+ - Key: deletion_protection.enabled
+ Value: "false"
+ Scheme: internet-facing
+ SecurityGroups:
+ - Fn::GetAtt:
+ - demoserviceLBSecurityGroupB7433664
+ - GroupId
+ Subnets:
+ - Ref: demovpcPublicSubnet1Subnet59C04EC3
+ - Ref: demovpcPublicSubnet2Subnet4F3C6289
+ Type: application
+ DependsOn:
+ - demovpcPublicSubnet1DefaultRouteDE177143
+ - demovpcPublicSubnet2DefaultRoute5D66C9AC
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-service/LB/Resource
+ demoserviceLBSecurityGroupB7433664:
+ Type: AWS::EC2::SecurityGroup
+ Properties:
+ GroupDescription: Automatically created Security Group for ELB WebAppInfraStackdemoserviceLB72BC164F
+ SecurityGroupIngress:
+ - CidrIp: 0.0.0.0/0
+ Description: Allow from anyone on port 80
+ FromPort: 80
+ IpProtocol: tcp
+ ToPort: 80
+ VpcId:
+ Ref: demovpc6A63F275
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-service/LB/SecurityGroup/Resource
+ demoserviceLBSecurityGrouptoWebAppInfraStackdemoserviceServiceSecurityGroupFE37520180D63C1DEC:
+ Type: AWS::EC2::SecurityGroupEgress
+ Properties:
+ GroupId:
+ Fn::GetAtt:
+ - demoserviceLBSecurityGroupB7433664
+ - GroupId
+ IpProtocol: tcp
+ Description: Load balancer to target
+ DestinationSecurityGroupId:
+ Fn::GetAtt:
+ - demoserviceServiceSecurityGroupF47260B1
+ - GroupId
+ FromPort: 80
+ ToPort: 80
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-service/LB/SecurityGroup/to WebAppInfraStackdemoserviceServiceSecurityGroupFE375201:80
+ demoserviceLBPublicListener0409B8C6:
+ Type: AWS::ElasticLoadBalancingV2::Listener
+ Properties:
+ DefaultActions:
+ - TargetGroupArn:
+ Ref: demoserviceLBPublicListenerECSGroup09A12C15
+ Type: forward
+ LoadBalancerArn:
+ Ref: demoserviceLB4B2B1BF2
+ Port: 80
+ Protocol: HTTP
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-service/LB/PublicListener/Resource
+ demoserviceLBPublicListenerECSGroup09A12C15:
+ Type: AWS::ElasticLoadBalancingV2::TargetGroup
+ Properties:
+ Port: 80
+ Protocol: HTTP
+ TargetGroupAttributes:
+ - Key: stickiness.enabled
+ Value: "false"
+ TargetType: ip
+ VpcId:
+ Ref: demovpc6A63F275
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-service/LB/PublicListener/ECSGroup/Resource
+ demoserviceTaskDefTaskRole586A7A1C:
+ Type: AWS::IAM::Role
+ Properties:
+ AssumeRolePolicyDocument:
+ Statement:
+ - Action: sts:AssumeRole
+ Effect: Allow
+ Principal:
+ Service: ecs-tasks.amazonaws.com
+ Version: "2012-10-17"
+ ManagedPolicyArns:
+ - Fn::Join:
+ - ""
+ - - "arn:"
+ - Ref: AWS::Partition
+ - :iam::aws:policy/AWSXRayDaemonWriteAccess
+ - Fn::Join:
+ - ""
+ - - "arn:"
+ - Ref: AWS::Partition
+ - :iam::aws:policy/CloudWatchAgentServerPolicy
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-service/TaskDef/TaskRole/Resource
+ demoserviceTaskDefTaskRoleDefaultPolicy78838EC6:
+ Type: AWS::IAM::Policy
+ Properties:
+ PolicyDocument:
+ Statement:
+ - Action: sns:Publish
+ Effect: Allow
+ Resource:
+ Ref: TopicBFC7AF6E
+ Version: "2012-10-17"
+ PolicyName: demoserviceTaskDefTaskRoleDefaultPolicy78838EC6
+ Roles:
+ - Ref: demoserviceTaskDefTaskRole586A7A1C
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-service/TaskDef/TaskRole/DefaultPolicy/Resource
+ demoserviceTaskDef3D628E08:
+ Type: AWS::ECS::TaskDefinition
+ Properties:
+ ContainerDefinitions:
+ - Environment:
+ - Name: SNS_TOPIC_ARN
+ Value:
+ Ref: TopicBFC7AF6E
+ - Name: ASPNETCORE_URLS
+ Value: http://+:80
+ - Name: EMF_LOG_GROUP_NAME
+ Value: /ecs/demo/ecs-fargate-dotnet-microservices
+ Essential: true
+ Image:
+ Fn::Sub: ${AWS::AccountId}.dkr.ecr.${AWS::Region}.${AWS::URLSuffix}/cdk-hnb659fds-container-assets-${AWS::AccountId}-${AWS::Region}:17f3cd33e412a16dea9b6e8d45b20218717a202491a500f2946fe2d332c5745f
+ LogConfiguration:
+ LogDriver: awslogs
+ Options:
+ awslogs-group:
+ Ref: demologgroupF8EFF667
+ awslogs-stream-prefix: ecs/web-api
+ awslogs-region:
+ Ref: AWS::Region
+ Name: web
+ PortMappings:
+ - ContainerPort: 80
+ Protocol: tcp
+ - Cpu: 32
+ Essential: true
+ Image: public.ecr.aws/xray/aws-xray-daemon:latest
+ LogConfiguration:
+ LogDriver: awslogs
+ Options:
+ awslogs-group:
+ Ref: demologgroupF8EFF667
+ awslogs-stream-prefix: ecs/web-api
+ awslogs-region:
+ Ref: AWS::Region
+ Memory: 256
+ Name: xray-daemon
+ PortMappings:
+ - ContainerPort: 2000
+ Protocol: udp
+ - Cpu: 32
+ Environment:
+ - Name: CW_CONFIG_CONTENT
+ Value: '{"logs":{"metrics_collected":{"emf":{}}}}'
+ Essential: true
+ Image: public.ecr.aws/cloudwatch-agent/cloudwatch-agent:latest
+ LogConfiguration:
+ LogDriver: awslogs
+ Options:
+ awslogs-group:
+ Ref: demologgroupF8EFF667
+ awslogs-stream-prefix: ecs/web-api
+ awslogs-region:
+ Ref: AWS::Region
+ Memory: 256
+ Name: cwagent
+ PortMappings:
+ - ContainerPort: 25888
+ Protocol: tcp
+ Cpu: "512"
+ ExecutionRoleArn:
+ Fn::GetAtt:
+ - demoserviceTaskDefExecutionRole2FFCFA31
+ - Arn
+ Family: WebAppInfraStackdemoserviceTaskDef1C742E47
+ Memory: "1024"
+ NetworkMode: awsvpc
+ RequiresCompatibilities:
+ - FARGATE
+ TaskRoleArn:
+ Fn::GetAtt:
+ - demoserviceTaskDefTaskRole586A7A1C
+ - Arn
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-service/TaskDef/Resource
+ demoserviceTaskDefExecutionRole2FFCFA31:
+ Type: AWS::IAM::Role
+ Properties:
+ AssumeRolePolicyDocument:
+ Statement:
+ - Action: sts:AssumeRole
+ Effect: Allow
+ Principal:
+ Service: ecs-tasks.amazonaws.com
+ Version: "2012-10-17"
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-service/TaskDef/ExecutionRole/Resource
+ demoserviceTaskDefExecutionRoleDefaultPolicyCB9D0E45:
+ Type: AWS::IAM::Policy
+ Properties:
+ PolicyDocument:
+ Statement:
+ - Action:
+ - ecr:BatchCheckLayerAvailability
+ - ecr:GetDownloadUrlForLayer
+ - ecr:BatchGetImage
+ Effect: Allow
+ Resource:
+ Fn::Join:
+ - ""
+ - - "arn:"
+ - Ref: AWS::Partition
+ - ":ecr:"
+ - Ref: AWS::Region
+ - ":"
+ - Ref: AWS::AccountId
+ - :repository/
+ - Fn::Sub: cdk-hnb659fds-container-assets-${AWS::AccountId}-${AWS::Region}
+ - Action: ecr:GetAuthorizationToken
+ Effect: Allow
+ Resource: "*"
+ - Action:
+ - logs:CreateLogStream
+ - logs:PutLogEvents
+ Effect: Allow
+ Resource:
+ Fn::GetAtt:
+ - demologgroupF8EFF667
+ - Arn
+ Version: "2012-10-17"
+ PolicyName: demoserviceTaskDefExecutionRoleDefaultPolicyCB9D0E45
+ Roles:
+ - Ref: demoserviceTaskDefExecutionRole2FFCFA31
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-service/TaskDef/ExecutionRole/DefaultPolicy/Resource
+ demoserviceService92541146:
+ Type: AWS::ECS::Service
+ Properties:
+ Cluster:
+ Ref: democluster9F0F8BE1
+ DeploymentConfiguration:
+ MaximumPercent: 200
+ MinimumHealthyPercent: 50
+ DesiredCount: 1
+ EnableECSManagedTags: false
+ HealthCheckGracePeriodSeconds: 60
+ LaunchType: FARGATE
+ LoadBalancers:
+ - ContainerName: web
+ ContainerPort: 80
+ TargetGroupArn:
+ Ref: demoserviceLBPublicListenerECSGroup09A12C15
+ NetworkConfiguration:
+ AwsvpcConfiguration:
+ AssignPublicIp: DISABLED
+ SecurityGroups:
+ - Fn::GetAtt:
+ - demoserviceServiceSecurityGroupF47260B1
+ - GroupId
+ Subnets:
+ - Ref: demovpcPrivateSubnet1Subnet60C4FF92
+ - Ref: demovpcPrivateSubnet2Subnet53D6A690
+ TaskDefinition:
+ Ref: demoserviceTaskDef3D628E08
+ DependsOn:
+ - demoserviceLBPublicListenerECSGroup09A12C15
+ - demoserviceLBPublicListener0409B8C6
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-service/Service/Service
+ demoserviceServiceSecurityGroupF47260B1:
+ Type: AWS::EC2::SecurityGroup
+ Properties:
+ GroupDescription: WebAppInfraStack/demo-service/Service/SecurityGroup
+ SecurityGroupEgress:
+ - CidrIp: 0.0.0.0/0
+ Description: Allow all outbound traffic by default
+ IpProtocol: "-1"
+ VpcId:
+ Ref: demovpc6A63F275
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-service/Service/SecurityGroup/Resource
+ demoserviceServiceSecurityGroupfromWebAppInfraStackdemoserviceLBSecurityGroupDA5F8ACB808B092541:
+ Type: AWS::EC2::SecurityGroupIngress
+ Properties:
+ IpProtocol: tcp
+ Description: Load balancer to target
+ FromPort: 80
+ GroupId:
+ Fn::GetAtt:
+ - demoserviceServiceSecurityGroupF47260B1
+ - GroupId
+ SourceSecurityGroupId:
+ Fn::GetAtt:
+ - demoserviceLBSecurityGroupB7433664
+ - GroupId
+ ToPort: 80
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-service/Service/SecurityGroup/from WebAppInfraStackdemoserviceLBSecurityGroupDA5F8ACB:80
+ demoserviceServiceTaskCountTargetAB404D38:
+ Type: AWS::ApplicationAutoScaling::ScalableTarget
+ Properties:
+ MaxCapacity: 10
+ MinCapacity: 1
+ ResourceId:
+ Fn::Join:
+ - ""
+ - - service/
+ - Ref: democluster9F0F8BE1
+ - /
+ - Fn::GetAtt:
+ - demoserviceService92541146
+ - Name
+ RoleARN:
+ Fn::Join:
+ - ""
+ - - "arn:"
+ - Ref: AWS::Partition
+ - ":iam::"
+ - Ref: AWS::AccountId
+ - :role/aws-service-role/ecs.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_ECSService
+ ScalableDimension: ecs:service:DesiredCount
+ ServiceNamespace: ecs
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-service/Service/TaskCount/Target/Resource
+ demoserviceServiceTaskCountTargetCpuScalingF093261E:
+ Type: AWS::ApplicationAutoScaling::ScalingPolicy
+ Properties:
+ PolicyName: WebAppInfraStackdemoserviceServiceTaskCountTargetCpuScalingE141C872
+ PolicyType: TargetTrackingScaling
+ ScalingTargetId:
+ Ref: demoserviceServiceTaskCountTargetAB404D38
+ TargetTrackingScalingPolicyConfiguration:
+ PredefinedMetricSpecification:
+ PredefinedMetricType: ECSServiceAverageCPUUtilization
+ TargetValue: 60
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/demo-service/Service/TaskCount/Target/CpuScaling/Resource
+ CDKMetadata:
+ Type: AWS::CDK::Metadata
+ Properties:
+ Analytics: v2:deflate64:H4sIAAAAAAAA/31TwY7aMBD9lt6NYem5BzbQFdKKoiTiigYzm7oEO/LYrFCUf+/YIYTdrXry8/PzePxmZi5ncvYN3mmijqdJrQ+yLTyok2Bq36Kay3bXKJG9md02E9twqLUqwsGgj9yIchs8lnCoceRHbkFklQavrbmLI1itt3HZgH8Bj+9wFVunLwzHwGvj0TEeBH0mt93Cc66/z2i8KFAFp/31xdnQpBz+S6wqh0Rf6LVJfCdQkWyzOhC/HlUD/AmugvgrOi3xTRs9/OkzY40HbdA9cLe7BbqLVr1PN1goqKNPMUhmg/ExAbcHIvQkl1ad0K3PUEUj2RY+kzk2lrS37voMhIIM51vaRqdaJdCJ2lbMvtrq7sGA0wf3DfhoLslF03BdU31eLRyfORuj8PgpYayBvFY1Kw5JoU114Qb5923Xv/ewf9RpdtPcNAN+OC/5Za75kPbDthMazrLNbd9pad1avpdao0edgDEUBG+J/eVkubfvRseAqQQfmX4pHY8AXyj6e2P8D0TXiRzJBsfepMLw5FR8GoW/gm9CPxmDJHaRNcfUC51YWr9BP/0un+R8NpWbVZlZh2zBZIeOWPLjwmfTpzifPKF/SOuJ487QZ5R5v/4FD/VVB7wDAAA=
+ Metadata:
+ aws:cdk:path: WebAppInfraStack/CDKMetadata/Default
+ Condition: CDKMetadataAvailable
+Outputs:
+ demoserviceLoadBalancerDNSE9520154:
+ Value:
+ Fn::GetAtt:
+ - demoserviceLB4B2B1BF2
+ - DNSName
+ demoserviceServiceURL1659A9E9:
+ Value:
+ Fn::Join:
+ - ""
+ - - http://
+ - Fn::GetAtt:
+ - demoserviceLB4B2B1BF2
+ - DNSName
+ DemoSnsTopicArn:
+ Value:
+ Ref: TopicBFC7AF6E
+ Export:
+ Name: DemoSnsTopicArn
+ DemoClusterName:
+ Value:
+ Ref: democluster9F0F8BE1
+ Export:
+ Name: DemoClusterName
+ DemoLogGroupName:
+ Value: /ecs/demo/ecs-fargate-dotnet-microservices
+ Export:
+ Name: DemoLogGroupName
+ DemoVpcId:
+ Value:
+ Ref: demovpc6A63F275
+ Export:
+ Name: DemoVpcId
+ DemoDeployRegion:
+ Value:
+ Ref: AWS::Region
+ Export:
+ Name: DemoDeployRegion
+ demoserviceServiceURLEndpoint:
+ Value:
+ Fn::Join:
+ - ""
+ - - http://
+ - Fn::GetAtt:
+ - demoserviceLB4B2B1BF2
+ - DNSName
+ - /api/Books
+ Export:
+ Name: demoserviceServiceURLEndpoint
+Conditions:
+ CDKMetadataAvailable:
+ Fn::Or:
+ - Fn::Or:
+ - Fn::Equals:
+ - Ref: AWS::Region
+ - af-south-1
+ - Fn::Equals:
+ - Ref: AWS::Region
+ - ap-east-1
+ - Fn::Equals:
+ - Ref: AWS::Region
+ - ap-northeast-1
+ - Fn::Equals:
+ - Ref: AWS::Region
+ - ap-northeast-2
+ - Fn::Equals:
+ - Ref: AWS::Region
+ - ap-south-1
+ - Fn::Equals:
+ - Ref: AWS::Region
+ - ap-southeast-1
+ - Fn::Equals:
+ - Ref: AWS::Region
+ - ap-southeast-2
+ - Fn::Equals:
+ - Ref: AWS::Region
+ - ca-central-1
+ - Fn::Equals:
+ - Ref: AWS::Region
+ - cn-north-1
+ - Fn::Equals:
+ - Ref: AWS::Region
+ - cn-northwest-1
+ - Fn::Or:
+ - Fn::Equals:
+ - Ref: AWS::Region
+ - eu-central-1
+ - Fn::Equals:
+ - Ref: AWS::Region
+ - eu-north-1
+ - Fn::Equals:
+ - Ref: AWS::Region
+ - eu-south-1
+ - Fn::Equals:
+ - Ref: AWS::Region
+ - eu-west-1
+ - Fn::Equals:
+ - Ref: AWS::Region
+ - eu-west-2
+ - Fn::Equals:
+ - Ref: AWS::Region
+ - eu-west-3
+ - Fn::Equals:
+ - Ref: AWS::Region
+ - me-south-1
+ - Fn::Equals:
+ - Ref: AWS::Region
+ - sa-east-1
+ - Fn::Equals:
+ - Ref: AWS::Region
+ - us-east-1
+ - Fn::Equals:
+ - Ref: AWS::Region
+ - us-east-2
+ - Fn::Or:
+ - Fn::Equals:
+ - Ref: AWS::Region
+ - us-west-1
+ - Fn::Equals:
+ - Ref: AWS::Region
+ - us-west-2
+Parameters:
+ BootstrapVersion:
+ Type: AWS::SSM::Parameter::Value
+ Default: /cdk-bootstrap/hnb659fds/version
+ Description: Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]
+Rules:
+ CheckBootstrapVersion:
+ Assertions:
+ - Assert:
+ Fn::Not:
+ - Fn::Contains:
+ - - "1"
+ - "2"
+ - "3"
+ - "4"
+ - "5"
+ - Ref: BootstrapVersion
+ AssertDescription: CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI.
+
diff --git a/WebAPI/src/infra/src/Infra.sln b/src/infra/src/Infra.sln
similarity index 100%
rename from WebAPI/src/infra/src/Infra.sln
rename to src/infra/src/Infra.sln
diff --git a/src/infra/src/Infra/BaseInfraStack.cs b/src/infra/src/Infra/BaseInfraStack.cs
new file mode 100644
index 0000000..c229046
--- /dev/null
+++ b/src/infra/src/Infra/BaseInfraStack.cs
@@ -0,0 +1,38 @@
+namespace InfraSampleWebApp;
+
+public class BaseInfraStack : Stack
+{
+ public BaseStackProps BaseStackProps { get; private set; }
+
+ internal BaseInfraStack(Construct scope, string id, IStackProps props = null) : base(scope, id, props)
+ {
+ BaseStackProps = new()
+ {
+ Vpc = new Vpc(this, "demo-vpc", new VpcProps
+ {
+ IpAddresses = IpAddresses.Cidr("172.30.0.0/16"),
+ MaxAzs = 3
+ })
+ };
+
+ // ECS Cluster
+ BaseStackProps.Cluster = new Cluster(this, "demo-cluster", new ClusterProps
+ {
+ Vpc = BaseStackProps.Vpc,
+ ContainerInsights = true
+ });
+
+ BaseStackProps.Topic = new Topic(this, "Topic", new TopicProps
+ {
+ DisplayName = "Customer subscription topic",
+ TopicName = "demo-web-app-topic"
+ });
+
+ BaseStackProps.LogGroup = new LogGroup(this, "demo-log-group", new LogGroupProps
+ {
+ LogGroupName = BaseStackProps.LogGroupName,
+ Retention = RetentionDays.ONE_DAY,
+ RemovalPolicy = BaseStackProps.CleanUpRemovePolicy,
+ });
+ }
+}
diff --git a/src/infra/src/Infra/BaseStackProps.cs b/src/infra/src/Infra/BaseStackProps.cs
new file mode 100644
index 0000000..62989be
--- /dev/null
+++ b/src/infra/src/Infra/BaseStackProps.cs
@@ -0,0 +1,44 @@
+// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+// SPDX-License-Identifier: MIT-0
+
+
+namespace InfraSampleWebApp
+{
+ public class BaseStackProps : StackProps
+ {
+ ///
+ /// VPC and all base network infrastructure
+ ///
+ public Vpc Vpc { get; set; }
+
+ ///
+ /// ECS Cluster
+ ///
+ public Cluster Cluster { get; set; }
+
+ ///
+ /// SNS Topic
+ ///
+ public Topic Topic { get; internal set; }
+
+ ///
+ /// CW LogGroup name prefix
+ ///
+ public string LogGroupName { get; } = "/ecs/demo/ecs-fargate-dotnet-microservices";
+
+ ///
+ /// X-Ray Daemon Side Card Name
+ ///
+ public string XrayDaemonSideCardName { get; } = "xray-daemon";
+
+ ///
+ /// CloudWatch Agent Side Card Name
+ ///
+ public string CloudWatchAgentSideCardName { get; } = "cwagent";
+
+ //Note: For demo' cleanup propose, this Sample Code will set RemovalPolicy == DESTROY
+ //this will clean all resources when you cdk destroy
+ public RemovalPolicy CleanUpRemovePolicy { get; } = RemovalPolicy.DESTROY;
+ public ILogGroup LogGroup { get; internal set; }
+ }
+}
diff --git a/ServicesWorkerIntegration/src/infra/src/Infra/GlobalSuppressions.cs b/src/infra/src/Infra/GlobalSuppressions.cs
similarity index 84%
rename from ServicesWorkerIntegration/src/infra/src/Infra/GlobalSuppressions.cs
rename to src/infra/src/Infra/GlobalSuppressions.cs
index 2fbf037..ab3b90d 100644
--- a/ServicesWorkerIntegration/src/infra/src/Infra/GlobalSuppressions.cs
+++ b/src/infra/src/Infra/GlobalSuppressions.cs
@@ -4,3 +4,5 @@
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Potential Code Analyzer Warning", "CA1014:Mark assemblies with CLSCompliant", Justification = "")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Potential Code Analyzer Warning", "CA1506:.ctor' is ccoupled", Justification = "")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Potential Code Analyzer Warning", "CA1848:Use the LoggerMessage delegates", Justification = "")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Potential Code Analyzer Warning", "CS9057:references version", Justification = "")]
+
diff --git a/WebAPI/src/infra/src/Infra/InfraSampleWebApp.csproj b/src/infra/src/Infra/InfraSampleWebApp.csproj
similarity index 69%
rename from WebAPI/src/infra/src/Infra/InfraSampleWebApp.csproj
rename to src/infra/src/Infra/InfraSampleWebApp.csproj
index 0874e8a..9055d2a 100644
--- a/WebAPI/src/infra/src/Infra/InfraSampleWebApp.csproj
+++ b/src/infra/src/Infra/InfraSampleWebApp.csproj
@@ -2,7 +2,7 @@
Exe
- net6.0
+ net8.0
Major
true
@@ -11,8 +11,8 @@
-
-
+
+
@@ -20,7 +20,8 @@
-
+
\ No newline at end of file
diff --git a/src/infra/src/Infra/Program.cs b/src/infra/src/Infra/Program.cs
new file mode 100644
index 0000000..d7dbe0b
--- /dev/null
+++ b/src/infra/src/Infra/Program.cs
@@ -0,0 +1,38 @@
+// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+// SPDX-License-Identifier: MIT-0
+global using Amazon.CDK;
+global using System.Collections.Generic;
+global using System.IO;
+global using Amazon.CDK.AWS.EC2;
+global using Amazon.CDK.AWS.Ecr.Assets;
+global using Amazon.CDK.AWS.ECS;
+global using Amazon.CDK.AWS.ECS.MyExtensions;
+global using Amazon.CDK.AWS.ECS.Patterns;
+global using Amazon.CDK.AWS.Logs;
+global using Amazon.CDK.AWS.SNS;
+global using Constructs;
+global using Amazon.CDK.AWS.ApplicationAutoScaling;
+
+
+namespace InfraSampleWebApp
+{
+ sealed class Program
+ {
+ public static void Main(string[] args)
+ {
+ var app = new App();
+ var baseInfra = new BaseInfraStack(app, "BaseInfraStack", new StackProps { });
+
+ //Web App Stack
+ _ = new WebAppStack(app, "WebAppStack", baseInfra.BaseStackProps);
+
+ //Worker Db Stack
+ _ = new WorkerDbStack(app, "WorkerDbStack", baseInfra.BaseStackProps);
+
+ //Worker Integration Stack
+ _ = new WorkerIntegrationStack(app, "WorkerIntegrationStack", baseInfra.BaseStackProps);
+
+ app.Synth();
+ }
+ }
+}
diff --git a/src/infra/src/Infra/WebAppStack.cs b/src/infra/src/Infra/WebAppStack.cs
new file mode 100644
index 0000000..07a1342
--- /dev/null
+++ b/src/infra/src/Infra/WebAppStack.cs
@@ -0,0 +1,93 @@
+// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+// SPDX-License-Identifier: MIT-0
+namespace InfraSampleWebApp
+{
+ public class WebAppStack : Stack
+ {
+ internal WebAppStack(
+ Construct scope,
+ string id,
+ BaseStackProps props)
+ : base(scope, id, props)
+ {
+ //ECR
+ //Build docker image and publish on ECR Repository
+ var asset = new DockerImageAsset(
+ this,
+ "web-app-image", new DockerImageAssetProps
+ {
+ Directory = Path.Combine(Directory.GetCurrentDirectory(), "../SampleWebApp"),
+ File = "Dockerfile.arm",
+ Platform = Platform_.LINUX_ARM64,
+ }
+ );
+
+ //CloudWatch LogGroup and ECS LogDriver
+ var logDriver = LogDriver.AwsLogs(new AwsLogDriverProps
+ {
+ LogGroup = props.LogGroup,
+ StreamPrefix = "ecs/web-api"
+ });
+
+ var albFargateSvc = new ApplicationLoadBalancedFargateService(
+ this,
+ "demo-service",
+ new ApplicationLoadBalancedFargateServiceProps
+ {
+ Cluster = props.Cluster,
+ MemoryLimitMiB = 1024,
+ Cpu = 512,
+ DesiredCount = 3,
+ RuntimePlatform = new RuntimePlatform
+ {
+ CpuArchitecture = CpuArchitecture.ARM64
+ },
+ TaskImageOptions = new ApplicationLoadBalancedTaskImageOptions
+ {
+ Image = ContainerImage.FromDockerImageAsset(asset),
+ ContainerName = "web",
+ EnableLogging = true,
+ Environment = new Dictionary()
+ {
+ {"SNS_TOPIC_ARN", props.Topic.TopicArn },
+ {"AWS_EMF_LOG_GROUP_NAME", props.LogGroupName },
+ {"ASPNETCORE_HTTP_PORTS","80,443"},
+ },
+ LogDriver = logDriver,
+ },
+ }
+ );
+
+ //Autoscaling
+ var scalableTarget = albFargateSvc.Service.AutoScaleTaskCount(new EnableScalingProps
+ {
+ MinCapacity = 1,
+ MaxCapacity = 10,
+ });
+
+ scalableTarget.ScaleOnCpuUtilization("CpuScaling", new Amazon.CDK.AWS.ECS.CpuUtilizationScalingProps
+ {
+ TargetUtilizationPercent = 60
+ });
+
+ //Grant permission to Publish on the SNS Topic
+ props.Topic.GrantPublish(albFargateSvc.Service.TaskDefinition.TaskRole);
+
+ //Custom shared C# Library (reusability of code)
+ albFargateSvc.Service.TaskDefinition
+ .AddXRayDaemon(new XRayDaemonProps
+ {
+ XRayDaemonContainerName = props.XrayDaemonSideCardName,
+ LogDriver = logDriver
+ }).AddCloudWatchAgent(new CloudWatchAgentProps
+ {
+ AgentContainerName = props.CloudWatchAgentSideCardName,
+ LogDriver = logDriver,
+ });
+
+ //Level 1 Cfn Output
+ _ = new CfnOutput(this, "DemoServiceServiceURLEndpoint", new CfnOutputProps { Value = $"http://{albFargateSvc.LoadBalancer.LoadBalancerDnsName}/api/Books", ExportName = "DemoServiceServiceURLEndpoint" });
+
+ }
+ }
+}
diff --git a/src/infra/src/Infra/WorkerDbStack.cs b/src/infra/src/Infra/WorkerDbStack.cs
new file mode 100644
index 0000000..579fa0a
--- /dev/null
+++ b/src/infra/src/Infra/WorkerDbStack.cs
@@ -0,0 +1,134 @@
+// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+// SPDX-License-Identifier: MIT-0
+using Amazon.CDK.AWS.DynamoDB;
+using Amazon.CDK.AWS.SNS.Subscriptions;
+using Amazon.CDK.AWS.SQS;
+
+namespace InfraSampleWebApp;
+
+public class WorkerDbStack : Stack
+{
+ public WorkerDbStack(
+ Construct scope,
+ string id,
+ BaseStackProps props = null)
+ : base(scope, id, props)
+ {
+
+ //Create SQS for Worker APP that persist data on DynamoDb
+ var workerDbQueue = new Queue(this, "worker-db-queue", new QueueProps
+ {
+ QueueName = "worker-db-queue",
+ RemovalPolicy = props.CleanUpRemovePolicy
+ });
+
+ //Grant Permission & Subscribe SNS Topic
+ props.Topic.AddSubscription(new SqsSubscription(workerDbQueue));
+
+ //Create DynamoDb Table
+ var table = new Table(this, "Table", new TableProps
+ {
+ RemovalPolicy = props.CleanUpRemovePolicy,
+ TableName = "BooksCatalog",
+ PartitionKey = new Amazon.CDK.AWS.DynamoDB.Attribute
+ {
+ Name = "Id",
+ Type = AttributeType.STRING
+ },
+ Encryption = TableEncryption.AWS_MANAGED
+ });
+
+ //Configure AutoScaling for DynamoDb Table
+ IScalableTableAttribute readScaling = table.AutoScaleReadCapacity(
+ new Amazon.CDK.AWS.DynamoDB.EnableScalingProps
+ {
+ MinCapacity = 1,
+ MaxCapacity = 50
+ }
+ );
+ readScaling.ScaleOnUtilization(new UtilizationScalingProps
+ {
+ TargetUtilizationPercent = 75
+ });
+
+ //Build docker container and publish to ECR
+ var asset = new DockerImageAsset(this, "worker-db-image", new DockerImageAssetProps
+ {
+ Directory = Path.Combine(Directory.GetCurrentDirectory(), "../WorkerDb"),
+ File = "Dockerfile",
+ Platform = Platform_.LINUX_ARM64,
+ });
+
+ //Create logDrive to reuse the same AWS CloudWatch Log group created from the other Stack
+ var logDriver = LogDriver.AwsLogs(new AwsLogDriverProps
+ {
+ LogGroup = props.LogGroup,
+ StreamPrefix = "ecs/worker-db"
+ });
+
+ //Autoscaling
+ // See: https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-scaling-simple-step.html
+ var autoscalingSteps = new Amazon.CDK.AWS.ApplicationAutoScaling.ScalingInterval[]{
+ //Step adjustments for scale-out policy
+ new (){
+ Lower = 0,
+ Upper = 10,
+ Change = 0
+ },
+ new (){
+ Lower = 20,
+ Upper = null,
+ Change = 3
+ },
+ new (){
+ Lower = null,
+ Upper = -20,
+ Change = -3
+ },
+ };
+
+ //Level 3 Construct for SQS Queue processing
+ var queueFargateSvc = new QueueProcessingFargateService(
+ this, "queue-fargate-services-db",
+ new QueueProcessingFargateServiceProps
+ {
+ Cluster = props.Cluster,
+ Queue = workerDbQueue,
+ MinScalingCapacity = 1,
+ MaxScalingCapacity = 100,
+ ScalingSteps = autoscalingSteps,
+ Cpu = 256,
+ MemoryLimitMiB = 512,
+ RuntimePlatform = new RuntimePlatform
+ {
+ CpuArchitecture = CpuArchitecture.ARM64
+ },
+ Image = ContainerImage.FromDockerImageAsset(asset),
+ Environment = new Dictionary()
+ {
+ {"WORKER_QUEUE_URL", workerDbQueue.QueueUrl },
+ {"AWS_REGION", this.Region},
+ {"AWS_XRAY_DAEMON_ADDRESS",$"{props.XrayDaemonSideCardName}:2000" },
+ {"EMF_LOG_GROUP_NAME", props.LogGroup.LogGroupName }
+ },
+ LogDriver = logDriver,
+ });
+
+ //Grant permission to DynamoDB table and SQS to consume message from the Queue
+ table.GrantWriteData(queueFargateSvc.TaskDefinition.TaskRole);
+ table.Grant(queueFargateSvc.TaskDefinition.TaskRole, "dynamodb:DescribeTable");
+ workerDbQueue.GrantConsumeMessages(queueFargateSvc.TaskDefinition.TaskRole);
+
+ //Custom shared C# Library (reusability of code)
+ queueFargateSvc.Service.TaskDefinition
+ .AddXRayDaemon(new XRayDaemonProps
+ {
+ XRayDaemonContainerName = props.XrayDaemonSideCardName,
+ LogDriver = logDriver
+ }).AddCloudWatchAgent(new CloudWatchAgentProps
+ {
+ AgentContainerName = props.CloudWatchAgentSideCardName,
+ LogDriver = logDriver,
+ });
+ }
+}
diff --git a/src/infra/src/Infra/WorkerIntegrationStack.cs b/src/infra/src/Infra/WorkerIntegrationStack.cs
new file mode 100644
index 0000000..f8f342e
--- /dev/null
+++ b/src/infra/src/Infra/WorkerIntegrationStack.cs
@@ -0,0 +1,129 @@
+// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+// SPDX-License-Identifier: MIT-0
+using Amazon.CDK.AWS.IAM;
+using Amazon.CDK.AWS.S3;
+using Amazon.CDK.AWS.SNS.Subscriptions;
+using Amazon.CDK.AWS.SQS;
+
+namespace InfraSampleWebApp;
+
+public class WorkerIntegrationStack : Stack
+{
+ public WorkerIntegrationStack(
+ Construct scope,
+ string id,
+ BaseStackProps props = null)
+ : base(scope, id, props)
+ {
+
+ //SQS for Worker APP that persist data on s3
+ var workerIntegrationQueue = new Queue(this, "worker-integration-queue", new QueueProps
+ {
+ QueueName = "worker-integration-queue",
+ RemovalPolicy = props.CleanUpRemovePolicy,
+ Encryption = QueueEncryption.KMS
+ });
+
+ //Grant Permission & Subscribe
+ props.Topic.AddSubscription(new SqsSubscription(workerIntegrationQueue));
+
+ //S3 Bucket
+ var bucket = new Bucket(this, "demo-bucket", new BucketProps
+ {
+ Encryption = BucketEncryption.KMS,
+ EnforceSSL = true,
+ BlockPublicAccess = BlockPublicAccess.BLOCK_ALL,
+ RemovalPolicy = props.CleanUpRemovePolicy,
+ AutoDeleteObjects = true //Set to false for Real Env, this is only set for demo cleanup propose
+ });
+
+ //Build docker container and publish to ECR
+ var asset = new DockerImageAsset(
+ this,
+ "worker-integration-image",
+ new DockerImageAssetProps
+ {
+ Directory = Path.Combine(Directory.GetCurrentDirectory(), "../WorkerIntegration"),
+ File = "Dockerfile",
+ Platform = Platform_.LINUX_ARM64,
+ }
+ );
+
+ //Create logDrive to reuse the same AWS CloudWatch Log group created from the other Stack
+ var logDriver = LogDriver.AwsLogs(new AwsLogDriverProps
+ {
+ LogGroup = props.LogGroup,
+ StreamPrefix = "ecs/worker-integration"
+ });
+
+ //Autoscaling
+ // See: https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-scaling-simple-step.html
+ var autoscalingSteps = new Amazon.CDK.AWS.ApplicationAutoScaling.ScalingInterval[]{
+ //Step adjustments for scale-out policy
+ new (){
+ Lower = 0,
+ Upper = 10,
+ Change = 0
+ },
+ new (){
+ Lower = 20,
+ Upper = null,
+ Change = 3
+ },
+ //Step adjustments for scale-in policy
+ new (){
+ Lower = null,
+ Upper = -20,
+ Change = -3
+ }
+ };
+
+ //Level 3 Construct for SQS Queue processing
+ var queueFargateSvc = new QueueProcessingFargateService(
+ this,
+ "queue-fargate-services",
+ new QueueProcessingFargateServiceProps
+ {
+ Queue = workerIntegrationQueue,
+ MinScalingCapacity = 1,
+ MaxScalingCapacity = 100,
+ ScalingSteps = autoscalingSteps,
+ Cpu = 256,
+ MemoryLimitMiB = 512,
+ Cluster = props.Cluster,
+ RuntimePlatform = new RuntimePlatform
+ {
+ CpuArchitecture = CpuArchitecture.ARM64
+ },
+ Image = ContainerImage.FromDockerImageAsset(asset),
+ Environment = new Dictionary()
+ {
+ {"WORKER_QUEUE_URL", workerIntegrationQueue.QueueUrl },
+ {"WORKER_BUCKET_NAME", bucket.BucketName},
+ {"AWS_XRAY_DAEMON_ADDRESS",$"{props.XrayDaemonSideCardName}:2000" }
+ },
+ LogDriver = logDriver
+ });
+
+ //Grant permission to S3 Bucket and SQS to consume message from the Queue
+ bucket.GrantWrite(queueFargateSvc.TaskDefinition.TaskRole);
+ workerIntegrationQueue.GrantConsumeMessages(queueFargateSvc.TaskDefinition.TaskRole);
+
+ //Custom shared C# Library (reusability of code)
+ queueFargateSvc.Service.TaskDefinition
+ .AddXRayDaemon(new XRayDaemonProps
+ {
+ XRayDaemonContainerName = props.XrayDaemonSideCardName,
+ LogDriver = logDriver
+ }).AddCloudWatchAgent(new CloudWatchAgentProps
+ {
+ AgentContainerName = props.CloudWatchAgentSideCardName,
+ LogDriver = logDriver,
+ });
+
+ //Grant permission to write X-Ray segments
+ queueFargateSvc.Service.TaskDefinition.TaskRole
+ .AddManagedPolicy(ManagedPolicy.FromAwsManagedPolicyName("AWSXRayDaemonWriteAccess"));
+
+ }
+}
\ No newline at end of file