Skip to content

TechDirectArchive

Hands-on IT, Cloud, Security & DevOps Insights

  • Home
  • About
  • Advertise With US
  • Contact
  • Reviews
  • Toggle search form
Home » Linux » How to install Amazon RDS using Terraform
  • mysqlhero
    How to reset MySQL Root password Oracle/MSSQL/MySQL
  • Webp.net resizeimage 4
    Create, list, lock, deploy, and delete Azure Resource Group via Azure CLI AWS/Azure/OpenShift
  • Screenshot
    How to configure Synology Active Insights Network | Monitoring
  • adfs training
    Post-Deployment of Active Directory Federation Service (ADFS) Windows Server
  • 980239e9 cisco logo
    Security Best Practice to secure your Cisco Router and Switches Network | Monitoring
  • Watchguard Firewall 180504 100511 1
    Reset an XTM Firebox Device: Easy Guide Network | Monitoring
  • Safeguard Your PC Against Common Malware Entry Points
    Safeguard Your PC Against Common Malware Entry Points Security | Vulnerability Scans and Assessment
  • maxresdefault
    How to extend a VM Hard Disk on VMware Workstation Virtualization

How to install Amazon RDS using Terraform

Posted on 25/04/202221/03/2024 Raphael Gab-Momoh By Raphael Gab-Momoh No Comments on How to install Amazon RDS using Terraform
feature-photo-terraform

Amazon Relational Database Service (RDS) is one of Amazon Web Services (AWS) database offerings, and it often necessitates a lot of scrolling about and clicking in the AWS Management Console. While this procedure might take several minutes, if you’re a DevOps or just need to automate it, Terraform and AWS RDS are a perfect match. This article will walk you through creating a Terraform configuration for an AWS RDS instance and deploying it to the AWS cloud. In addition, you’ll learn how to install Amazon RDS using Terraform.

Find other guides here: Squid Proxy: How to setup and configure a Proxy Server, How to install, configure Prometheus for Monitoring on a Linux Server, and how to install Gradle on Ubuntu.

Quick Overview of Databases, Amazon Relational Databases & Relational Database Systems

Installing Amazon RDS with Terraform requires using a relational database management system (RDBMS) software that stores, manages, queries, and retrieves data from a relational database. The RDBMS acts as a bridge between users and applications and the database, as well as providing administrative services for data storage, access, and performance management.

Also, see how to install and configure Microsoft Teams on Ubuntu, how to add an EBS volume to AWS EC2, and, how to Deploy MVC Application to AWS EC2 Using RDP.

What is a database

A database is a collection of data that has been arranged. Thus, the information can be saved in a variety of formats or files:

1. Data that is organized into lists or parent/child routes in hierarchical or navigational databases.

2. Data that is stored in relational databases in pre-defined tables that are linked by common data elements.

Note: You’ll utilize database when setting up Amazon RDS with Terraform.

In the 1960s, when computers began employing disk and drum storage systems, the term database was coined. This storage medium allowed for random data access, which was not possible with previous media (tape). In the 1960s, as the number and capability of computers increased, so did the amount of data be managed.

Interest in standards rose, and the group in charge of standardizing the Common Business Oriented Language (COBOL) computer programming language proposed the Conference on Data Systems Language database strategy (CODASYL).

Data was maintained in a navigational architecture in this technique.

Hierarchical Databases

To create a vast network of data, hierarchical databases (also known as navigational databases) use linked lists called data sets.

In addition, the forward and reverse pointers to other elements of the data set were usually present in these linked lists. One of the numerous ways could be used to locate the data:

  • The main key may be generated using a hashing method.
  • Getting through a relationship (a set of data).
  • Records are scanned in sequential order.
  • Two of the most well-known databases of this sort were:

Relational Databases

The following are the fundamental concepts of a relational database: ​

  • It organizes data using tables.
  • It link tables together through a common data element.
  • With relational database, users can create, modify or delete tables as needed.
  • Database Management Systems maintain the information stored on storage media and provide an interface to retrieve it. Meanwhile, the most widely used database interface is Standardized Query Language (SQL).

Database Management System (DBMS)

Database management systems (DBMS) are the programs (managers) that allow access to the data. Moreover, a database management system (DBMS), like Amazon RDS provides an interface that allows you to manipulate the data you’ve saved. The management system’s name usually refers to the database.

Additionally, MariaDB, Oracle, MySQL, PostgreSQL, and MongoDB are some of the most prominent DBMSs. The most popular database management system is a hot topic of discussion; one popular list can be found in this DB-Engines Ranking.

Because there are so many DBMSs to pick from, the finest ones usually come after a discussion that ends with the phrase “it depends.” For the few highlighted, below are some debate points:

  • MariaDB
    RDBMS is open-source, freely available, and a fork of MySQL. 
  • Oracle
    RDBMS, long history, supported “Enterprise Editions”.
  • MySQL
    RDBMS started out as an independent open source, now owned by Oracle.
  • PostgreSQL
    RDBMS, open-source, long history.
  • MongoDB
    Open source, Document DBMS.

Structured Query Language (SQL)

You can use SQL for data insertion, querying, updating, and deleting. Furthermore, it became a standard of the American National Standards Institute (ANSI) in 1986. Hence, here is an example of a SQL statement: Add a Table:

CREATE TABLE Articles (
-> Articleno INT NOT NULL ,
-> Title VARCHAR(100) NOT NULL,
-> Description VARCHAR(200),
-> PRIMARY KEY ( Articleno )
-> );

Every table divides into smaller entities called fields. Meanwhile, the fields in the Articles table consist of Article no, Title, and Description. What’s more, a field in a table is a column designed to store specific information about each record in the table.

Example: Select information from a table:

SELECT * FROM Readers;

SELECT is the command, the wildcard character * would pick every column of the

Example: Insert data into a table:

INSERT INTO Readers (Readno,First,Last)
-> Values (01,'Raphael,'Christian'),
-> (02,'Imoh','Billy'),
-> (03,'Isaac','Brown');

Installing Amazon RDS using Terraform

Amazon Relational Database Service is an Amazon Web Services distributed relational database service. It’s a cloud-based web service that makes it easy for anyone to create, operate, and scale a relational database for use in applications. And we will be creating this using terraform

Prerequisites for Installing Amazon RDS with Terraform

This will be a stage process guide. If you really want to follow along, make sure you have the following items ready:

  1. AWS (Amazon Web Services) account
  2. A code editor — While any text editor may be used to work with Terraform configuration files, for the exercise in the guide, we used the inbuilt Linux editor vim (it can be installed with the command apt install vim)
  3. Terraform
  4. AWS CLI
  5. Authenticate the AWS Account

Creating Terraform and the AWS RDS Database Configuration

Terraform is indeed an infrastructure-as-code tool that allows you to construct, alter, and version infrastructure securely and effectively. Terraform employs a variety of configuration files. You can author each file in one of two languages: Hashicorp Control Language (HCL) or JSON. This lesson will make use of HCL.

This tutorial will utilize three distinct files to construct an AWS RDS instance with Terraform, which when combined will include all of the instructions Terraform requires.

  1. main.tf — The Terraform config file includes the Terraform resource declaration as well as variable placeholders for the RDS instance properties.
  2. vars.tf — This is a Terraform variables file that contains all of the variables that main.tf will use. It’s a good idea to split configuration objects into variables, especially if you’re working with bigger Terraform settings.
  3. provider.tf — This is the configuration file for the AWS provider. Terraform connects to an Amazon account through AWS providers to manage or deploy/update hundreds of AWS services.

Configure Terraform for AWS RDS Database

Let’s start by building the Terraform configuration file for the AWS RDS database instance.

  1. Open a terminal/console on your computer with Terraform installed. If you want to know how to install terraform check out our previous article How to Install Terraform on Linux
  2. Create a directory called /terraform and then change (cd) to it. All the configuration files you’ll be dealing with will be in this folder.
  3. Create folder for main.tf, vars.tf, provider.tf using the touch command.
How to install Amazon RDS using Terraform-create-folders
folders

The next thing to do is to edit the folders we created earlier. the first one will be the main.tf that we created with touch main.tf. we can do this with the command below:

vim main.tf

Afterward, copy and paste the code below into the empty vim file. The code utilizes the AWS db instance resource in configuring Amazon RDS using Terraform.

This document comprehensively outlines how to utilize AWS APIs actively to provision an RDS instance, which you can customize based on a few specified parameters.

You’ll also note that a lot of the values begin with the word var. Following this, you will create Terraform input variables with actual values in the next step, and these will serve as placeholders.

resource "aws_db_instance" "default" {
# Allocating the storage for database instance.
  allocated_storage    = 10
# Declaring the database engine and engine_version
  engine               = var.engine
  engine_version       = var.engine_version
# Declaring the instance class
  instance_class       = var.instance_class
  name                 = var.name
# User to connect the database instance 
  username             = var.username
# Password to connect the database instance 
  password             = var.password
  parameter_group_name = var.parameter_group_name
}

We need to edit the vars.tf file that we created earlier with touch vars.tf command. we can do this with the command below:

vim vars.tf

Create a Variables File

To use Amazon RDS with Terraform, create a variables file to declare all the necessary variables for the main configuration file. Following this, you’ll notice that the main.tf configuration file references each of the variables listed below.

variable "engine" {}
variable "engine_version" {}     
variable "instance_class" {}
variable "name" {}       
variable "username" {}  
variable "password" {}
variable "parameter_group_name" {}
~                                                                              
~                                        

When working with Amazon RDS using Terraform, we need to provide the following values, and when prompted, we must input them accurately. Terraform will then leverage these values from the variables file to substitute the variable references present in the configuration file for the Amazon RDS Terraform setup.

Create AWS RDS

Terraform will create this AWS RDS instance as follows: It will run a MySQL 5.7 database on a t3.micro engine.
– With a password of password and a user1 admin username

  engine               = "mysql"
  engine_version       = "5.7"
  instance_class       = "db.t3.micro"
  name                 = "mydb"
  username             = "user1"
  password             = "password"
  parameter_group_name = "default.mysql5.7"

Finally, let’s edit the provider.tf file that was created with the touch provider.tf command we can do so with:

vim prov

Thus, we can use the provider information below:

provider "aws" {
   region = "us-east-1"
 }

To ensure smooth execution of the next commands related to Amazon RDS Terraform, let’s install “tree” using the command below:

apt install tree

output

root@ubuntu:~/terraform# apt install tree
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  tree
0 upgraded, 1 newly installed, 0 to remove and 106 not upgraded.
Need to get 43.0 kB of archives.
After this operation, 115 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 tree amd64 1.8.0-1 [43.0 kB]
Fetched 43.0 kB in 1s (40.4 kB/s)
Selecting previously unselected package tree.
(Reading database ... 189943 files and directories currently installed.)
Preparing to unpack .../tree_1.8.0-1_amd64.deb ...
Unpacking tree (1.8.0-1) ...
Setting up tree (1.8.0-1) ...
Processing triggers for man-db (2.9.1-1) ...
root@ubuntu:~/terraform# 

By using the tree command, make sure the folder has all of the essential files.

How to install Amazon RDS using Terraform-tree
tree

Creating the AWS RDS Instance with Terraform

It’s time to start Terraform and create your first AWS RDS database instance now that you have the Terraform configuration files ready to go! Terraform normally uses a three-stage approach to provision a Terraform configuration: terraform init, terraform plan, and terraform apply. Let’s have a look at each stage now.

Step 1: Terraform init

Working with Amazon RDS using Terraform requires you to remain in the directory where you created all the relevant files, including the configuration files for Amazon RDS Terraform. In this case, the directory would be ~/terraform.

Once in that directory, execute the “terraform init” command. This command will set up the required plugins and providers, enabling smooth interaction with AWS resources that are necessary for your configuration.

How to install Amazon RDS using Terraform-terraform-init
terraform init

Step 2: Terraform Plan

The Terraform plan command gives you an overview of which resources in your infrastructure will be provisioned. You’ll also get a list of all the AWS resources, including Amazon RDS that Terraform plans to build as shown below.

How to install Amazon RDS using Terraform-plan1
terraform plan
How to install Amazon RDS using Terraform-plan2

Step 3: Terraform Apply

When you execute “terraform apply” for Amazon RDS using Terraform, the tool will utilize the configuration present in the main.tf and other files to generate the required settings. Subsequently, Terraform will instruct AWS on how to build the database instance based on this configuration.

How to install Amazon RDS using Terraform-apply1
Terraform apply
How to install Amazon RDS using Terraform-apply-2

Confirming Amazon RDS Installation Using Terraform

Terraform should have generated the database instance by now. Let’s double-check in the AWS Management Console by manually looking for the database instance. Meanwhile, make sure that you are in the right region.

  1. Log in to the AWS Management Console by using your preferred web browser.
  2. While still in the Console, use the top-right search box to look for RDS and then select the RDS menu item.
terraform-created-db

Conclusion

In summary, this guide explains how to use install Amazon RDS using Terraform to create your first database. Terraform is undoubtedly the most popular automation tool.

Rate this post

Thank you for reading this post. Kindly share it with others.

  • Click to share on X (Opens in new window) X
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Pinterest (Opens in new window) Pinterest
  • Click to share on Tumblr (Opens in new window) Tumblr
  • Click to share on Telegram (Opens in new window) Telegram
  • Click to share on WhatsApp (Opens in new window) WhatsApp
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Mastodon (Opens in new window) Mastodon
  • Click to share on Bluesky (Opens in new window) Bluesky
  • Click to share on Threads (Opens in new window) Threads
  • Click to share on Nextdoor (Opens in new window) Nextdoor
Linux Tags:MySQL, rds

Post navigation

Previous Post: How to add languages to your Windows PC
Next Post: How to create a BitLocker System Partition [Part 2]

Related Posts

  • Feature Image DNF vs APT
    What are the differences between dnf and apt package managers? Linux
  • integrate VHR with VBR
    How to deploy and integrate VHR with VBR Backup
  • trip wire feature
    How to install and configure Tripwire on Ubuntu Linux
  • FEATURE IMAGE
    SSH into a VM created using Azure CLI or GUI Linux
  • portainer feature
    How to Install Docker Portainer on Linux Containers
  • Slide1
    Read-only Files: Saving Files in VIM Editor on Linux/Unix-like OS Linux

More Related Articles

Feature Image DNF vs APT What are the differences between dnf and apt package managers? Linux
integrate VHR with VBR How to deploy and integrate VHR with VBR Backup
trip wire feature How to install and configure Tripwire on Ubuntu Linux
FEATURE IMAGE SSH into a VM created using Azure CLI or GUI Linux
portainer feature How to Install Docker Portainer on Linux Containers
Slide1 Read-only Files: Saving Files in VIM Editor on Linux/Unix-like OS Linux

Leave a Reply Cancel reply

You must be logged in to post a comment.

Microsoft MVP

VEEAMLEGEND

vexpert-badge-stars-5

Virtual Background

GoogleNews

Categories

veeaam100

sysadmin top30a
 
  • mysqlhero
    How to reset MySQL Root password Oracle/MSSQL/MySQL
  • Webp.net resizeimage 4
    Create, list, lock, deploy, and delete Azure Resource Group via Azure CLI AWS/Azure/OpenShift
  • Screenshot
    How to configure Synology Active Insights Network | Monitoring
  • adfs training
    Post-Deployment of Active Directory Federation Service (ADFS) Windows Server
  • 980239e9 cisco logo
    Security Best Practice to secure your Cisco Router and Switches Network | Monitoring
  • Watchguard Firewall 180504 100511 1
    Reset an XTM Firebox Device: Easy Guide Network | Monitoring
  • Safeguard Your PC Against Common Malware Entry Points
    Safeguard Your PC Against Common Malware Entry Points Security | Vulnerability Scans and Assessment
  • maxresdefault
    How to extend a VM Hard Disk on VMware Workstation Virtualization

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,841 other subscribers
  • RSS - Posts
  • RSS - Comments
  • About
  • Authors
  • Write for us
  • Advertise with us
  • General Terms and Conditions
  • Privacy policy
  • Feedly
  • Telegram
  • Youtube
  • Facebook
  • Instagram
  • LinkedIn
  • Tumblr
  • Pinterest
  • Twitter
  • mastodon

Tags

AWS Azure Bitlocker Microsoft Windows PowerShell WDS Windows 10 Windows 11 Windows Deployment Services Windows Server 2016

Copyright © 2025 TechDirectArchive

 

Loading Comments...
 

You must be logged in to post a comment.