- Python 3.8 and above
- Pip
- pipenv
- clone this project
- navigate to project folder and run '$pipenv shell' (make sure to use the correct pipenv python version!)
- next, '$ pipenv install'
Once the package has been installed we can move on to the next step
- Create a MySQL DB instance in AWS RDS (t2.micro is more than enough)
- Enter any instance identifier
- Enter the Database username and password (make sure to remember this!)
- Leave everything as default, make sure to set the DB VPC to default for convenience
- Next, click the Additional Configuration dropdown, enter an initial database name (remember this as well!)
- Leave everything as default and create the database!
- Next, navigate to 'Security Groups' under EC2 service and add an inbound rule for MySQL
- Just allow every source for now (0.0.0.0) for convenience, then save the rule!
- Create a S3 Bucket with any name
- Allow public access and enable website hosting.
- Under the permission tab, add the following policy to bucket permission (change [your-bucket-name-here] to your bucket name
{
"Version":"2012-10-17",
"Statement":[{
"Sid":"PublicReadGetObject",
"Effect":"Allow",
"Principal": "*",
"Action":["s3:GetObject"],
"Resource":["arn:aws:s3:::[your-bucket-name-here]/*"
]
}
]
}
Currently looking for a better solution...
- Open the
ddac_project
folder, within thesettings.py
file, append the database credentials to theDATABASES
variable - After that, navigate to the project folder in the terminal and run
pipenv shell
(make sure to be in root directory) - Run the following:
python manage.py migrate
- Create a super user now
python manage.py createsuperuser
- Once successful, change the database credentials to the following:
- Once complete, we can start deployment with Zappa
NAME
- the database nameUSER
- the database usernamePASSWORD
- the database passwordHOST
- the database hostname (url)PORT
- the database port (usually 3306)NAME
- os.environ['NAME']
USER
- os.environ['USER']
PASSWORD
- os.environ['PASSWORD']
HOST
- os.environ['HOST']
PORT
- os.environ['PORT']
- delete the
zappa_settings.json
file if exists - back in the terminal, run the following
zappa init
, and follow the wizard - once the wizard is compelete, run the following
zappa deploy dev
- don't worry about 500/502 error shown by zappa for now, we will fix it
- Before fixing the error, grab the API Gateway URL (ex. ******.execute-api.us-east-1.amazonaws.com), append the URL to
settings.py
ALLOWED_HOSTS
- Next, visit Lambda service in the AWS Dashboard, and select the project function.
- Under the configuration tab -> environment variables, add the respective environment variables (ex. key: NAME, value: DATABASE_NAME)
- once that is settled, go back to the terminal and update the deployment using the following
zappa update [zappa-name]
too lazy to write script, so...
copy the whole content within the frontend folder and just dump it to your S3 bucket
one last thing, go to index.js
file, change the API_URL
to your API Gateway url
finally, just visit your s3 website hosting url and done.