dotnet infrastructure implementation
January 2, 2024 · View on GitHub
Project structure
├── infrastructure-dotnet # Infrastructure code via CDK (NET8).
│ ├── src #
| | ├── Infrastruture # CDK App - Deploys the stacks
| | | ├── Dockerfile # Dockerfile containing the build container definition
└─────── ... # Lambda handler implementations
This project contains the C# version for both infrastructure and lambda handlers. While the CDK project uses dotnetcore3.1, the Lambda handlers are using and running in a NET8 environment. The Lambda build happens in a Docker container, and generates a single executable (bootstrap) that runs in a custom lambda runtime.
The cdk.json file tells the CDK Toolkit how to execute your app.
Deployment
- Bootstrap your AWS account as it's required for the automated Docker image build and deployment
cdk bootstrap aws://{ACCOUNT_ID}/{REGION}
- Synthesize the cdk stack to emits the synthesized CloudFormation template. Set up will make sure to build and package the lambda functions residing in the handlers directory.
cdk synth
- Deploy the CDK application
cdk deploy --all
It uses the .NET Core CLI to compile and execute your project.
Useful commands
dotnet build srccompile this appcdk deploydeploy this stack to your default AWS account/regioncdk diffcompare deployed stack with current statecdk synthemits the synthesized CloudFormation template