https://github.com/superluminar-io/cdk-dotnet-example
Example project bootstrapping a CDK project with C#
https://github.com/superluminar-io/cdk-dotnet-example
api-gateway aws cdk cloud dotnet dynamodb lambda serverless
Last synced: about 1 month ago
JSON representation
Example project bootstrapping a CDK project with C#
- Host: GitHub
- URL: https://github.com/superluminar-io/cdk-dotnet-example
- Owner: superluminar-io
- License: mit
- Created: 2021-01-22T09:28:52.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-02-01T19:46:18.000Z (about 5 years ago)
- Last Synced: 2024-12-31T12:20:39.777Z (over 1 year ago)
- Topics: api-gateway, aws, cdk, cloud, dotnet, dynamodb, lambda, serverless
- Language: C#
- Homepage:
- Size: 293 KB
- Stars: 1
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CDK .NET Example
This is a simple example project bootstrapping a CDK project with C#.
## Prerequisites
* [NodeJS / NPM](https://nodejs.org/en/)
* [Docker](https://www.docker.com/)
* [Dotnet](https://dotnet.microsoft.com/download)
## Bootstrap
This project comes with a CD pipeline built-in. We have to bootstrap the pipeline once. After that, we can merge our changes to the main branch, and the pipeline will automatically deploy our application. In order to connect the pipeline with the GitHub repository, we need to store a [GitHub access token](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) in the [secrets manager](https://aws.amazon.com/secrets-manager/). The name of the secret is `CDK_DOTNET_EXAMPLE_GITHUB_TOKEN`.
After setting up the secret, we can initialize the pipeline. Make sure you have AWS credentials in your terminal.
```sh
$ git clone git@github.com:superluminar-io/cdk-dotnet-example
$ cd cdk-dotnet-example
# Install dependencies
$ npm i
# Bootstrap CDK in the target account
$ npx cdk bootstrap --cloudformation-execution-policies arn:aws:iam::aws:policy/AdministratorAccess
# Deploy the pipeline
$ npx cdk deploy PipelineStack
```
The pipeline should deploy your application. In CloudFormation, you should find a new `ApiStack`. Take the URL from the stack output and run the following requests:
```sh
# Create note
$ curl -X POST https://XXXXXXXXXX.execute-api.eu-central-1.amazonaws.com/notes --data '{ "title": "Hello World", "content": "Mollit adipisicing ut dolore aliqua." }' -H 'Content-Type: application/json'
# List notes
$ curl https://XXXXXXXXXX.execute-api.eu-central-1.amazonaws.com/notes
# Get note
$ curl https://XXXXXXXXXX.execute-api.eu-central-1.amazonaws.com/notes/:id
```
## Credits
* [AWS CDK Workshop](https://cdkworkshop.com/40-dotnet.html)
* [Lambda .NET Example](https://github.com/aws-samples/aws-cdk-examples/tree/master/csharp/capitalize-string)