This is an example showing how to deploy a Todo application integrated with RDS(MySql) on to multiple AZs.
- Here application and dataBase are deployed in different private subnets which are not directly accessible to outside world.
- Nat Gateway provides access to internet to the private subnets.
- For deploying application on to EC2 we need an AMI (Amazon Machine Image) which will be created using packer.
- To get high availability of Todo App, we deploy our Todo app to run on at least two Availability Zones (AZs) with auto-scaling group. The load balancer also needs at least 2 public subnets in different AZs.
-
Install AWS CLI
https://cloudaffaire.com/how-to-install-aws-cli/
-
Install Terraform
https://learn.hashicorp.com/tutorials/terraform/install-cli
-
Setup AWS credentials
https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html
- Deploy AWS stack
# Go to environment folder in which you want to deploy cluster
$ cd ./<account>/<region>/<envionment>
# Create VPC
$ terraform apply vpc
# Create RDS(MySql) cluster
$ terraform apply database/mysql/todo
# Create TODO AMI
$ cd ../../../packer/todo
$ ssh-keygen -t rsa -C "<email-address>" -f todo
$ terraform apply
# Create Todo App EC2 cluster
$ cd -
$ terraform apply services/todo/app
- Login to AWS console using your own credentials
- Click on services and then to EC2
- Under EC2 click on LoadBalancers
- Under LoadBalancers copy DNS Name
- Goto ->>
http://<ALB-DNS>/swagger-ui/
- Now you should see the swagger page for TODO application
- SSH Todo App EC2 instance(s)
# Add todo private key to key chain
$ ssh-add -k <todo_pem_file>
# Access the Bastion Host
$ ssh -i <bastion_pem_file> -A <bastion_user>@<basion_public_ip>
# Access the private instance
$ ssh springtodo@<todo_private_ip>
# Get status
$ sudo systemctl status todo
- AWS EBS (Elastic Block Storage)
- AWS EC2 (Elastic Compute Cloud)
- AWS RDS (Relational Database Service)
- AWS VPC (Virtual Private Cloud)
- AWS IGW (Internet GateWay)
- AWS ALB (Application Load Balancer)
- AWS ASG (Auto Scaling Group)
- AWS NAT (Network Address Translation)
- AWS SG (Security Group)
- AWS AMI (Amazon Machine Image)