Skip to content

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.

Notifications You must be signed in to change notification settings

mfkimbell/cloud-file-sharing-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cloud-file-upload

cloud file workflow

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

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

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="[email protected]",
)
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
display

This is the notification for new users: Screenshot 2023-09-29 at 1 00 21 PM


This is what is recieved when someone shares a file:

email

About

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published