This repo contains an AWS Serverless application using CDK to define the Infrastructure, written in C#. This defines an application that will deploy a website, API and simple cataloguing code to allow images to be uploaded via an API and then shown in a simple website.
- User uploads an image to the API via a POST
- API Gateway directly PUT's this to S3
- An S3 Event fires a Lambda
- The Lambda moves the file to a dated folder in the Web Bucket
- The user browses to a CloudFront hosted website that is backed by the Web Bucket
- The website does an API request to the API to get the categories (dated folders)
- API Gateway uses a Lambda to get this list
- The user browses to a folder
- The website does an API request to the API to get the images in that category
- API Gateway uses a Lambda to get the image list
- The website renders the list of images via the CloudFront CDN
The cdk.json
file tells the CDK Toolkit how to execute your app.
It uses the .NET Core CLI to compile and execute your project.
dotnet build src
compile this appcdk deploy
deploy this stack to your default AWS account/regioncdk diff
compare deployed stack with current statecdk synth
emits the synthesized CloudFormation template
curl --data-binary '@example-images/face.png' https://YOURGATEWAYID.execute-api.eu-west-1.amazonaws.com/prod/image/face.png
To use the website then please update the gallery.js file to include the correct ID of your API Gateway.
Beware! For a production environment then the API would have authentication - do not leave this deployed as it can be abused and could cost you money if large files are uploaded. It is an example only.