This is the way to build a production environment on AWS by turning a Ruby on Rails application created as a portfolio into a Docker container. The portfolio itself is here. [[Portfolio] Overview of the portfolio created during job change activities (Tec camp)] (https://qiita.com/sho_U/items/058e590325ee6833abb0)
I was suffering a lot, so I hope it helps someone.
|1||Docker containerization of Rails application in local environment|
|2||Create a VPC on AWS. Create a public subnet|
|3||Create a private subnet|
|4||Create an EC2 instance|
|5||Create an RDS|
|6||Upload Docker container to AWS|
I built an existing Ruby on Rails + MySQL application with Docker and created a database container in (1) to deploy it on AWS.
Actually, you can place an EC2 instance in a private subnet and a database container in it, but AWS has a service called RDS. Roughly speaking, RDS is an instance for a database that automatically configures it for increased availability and fault tolerance.
In addition, by arranging backup databases in different Availability Zones, even if a failure occurs in one database due to a disaster, etc., it can operate without problems. This is why I created two private subnets.
This time, we will create a database instance using this RDS.
First, create a subnet group that combines two private subnets.
Enter the RDS dashboard, select your subnet group, and click Create DB Subnet Group.
Add the two private subnets you just created to the subnet.
You have now created a subnet group with different Availability Zones, such as:
RDS does not directly touch the database settings, so set them in the parameter group.
The parameter group family matches the version of your development environment.
Enter the RDS dashboard, select an option group, and click Create Group.
Set the engine and major engine version according to the development environment.
Enter the RDS dashboard, select your database, and click Create Database. The following is a setting example. Please set according to your own operation.
Click "Create Database"
It's a little difficult to understand, but by connecting RDS with the subnet group and the security group for db as shown below,
The result is the following configuration.
You have now created an RDS instance.
Continue to next time (6) Upload Docker container to AWS (https://qiita.com/sho_U/items/a1b5e4ddf13f3c42a722)