https://github.com/mfkimbell/cloud-file-sharing-service
AWS Application that utilizes lambda to allow for users to sign up for and use a cloud file sharing service through SNS. It also manages a MySQL database to track users.
https://github.com/mfkimbell/cloud-file-sharing-service
aws aws-lambda boto3 ec2 flask iam mysql rds s3 ses sns
Last synced: 2 months ago
JSON representation
AWS Application that utilizes lambda to allow for users to sign up for and use a cloud file sharing service through SNS. It also manages a MySQL database to track users.
- Host: GitHub
- URL: https://github.com/mfkimbell/cloud-file-sharing-service
- Owner: mfkimbell
- Created: 2023-07-24T21:13:59.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-12-02T06:23:00.000Z (over 2 years ago)
- Last Synced: 2025-01-22T22:31:22.802Z (over 1 year ago)
- Topics: aws, aws-lambda, boto3, ec2, flask, iam, mysql, rds, s3, ses, sns
- Language: Python
- Homepage:
- Size: 119 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# cloud-file-upload

In this application, a user can
create an account and upload a profile picture. This will save their information on RDS in a MySQL database, it will then send an email to my personal email telling me a user has created an account. A user can enter their credentials and allow them to login to the main webapp. A user can then select up to 5 emails to upload a file to. Each address will recieve an email with a link that allows them to download the uploaded file from S3.
---
# Tools Used:
* `Flask` Used to operate the webserver
* `Boto3` Python SDK used to connecto to S3 buckets and Lambda functions (can do other aws services)
* `S3` Store profile pictures and uploaded files
* `AWS Lambda` Calls SNS and SES functions
* `SNS` Sends email to webpage owner when new account is created
* `SES` Sends file download link to specified emails
* `MySQL/RDS` Store user credentials, profile pictures, and file uploads
* `EC2` Host Flask WebServer/application
* `IAM` Set access and identity permissions that we use when connecting with Boto3
---
When people access the application, they can only add files if they've added credentials to the MySQL database in AWS RDS. Anyone can connect, as by default, the "/add" route has permissions built into it to add a username and password to S3, my email is alerted after the function is invoked.
### lambda function: lambdaSNS
``` python
import boto3
def lambda_handler(event, context):
ACCESS_KEY = "AKIA3SR6ZX6FT4OAXVPJ"
SECRET_KEY = "*******************"
AWS_REGION = "us-east-1"
email = event.get("email")
sns_client = boto3.client(
"sns",
region_name=AWS_REGION,
aws_access_key_id=ACCESS_KEY,
aws_secret_access_key=SECRET_KEY,
)
# do i need aws_access_key_id = ACCESS KEY or SECRET_KEY
sns_client.publish(
TopicArn="arn:aws:sns:us-east-1:795774402443:mksns",
Message="New user Added: " + email,
Subject="New User",
)
```
---
After that, they can use the "/login" route, which allows the user to input data and call the "/uploadSend" endpoint. This stores data in s3, keeps track of the file name in the MySQL database, and invokes my lambda function "lambdaSendFileLink" which sends an email to the entered emails that contains a link.
### lambda function: lambdaSendFileLink
``` python
import boto3
import json
ACCESS_KEY = "AKIA3SR6ZX6FT4OAXVPJ"
SECRET_KEY = "********************"
AWS_REGION = "us-east-1"
def lambda_handler(event, context):
ACCESS_KEY = "AKIA3SR6ZX6FT4OAXVPJ"
SECRET_KEY = "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"
AWS_REGION = "us-east-1"
emails = event.get("email")
botoS3 = boto3.client(
"s3",
region_name=AWS_REGION,
aws_access_key_id=ACCESS_KEY,
aws_secret_access_key=SECRET_KEY,
)
botoSES = boto3.client("ses", region_name="us-east-1")
key = event.get("filename")
bucket = "mkcloudbucket"
url = f"https://{bucket}.s3.amazonaws.com/{key}"
response = botoSES.send_email(
Destination={"ToAddresses": emails},
Message={
"Body": {
"Text": {
"Charset": "UTF-8",
"Data": "Your file is ready to download: " + url,
}
},
"Subject": {
"Charset": "UTF-8",
"Data": "Test email",
},
},
Source="mkimbell@uab.edu",
)
print(response)
return {
"statusCode": 200,
"body": json.dumps(
"Email Sent Successfully. MessageId is: " + response["MessageId"]
),
}
```
---
1. Main page login
2. Create account page
3. File upload app page

---
This is the notification for new users:

---
This is what is recieved when someone shares a file: