Jakub Sokołowski
55e4630222
NodeJS 8.10 is approaching End-of-life and AWS Lambda will stop supporting it at the end of 2019. Signed-off-by: Jakub Sokołowski <jakub@status.im> |
||
---|---|---|
ansible | ||
files | ||
modules | ||
.gitignore | ||
Makefile | ||
README.md | ||
ansible.cfg | ||
backup.tf | ||
dev.tf | ||
mail.tf | ||
main.tf | ||
outputs.tf | ||
prod.tf | ||
ses.tf | ||
smtp.tf | ||
variables.tf | ||
versions.tf |
README.md
Description
This repo configures infrastructure for the https://dap.ps/ service.
The service is split into two stages:
prod
- https://prod.dap.sp/dev
- https://dev.dap.ps/
The prod
environment is CNAME
ed to dap.ps
domain.
Technical Details
The infrastructure is hosted on AWS and consists of 5 main elements:
- ELB - Load balancers
- EB - Node.js App hosting
- EC2 - MongoDB cluster
- S3 - MongoDB backups & Terraform state
- SES - Mail forwarding
All the AWS parts are provisioned and managed with Terraform and the MongoDB cluster configured with Ansible.
The only part that is not AWS is Gandi DNS provider due to AWS Route53 not supporting the .ps
TLD.
Usage
Creation of both dev
and prod
stages is as simple as:
terraform init
terraform apply
And then configure the MongoDB hosts using ansible:
ansible-playbook ansible/dev.yml
ansible-playbook ansible/prod.yml
Known Issues
- The ElasticBeanstalk environments can fail when being recreated
- This is mostly due to AWS being slow at destorying resources and their race conditions
- There is no easy way of making ElasticBeanstalk spread geographically
- The only way seems to have multiple EB environments linked via ELB
TODO
- #4 - [prod] Geographically spread hosts
- #11 - [prod] MongoDB Web UI
- #13 - [prod] Stress test infrastructure
Links
These helped me during work on this setup:
- https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3.html
- https://aws.amazon.com/getting-started/tutorials/deploy-app-command-line-elastic-beanstalk/
- https://medium.com/@vygandas/how-to-deploy-your-nodejs-app-on-amazon-elastic-beanstalk-aws-eb-with-circleci-short-tutorial-d8210d2a7f0c
- https://realpython.com/deploying-a-django-app-to-aws-elastic-beanstalk/