AWS Database Blog
Provision and manage Amazon RDS for Oracle using Terraform
This the first post in a multi-part series where we discuss how you can set up Amazon Relational Database Service (Amazon RDS) for Oracle with Terraform. Terraform by HashiCorp allows you to define the instructions for setting up the infrastructure as a code, simplifying and automating the process instead of doing everything manually.
Overview of solution
When it comes to provisioning an RDS for Oracle instance, Terraform can make the process efficient and reproducible. We walk you through the steps to provision an RDS for Oracle instance, modify the instance, and remove the instance.
Prerequisites
This post assumes that you’re familiar with Terraform, GitHub, and Git commands.
For this walkthrough, you need the following:
- An active AWS account. If you don’t have an account, sign up for one.
- The AWS Command Line Interface (AWS CLI) installed and configured. For more information, see Installing, updating, and uninstalling the AWS CLI.
- Terraform installed on your local machine. For more information, see Install Terraform.
- The necessary AWS Identity and Access Management (IAM) permissions required to create the AWS resources using Terraform.
Set up your resources
Complete the following steps to set up your resources:
- Install git on your workstation.
- Clone the GitHub repo rds-oracle-terraform to your workstation by running the following command in your terminal window:
This command creates a directory named rds-oracle-terraform
under your current directory. You can modify the variables as per your use case to deploy the modules.
- Export the AWS environment:
Build the database instance
Your directory contains the following files:
- main.tf – Main terraform code
- variables.tf – Variables for the code
- test.tfvars – Variables for your specific file
- versions.tf – The version support for Terraform
- outputs.tf – Information about your infrastructure
- Initialize the Terraform module:
The file test.tfvars
holds the values of the RDS database identifier and database admin password.
- Run a plan to confirm what is to be built:
- Apply the code and build the database:
While it’s building, you will see the resource on the Amazon RDS console.
After 10–20 minutes, you will see a Creation Complete message when the instance is built.
The following screenshot shows the instance with the status Available on the Amazon RDS console.
Modify database settings using Terraform
To modify the RDS for Oracle database settings using Terraform, you can update the values in the variables.tf
file, as shown in the following screenshot. In this example, we increase the DB storage to 400 GiB and modify the database backup retention to 7 days. This allows you to customize the database configuration according to your requirements. Please note that the maximum allocated storage must be increased by at least 10 percent.
Then run terraform plan -var-file=test.tfvars
To apply the changes listed in the preceding screenshot, run terraform apply -var-file=test.tfvars
You can monitor the instance status on the Amazon RDS console.
Clean up
AWS resources created by the Terraform RDS for Oracle instance incur costs as long as they are in use. When you no longer need the resources, clean them up by deleting the RDS for Oracle instance.
Run the following commands in your terminal window to remove the resource with a terraform destroy
command:
On the Amazon RDS console, you will see the instance deletion in progress.
Conclusion
As cloud infrastructures continue to evolve and expand, automation becomes a necessity. In this first part of our series, we established a solid understanding of how to use Terraform to deploy, modify, and clean up an RDS for Oracle instance.
In the next part of this series, we delve into the management aspect, including scaling, monitoring, and maintenance, to comprehensively address the management of Amazon RDS for Oracle using Terraform.
About the Authors
Tony Mullen is a Senior Database Specialist Solutions Architect based in Manchester. With a focus on relational database engines, he assists customers in migrating and modernizing their database workloads to AWS.
Vetrivel is a Senior Cloud Support Database Engineer at Amazon Web Services, specialized in Databases, Storage and Oracle workloads in the AWS cloud. He leverages his IT expertise to offer technical support to customers, empowering them to build well architected solutions within the AWS Cloud. Beyond his professional life, Vetrivel’s passions include traveling, discovering new destinations, relishing diverse cuisines, and participating in adventure activities.
Sharath Chandra Kampili is a Database Specialist Solutions Architect with Amazon Web Services. He works with AWS RDS team, focusing on commercial database engines like Oracle. Sharath works directly with AWS customers to provide guidance and technical assistance on the database projects, helping them improve the value of their solutions when using AWS.