A cloud native REST API using C# for both runtime code and for IaC. All AWS infrastructure (see diagram below) is provisioned using AWS CDK.
Prerequisites:
Our Lambdas are using DynamoDB and we will use the temporary stacks in dev environment for debugging. Once feature development is completed, stack can be deleted.
Follow the next steps in order to run the lambdas locally:
- Publish Lambdas (their assemblies will be pushed into S3):
dotnet publish ./src/Lambda.AddTransaction/Lambda.AddTransaction.csproj -o ./iac/Assets/Lambda.AddTransaction
dotnet publish ./src/Lambda.GetTransaction/Lambda.GetTransaction.csproj -o ./iac/Assets/Lambda.GetTransaction
dotnet publish ./src/Lambda.DeleteTransaction/Lambda.DeleteTransaction.csproj -o ./iac/Assets/Lambda.DeleteTransaction
dotnet publish ./src/Lambda.UpdateTransaction/Lambda.UpdateTransaction.csproj -o ./iac/Assets/Lambda.UpdateTransaction
dotnet publish ./src/Lambda.PartialUpdateTransaction/Lambda.PartialUpdateTransaction.csproj -o ./iac/Assets/Lambda.PartialUpdateTransaction
cd iac
- Synthesize CDK stack
cdk ls -c environment=dev-<user|feature>
- Deploy
cdk deploy --all --require-approval never -c environment=dev-<user|feature>
- Deployed stack output contains AccessKey and SecretKey, which are short lived and only created for dev env for debugging purposes in order to gain permission to real DynamoDB service. Please save the following as environment variables:
Environment variable name | Value |
---|---|
AWS_Local__AccessKey | < value from cfn output > |
AWS_Local__SecretKey | < value from cfn output > |
AWS_Local__Region | < value from cfn output > |
DynamoDB__Transactions__TableName | < value from cfn output > |
- To debug please use Lambdas.RunningLocally UnitTest project.
Delete stack from dev environment:
cdk destroy -c environment=dev-<user|feature>
Please note that for dev env DynamoDB table will be removed.
Unit tests are located in /tests/*.UnitTests
folders. You can run them from VisualStudio or using cli dotnet test <Unit Test Project>.csproj
.
Acceptance tests
cd /tests/Acceptance.Tests
npm test
In order to deploy to QA/PROD please use the following actions: