Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
January 18, 2022 05:40 pm GMT

How-to setup a HA/DR database in AWS? [8 - Multiple instances in multiple regions]

In this part of the serie, we will see how to create in one Terraform script and in a single execution, how to create elements in multiple regions.

This kind of tips is really helpful if you want to create at once all your infra and/or if you want to setup some disaster recovery.

How to do it?

To do it, it's pretty simple. We have 2 steps to follow :

  • declare multiple providers
  • declare which provider we want to use for each resource

Declare multiple providers

In your current script to create something on AWS, you should have an AWS Provider with the region where it should be created.

So, copy/paste this block for all your regions. Then add an alias to each of them to be able to differentiate them.

provider "aws" {  alias  = "frankfurt"  region = "eu-central-1"}provider "aws" {  alias  = "sydney"  region = "ap-southeast-2"}

Declare which provider we want to use for each resource

In each resource you have, add the provider parameter to link each of them to the correct provider.

resource "aws_rds_cluster_instance" "test_frankfurt" {  provider = aws.frankfurt  ...}resource "aws_rds_cluster_instance" "test_sydney" {  provider = aws.sydney  ...}

And that's it! You are now able to deploy your complete infra on multiple regions at once!

I hope it will help you!

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


Original Link: https://dev.to/adaendra/how-to-setup-a-hadr-database-in-aws-8-multiple-instances-in-multiple-regions-210d

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To