From 3c5b79a94c632e6a4a318eb84f329541ff98dae0 Mon Sep 17 00:00:00 2001 From: shubhankarunhale <55907988+shubhankarunhale@users.noreply.github.com> Date: Wed, 24 Jul 2024 23:22:37 -0500 Subject: [PATCH] Fixed actions failure and added Readme --- .github/workflows/main.yml | 33 ++++++-------- README.md | 93 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+), 18 deletions(-) create mode 100644 README.md diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3ac473b..90e9016 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,55 +29,52 @@ jobs: - name: Debug List files run: ls -al - - name: Install frontend dependencies - run: | - npm install - working-directory: ./frontend - - name: Install backend dependencies run: | + cd cdk npm install - working-directory: ./cdk - name: Synthesize CDK run: | + cd cdk export FRONTEND_STACK_EXPORTS_AVAILABLE=false npx cdk synth - working-directory: ./cdk - name: Deploy BackendStack run: | + cd cdk npx cdk deploy BackendStack --require-approval never - working-directory: ./cdk - name: Get API Gateway URL id: get-url run: | api_url=$(aws cloudformation list-exports --query "Exports[?Name=='ApiGateway'].Value" --output text) - echo "API_URL=${api_url}" - echo "REACT_APP_API_GATEWAY_URL=${api_url}" > frontend/.env echo "API_URL=${api_url}" >> $GITHUB_ENV - working-directory: ./frontend + echo "REACT_APP_API_GATEWAY_URL=${api_url}" > frontend/.env - - name: Debug Print .env file contents + - name: Print .env file contents run: | - ls -al frontend - cat frontend/.env || echo ".env file not found" - working-directory: ./frontend + cd frontend + cat .env + + - name: Install frontend dependencies + run: | + cd frontend + npm install - name: Build frontend run: | + cd frontend export BUILD_PATH=../cdk/resources/build npx react-scripts build - working-directory: ./frontend - name: Deploy FrontendStack run: | + cd cdk npx cdk deploy FrontendStack --require-approval never - working-directory: ./cdk - name: Deploy BackendStack with exports available run: | + cd cdk export FRONTEND_STACK_EXPORTS_AVAILABLE=true npx cdk deploy BackendStack --require-approval never - working-directory: ./cdk diff --git a/README.md b/README.md new file mode 100644 index 0000000..236d939 --- /dev/null +++ b/README.md @@ -0,0 +1,93 @@ +# AWS-S3-Secure-File-Manager-Starter + +**AWS-S3-Secure-File-Manager-Starter** is a boilerplate starter code for a serverless file management application using AWS services. This application demonstrates secure and efficient file uploads using presigned URLs, enabling scalable and cost-effective file management. + +## Features + +- **Secure File Uploads**: + - **Least Privilege Principle**: Presigned URLs grant temporary, limited access for file uploads, minimizing risk and exposure. + - **No Lambda Permissions Needed**: Uploads are handled directly by S3, reducing Lambda's role and associated security risks. + +- **Scalable Architecture**: + - **Direct Upload to S3**: Clients upload files directly to S3, bypassing Lambda and enhancing scalability and performance. + +- **Performance Optimization**: + - **Faster Uploads**: Bypassing Lambda for uploads reduces latency and improves performance. + +- **Cost Efficiency**: + - **Reduced Lambda Execution Time**: Minimizes compute resource usage and costs by handling uploads directly through S3. + +- **Simplicity and Flexibility**: + - **Client-Side Control**: Customizable upload parameters and control directly from the client application. + +## How It Works + +1. **Generating Presigned URLs**: + - Your backend generates presigned URLs using AWS SDKs. These URLs are temporary and scoped to specific S3 operations. + +2. **Client-Side Upload**: + - The React frontend receives the presigned URL and uses it to upload files directly to S3 via HTTP PUT or POST requests. + +3. **Security and Validation**: + - AWS validates the presigned URL parameters, ensuring that only authorized uploads are accepted. + +## Example Use Case + +**Scenario**: Uploading user-generated files to an S3 bucket. + +**Implementation**: Lambda functions generate presigned URLs for each upload request. + +**Advantages**: +- Simplified architecture +- Reduced Lambda execution time and costs +- Enhanced security with temporary, scoped access + +## Getting Started + +To set up the project locally: + +1. **Clone the Repository**: + ```bash + git clone https://github.com/yourusername/AWS-S3-Secure-File-Manager-Starter.git + cd AWS-S3-Secure-File-Manager-Starter + ``` + +2. **Install Dependencies**: + + - **For the frontend**: + ```bash + cd frontend + npm install + cd .. + ``` + + - **For the backend (CDK)**: + ```bash + cd cdk + npm install + ``` + +3. **Configure AWS CLI**: + Ensure AWS CLI is configured with your credentials: + ```bash + aws configure + ``` + +4. **Deploy the Application**: + - Run the deployment script: + ```bash + ./deploy.sh + ``` + +5. **Run the Application Locally**: + - Start the frontend: + ```bash + cd frontend + npm start + ``` + + - Open [http://localhost:3000](http://localhost:3000) in your browser. + +## License + +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.