Terraform in AWS
-
Now we need to create a database instance in aws
-
To create a database
- we need to create a db subnet group which specifies database subnets
- We need to create a rds db instance with mysql/postgres/oracle/sqlserver.
- In this series i will be creating a mysql based rds instance
-
Manual Steps:
- Create a db subnet group
- Create a db subnet group
-
Terraform:
- Lets create a new file called as rds.tf
- The resource for db subnet group Refer Here
- Refer Here for the changeset
-
Now we need to create a db instance. Manual Steps are shown below
-
Now lets try to create a db instance from terraform provider documentation. Refer Here
-
Refer Here for the changes added to create rds instance
-
Now we are supposed to create ec2 instances in app subnet and web subnet
-
Lets refactor the terraform template so that we have network.tf to create network elements , rds.tf to create database elements
-
Since having one large network.tf is not readable lets create multiple tf files
-
Refer Here for the changeset
-
So we need to create ec2 instance in web subnet and install required softwares and deploy the application and same scenario for app subnet
-
So this is just not creation of resource, we need to login into vm’s (ec2 instances) from terraform and execute the application deployment script (shell script/Chef cookbook/Ansible)
-
The above operations are referred as provisioning
