📔
ServerlessDocs - Serverless File Service
  • Introduction
  • Why Serverless!!
  • Prerequisites
  • User Management
    • Authentication
    • Amazon Cognito
    • Create the User Pool
    • Create an App Client
    • Integrate the app with Cognito User Pool
    • Create the Identity Pool
    • Validate the setup
    • Troubleshooting
  • Manage Documents with AWS S3
    • Authorization
    • Update Cognito Identity Pool Auth Role
    • S3 Documents Bucket Folder Structure
    • Validate the Access Permissions
    • Public and Private files access
    • Upload Files to S3
    • Download Files
    • Delete Files
    • Share Files
  • More Security Configurations
    • Cognito user emails
    • Password policies
    • Allow only Organization and Whitelisted users to Signup
    • Allow admin users to upload Public files
    • Notify Admin users when a new user signup
    • Enable Multi-factor Authentication (MFA)
  • User Operations
    • Password Reset / Forgot Password
    • Resend Verification Code
  • Serverless APIs
    • APIs
    • Secure APIs using API Gateway Authorizer
    • Access Cognito values in Lambda function
    • Authorize APIs with OAuth 2 Scope
    • Fine-grained Access with AssumeRole
    • Notify Admin users on large file uploads
    • Generate a Month-To-Date Usage report
  • Source Code and Setup
    • Source Code
    • IAM Policies
    • S3 Bucket Policies
    • Suggestions / Feedback
    • More References
  • Deployment
    • AWS SAM
    • Serverless Framework
  • Contributors
    • Team
Powered by GitBook
On this page

Was this helpful?

Prerequisites

PreviousWhy Serverless!!NextAuthentication

Last updated 4 years ago

Was this helpful?

The front-end source code available here. I am using Vanilla JavaScript so that it would be easy for anyone to get started. I will put the followup updates on React and Angular in the future.

Copy the front-end code to an S3 bucket in your account. Make sure you Do not block public acccess of the bucket. Once the code is moved, apply the Public Read policy as mentioned below.

WebApp Bucket Policy for Public Access

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicReadGetObject",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::<your S3 bucket>/*"
        }
    ]
}

Create another S3 bucket to store all the file uploads. Update the CORS configurations for the files bucket as per below.

Keep your files buckets as private and secure. You can block public access of the bucket to make sure no accidental configuration override.

Files Bucket CORS Configuration

<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
    <AllowedOrigin>*</AllowedOrigin>
    <AllowedMethod>GET</AllowedMethod>
    <AllowedMethod>POST</AllowedMethod>
    <AllowedMethod>DELETE</AllowedMethod>
    <AllowedMethod>PUT</AllowedMethod>
    <AllowedHeader>*</AllowedHeader>
    <ExposeHeader>ETag</ExposeHeader>
</CORSRule>
</CORSConfiguration>

Make sure you create Web Hosting and Document Storage buckets in the same region.

Quick test

If you open the application in your browser now, it will show that the Cognito Pool and Client is not configured.

GitHub - AppGambitStudio/serverless-docs: Serverless Document Management SystemGitHub
Logo
Basic setup is running with no configurations