Small demo project on how one could set up serverless C# (.NET 6, ARM architecture) functions on AWS.
The infrastructure is simply an API Gateway with two functions behind it, for adding and getting books from DynamoDB.
It also contains:
- Serverless Framework to deploy your application
- VS Code configuration files to run tasks for building and testing
- A demo test using XUnit
- Also: [Amazon.Lambda.TestTool] support as a launch task, but there's something wonky going on with the JSON serializer...
Note that this project has been created and run in a MacOS 13 environment and Windows compatibility is not guaranteed.
This assumes you have a recent Node version (19+) and Dotnet stuff installed already.
See:
Run npm install
to install Node dependencies.
The only real usage for Node here is to keep the dependency on Serverless Framework explicit and localized. You might want to simply do a global install of it instead, if you prefer.
Set your own values in serverless.yml
for custom.awsAccountNumber
.
Run npm test
or the Bash script scripts/test.sh
. You can also use the VS Code task.
Run npm test
or the Bash script scripts/test.sh
. You can also use the VS Code task (Mac shortcut: CMD + SHIFT + B).
Run npm run deploy
or the Bash script scripts/deploy.sh
. You can also use the VS Code task.
Run npm run teardown
or the Bash script scripts/teardown.sh
.
Make sure to substitute RANDOM
and REGION
with your own values.
Add a book with:
curl https://RANDOM.execute-api.REGION.amazonaws.com/book -X POST -d '{"name":"The new book", "year": 2023}' -H 'Content-Type: application/json'
And get it with:
curl https://RANDOM.execute-api.REGION.amazonaws.com/book -d '{"name":"The new book"}' -H 'Content-Type: application/json'