This is an example of a Next.js application allowing you to upload photos to an S3 bucket.
Getting Started
Option 1: Use an existing S3 bucket.
Retrieve your existing access key, secret key, S3 bucket region and name. Provide those values after clicking "Deploy" to automatically set the environment variables.
Option 2: Create an S3 bucket.
Create a new IAM role with permission for AWSCloudFormationFullAccess and AmazonS3FullAccess.
leerob/nextjs-aws-s3
Next.js + AWS S3 Upload
This is an example of a Next.js application allowing you to upload photos to an S3 bucket.
Getting Started
Option 1: Use an existing S3 bucket.
Retrieve your existing access key, secret key, S3 bucket region and name. Provide those values after clicking "Deploy" to automatically set the environment variables.
Option 2: Create an S3 bucket.
AWSCloudFormationFullAccess
andAmazonS3FullAccess
.aws configure
..env.local
file similar to.env.example
.cdk deploy
to create an S3 bucket with the correct CORS settings..env.local
.yarn dev
to start the Next app atlocalhost:3000
..png
or.jpg
file.This example uses
createPresignedPost
instead ofgetSignedUrlPromise
to allow setting max/min file sizes withcontent-length-range
.Commands
yarn dev
– Starts the Next.js app atlocalhost:3000
.cdk deploy
– Deploy this stack to your default AWS account/regioncdk diff
– Compare deployed stack with current statecdk synth
– Emits the synthesized CloudFormation template