Skip to content

Commit

Permalink
Fixed actions failure and added Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhankarunhale committed Jul 25, 2024
1 parent 3f8f425 commit 3c5b79a
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 18 deletions.
33 changes: 15 additions & 18 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
93 changes: 93 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit 3c5b79a

Please sign in to comment.