How-to setup a HA/DR database in AWS? [1]
Tags: aws, sre, devops, terraform
Published: 2022-01-18 17:39:19

*In every company, we store some datas. For some of them it's with databases. But how can you be sure to keep your data safely and have the best availability ?*

If you don't know, you are at the right place.

---

In this mini-serie, we will see together how to setup a database, then it's High Availability *(HA)* and then it's **DR** to be sure that you and your enterprise can store your data safely, avoid lose in case of failure and be able to recover your data in case of a disaster.

Some links will be given to help you to have a better understanding of the solution. And some tips too, to let you know what can be interesting to look at, or how to do some specific things.

To follow the good practice, we will do it with Terraform to have all our **infra as code**.

But before going further, here are the 2 principals definitions to understand what we will do and why.

---

## What's an High Available system?
**HA = High Available**

When we are talking about infrastructure, especially in the cloud, an high available system is :
> A system which can continue to work even if a server/datacenter is non available.

An example with AWS : an available system is something deploy in multiple **AZ** *(Availability Zones)*.

---

## What's a Disaster Recovery system?
**DR = Disaster Recovery**

> Disaster recovery is an organization’s method of regaining access and functionality to its IT infrastructure after events like a natural disaster, cyber attack, or even business disruptions related to the COVID-19 pandemic. A variety of disaster recovery (DR) methods can be part of a disaster recovery plan. DR is one aspect of business continuity.

*Definition from VMWare : https://www.vmware.com/topics/glossary/content/disaster-recovery.html*

---

## What is an "Infra as Code" ?
> Infrastructure as Code (IaC) is the management of infrastructure (networks, virtual machines, load balancers, and connection topology) in a descriptive model, using the same versioning as DevOps team uses for source code. Like the principle that the same source code generates the same binary, an IaC model generates the same environment every time it is applied. IaC is a key DevOps practice and is used in conjunction with continuous delivery.

*Definition from Microsoft : https://docs.microsoft.com/en-us/devops/deliver/what-is-infrastructure-as-code*

Explicative video from **Techworld by Nana**
{% youtube POPP2WTJ8es %}

---

## Prerequisite
To understand correctly what's going next, you need to know Terraform *(How does it work and how to read it)* and to have a basis on AWS.

For Terraform, please check the documentation *(https://www.terraform.io/docs)* or the following video from **Techworld by Nana** before.

{% youtube l5k1ai_GBDE %}

For the AWS part, I will give you some definitions and links to help you to understand but I'm not sure it will be enough to understand the whole package. So don't hesitate to read something to introduce you to AWS or the following video from **Simplilearn** and if after you have some questions, don't hesitate in the comments.

{% youtube 3XFODda6YXo %}

---

### Links
#### Documentation
- AWS : https://aws.amazon.com/
- Terraform : https://www.terraform.io/docs

#### Youtube channels
- Techworld By Nana : https://www.youtube.com/channel/UCdngmbVKX1Tgre699-XLlUA
- Simplilearn : https://www.youtube.com/channel/UCsvqVGtbbyHaMoevxPAq9Fg

---

I hope it will help you! 🍺

And see you soon for the next part of this serie. 😀

---

## Serie link
- **1 - Start** : https://dev.to/adaendra/how-to-setup-a-hadr-database-in-aws-1-1ko7
- **2 - Definitions** : https://dev.to/adaendra/how-to-setup-a-hadr-database-in-aws-2-definitions-93p
- **3 - Simple database** : https://dev.to/adaendra/how-to-setup-a-hadr-database-in-aws-3-simple-database-a9o
- **4 - HA Database** : https://dev.to/adaendra/how-to-setup-a-hadr-database-in-aws-4-ha-database-4kek
- **5 - DR database** : https://dev.to/adaendra/how-to-setup-a-hadr-database-in-aws-5-dr-database-278b
- **6 - Create from snapshot** : https://dev.to/adaendra/how-to-setup-a-hadr-database-in-aws-6-create-from-snapshot-2mbf
- **7 - Dynamic Terraform backend definition** : https://dev.to/adaendra/how-to-setup-a-hadr-database-in-aws-7-dynamic-terraform-backend-definition-3aga
- **8 - Multiple instances in multiple regions** : https://dev.to/adaendra/how-to-setup-a-hadr-database-in-aws-8-multiple-instances-in-multiple-regions-210d
- **9 - Generate a random value** : https://dev.to/adaendra/how-to-setup-a-hadr-database-in-aws-9-generate-a-random-value-5g8a

---

<center><h3>You want to support me?</h3></center>
<a href="https://www.buymeacoffee.com/mxguilbert7" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a>