-
Notifications
You must be signed in to change notification settings - Fork 9
DrFujiBot on AWS
EverOddish edited this page Jan 16, 2023
·
5 revisions
- Edit
~/.aws/credentials
to add access key in new profile namedpchal
cd DrFujiBot_Django
eb init --profile pchal
- Open
DrFujiBot_Django/settings.py
and verify thatlocal
is set toFalse
- Edit
.ebextensions/db-migrate.config
to uncomment the02_createsuperuser
block -
eb create drfujibot-env
(creates environment and uploads source) - Edit
DrFujiBot_Django/settings.py
to add the environment URL toALLOWED_HOSTS
- In the AWS Console, open the new environment, click "Configuration", then find "Database" and click "Edit"
- Engine: postgres
- Engine version: 14.5
- Instance class: db.t4g.micro
- Storage: 5 (GB)
- Availability: Low (one AZ)
- Database retention policy: Retain
- Run
eb deploy
with updatedALLOWED_HOSTS
- Click "Clusters" and then "Create cluster", all default settings (Fargate)
- Click "Amazon ECR" on the left, create a repository ("Get started"), private, name "drfujibot"
- Open the new repository and click "View push commands"
- Copy and run the
aws ecr
command to log in withdocker
, and include--profile pchal
in the copiedaws ecr
command -
cd DrFujiBot_IRC
and./build_image.sh
to build and push to ECR - Go back to ECS, then Task Definitions on the left, then "Create new task definition"
- Task definition family: DrFujiBot
- Container name: DrFujiBotIRC
- Image URI: (image URI from ECR)
- Remove any port mappings
- Set environment variables:
DJANGO_URL
TWITCH_OAUTH_TOKEN
TWITCH_CHANNEL
- App environment: AWS Fargate (serverless)
- Operating system: Linux/X86_64
- CPU: .5 vCPU
- Memory: 1 GB
- Uncheck "Use log collection"
- Go back to ECS, then Services, then Deploy
- Compute options: Launch type
- Launch type: FARGATE
- Platform version: Latest
- Application type: Service
- Desired tasks: 1
Need to add an inbound rule on the Elastic Beanstalk security group to allow the IP address from which you run psql
pg_dump -U drfujibot -h localhost -f /home/everoddish/fuji_backup/drfujibot2.sql drfujibot
psql --host=<instance>.us-east-2.rds.amazonaws.com --port=5432 --username=drfujibot --dbname=ebdb --password < ~/fuji_backup/drfujibot2.sql