RDS
AWS RDS stands for relational database service. It provides various databases as a managed service. For example, it includes support for Oracle, MySQL, MariaDB, and other similar relational databases. Since it is a managed service, RDS provides easy replication of the instances and takes snapshots automatically. Sometimes it is required to apply security updates to your database, this is also supported by RDS where you can schedule these tasks as needed. Another important feature of RDS is that it is possible to vertically scale up or down the database instances at any time. For example, when you want to update your instance with more CPU power, you can simply upgrade to a newer instance type in there.
Creating a RDS instance includes few steps,
A subnet group is required to specify which subnet the database will be located in.
A parameter group is required to provide settings to the database. Usually we don't get access to the database instance and therefore this provides a way of defining database configurations and settings.
A security group is required to control access rights to the RDS instance.
First, let's create a file to keep our variables; vars.tf,
variable "AWS_REGION" {
default = "eu-west-1"
}
variable "PATH_TO_PRIVATE_KEY" {
default = "mykey"
}
variable "PATH_TO_PUBLIC_KEY" {
default = "mykey.pub"
}
variable "AMIS" {
type = map(string)
default = {
us-east-1 = "ami-13be557e"
us-west-2 = "ami-06b94666"
eu-west-1 = "ami-844e0bf7"
}
}
variable "RDS_PASSWORD" {
}Then a filed named provider.tf,
Then a file named vpc.tf,
Then a filed named instance.tf,
Then create a file with the name rds.tf,
Then a file named securitygroup.tf,
In here we allow ingress and egress traffic to our EC2 instance the then limit the ingress traffic of the RDS instance only from the EC2 instance's subnet.
Generate ssh keys,
Initialize the providers,
Apply the changes,
Don't forget to clean up once experiments are done,
Last updated
Was this helpful?