This project is to create a presigned url to upload files to s3 directory. Whole stack will be created using AWS SAM.
Architecture is as follows:
- Need to have sam cli and npm installed
- Within the backend directory, run:
sam build
sam deploy -g
- Parameter SnsNotificationEmail : Add an email address to recieve SNS notification from uploaded file processed events
- This will create:
- S3 bucket for static web site hosting
- S3 bucket to upload files
- Lambda function to generate pre-signed url
- API gateway to trigger above lambda
- Lambda function to trigger when file is uploaded into the S3 bucket
- Lambda destination SNS topic for above function when success
- Lambda destination SNS topic for above function when failed
** While creating the stack, you will receive two emails to subscribe to above sns topics. Confirm the subscriptions.
Once the stack is created, note the values of below outputs:
S3WebsiteURL
- This will be the final url to access the system.S3WebsiteBucket
- S3 bucket for static website contents.S3FileUploadBucket
- S3 bucket to store the uploaded filesPresignedUrlApi
- API endpoint to generate the presigned url.
-
Go to the frontend directory. Update the variable
VUE_APP_GENERATE_URL
in the .env file with the value ofPresignedUrlApi
. -
Run below commands to install dependancies and build the frontend
npm install
npm run build
This will generate the project files to deploy in the dist
directory.
- To copy the built contents to s3, run:
aws s3 cp dist s3://<S3WebsiteBucket> --recursive
-
Access the web site using the
S3WebsiteURL
value. -
Upload a file and you should receive a sns notification to the given email.
- First remove the data in the both s3 buckets:
aws s3 rm s3://<S3FileUploadBucket> --recursive
aws s3 rm s3://<S3WebsiteBucket> --recursive
- Then run:
aws cloudformation delete-stack --stack-name <Stack Name>