Relational Database Service (RDS)

The “aws_db_instance” resource type an RDS instance resource. A DB instance is an isolated database environment in the cloud.

Example Usage

resource "aws_db_instance" "mydatabase" {
  allocated_storage = 10
  storage_type = "gp2"
  engine = "mysql"
  engine_version = "5.7"
  instance_class = "db.t2.micro"
  name = "mydb"
  username = "root"
  password = "Pa$#W0rD"
  parameter_group_name = "default.mysql5.7"
}

The following arguments are mandatory :

  • allocated_storage
  • engine
  • instance_class
  • username
  • password

You can create MySQL, MariaDB, PostgreSQL, Oracle, SQL Server DB instances by mentioning engine type and engine_version.

To enable multi-AZ, use multi_az = true.

We can also add maintenance and backup windows and retention period using following attributes

  • backup_window
  • backup_retention_period
  • maintenance_window

There are other attributes to enable encryption, enable delete protection, to assign security groups and subnets and version upgrade etc..

 

Advertisements

Learn Technology

%d bloggers like this: