cloud-foundation-fabric/examples/data-solutions/cloudsql-multiregion
Lorenzo Caggioni a4d59a250b Improve README 2022-04-11 18:14:59 +02:00
..
README.md Improve README 2022-04-11 18:14:59 +02:00
backend.tf.sample Improve README 2022-04-11 18:14:59 +02:00
diagram.png Improve README 2022-04-11 18:14:59 +02:00
main.tf Improve README 2022-04-11 18:14:59 +02:00
outputs.tf Multi-region Cloud-SQL example 2022-04-04 17:01:24 +02:00
terraform.tfvars.sample Improve README 2022-04-11 18:14:59 +02:00
variables.tf Improve README 2022-04-11 18:14:59 +02:00

README.md

Cloud SQL instance with multi-region read replicas

This example creates the Cloud SQL instance with multi-reagion read replica solution described in the Cloud SQL for PostgreSQL disaster recovery article.

The solution is resiliant to a regional outage. To get familiar with the procedure needed in the unfortunate case of a disaster recovery, we suggest to follow steps described in the Simulating a disaster (region outage) article.

The solution will use:

  • Postgre SQL instance with Private IP

This is the high level diagram:

Cloud SQL multi-region.

Move to real use case consideration

In the example we implemented some compromise to keep the example minimal and easy to read. On a real word use case, you may evaluate the option to:

  • Configure a Shared-VPC
  • Use VPC-SC to mitigate data exfiltration

Deploy your enviroment

We assume the identiy running the following steps has the following role:

  • resourcemanager.projectCreator in case a new project will be created.
  • owner on the project in case you use an existing project.

Run Terraform init:

$ terraform init

Configure the Terraform variable in your terraform.tfvars file. You need to spefify at least the following variables:

data_eng_principals = ["user:data-eng@domain.com"]
project_id      = "datalake-001"
prefix          = "prefix"

You can run now:

$ terraform apply

You should see the output of the Terraform script with resources created and some command pre-created for you to run the example following steps below. TBC

Variables

name description type required default
prefix Unique prefix used for resource names. Not used for project if 'project_create' is null. string
project_id Project id, references existing project if project_create is null. string
regions Map of instance_name => location where instances will be deployed. map(string)
cloudsql_psa_range Range used for the Private Service Access. string "10.60.0.0/16"
database_version Database type and version to create. string "POSTGRES_13"
project_create Provide values if project creation is needed, uses existing project if null. Parent is in 'folders/nnn' or 'organizations/nnn' format. object({…}) null
tier The machine type to use for the instances. See See https://cloud.google.com/sql/docs/postgres/create-instance#machine-types. string "db-g1-small"

Outputs

name description sensitive
connection_names Connection name of each instance.
ips IP address of each instance.
project_id ID of the project containing all the instances.