From 3ce8b2359d646ea3aab30b04071225fceb0d563f Mon Sep 17 00:00:00 2001 From: bill-rich Date: Thu, 29 Apr 2021 13:33:32 -0700 Subject: [PATCH 1/2] Note for postgresql --- .../docs/r/rds_global_cluster.html.markdown | 112 ++++++++++++++---- 1 file changed, 92 insertions(+), 20 deletions(-) diff --git a/website/docs/r/rds_global_cluster.html.markdown b/website/docs/r/rds_global_cluster.html.markdown index 8a47ab5876d8..04b3043fa8fe 100644 --- a/website/docs/r/rds_global_cluster.html.markdown +++ b/website/docs/r/rds_global_cluster.html.markdown @@ -14,7 +14,60 @@ More information about Aurora global databases can be found in the [Aurora User ## Example Usage -### New Global Cluster +### New MySQL Global Cluster + +```terraform +resource "aws_rds_global_cluster" "example" { + global_cluster_identifier = "global-test" + engine = "aurora" + engine_version = "5.6.mysql_aurora.1.22.2" + database_name = "example_db" +} + +resource "aws_rds_cluster" "primary" { + provider = aws.primary + engine = "aurora" + engine_version = "5.6.mysql_aurora.1.22.2" + cluster_identifier = "test-primary-cluster" + master_username = "username" + master_password = "somepass123" + database_name = "example_db" + global_cluster_identifier = aws_rds_global_cluster.example.id + db_subnet_group_name = "default" +} + +resource "aws_rds_cluster_instance" "primary" { + provider = aws.primary + identifier = "test-primary-cluster-instance" + cluster_identifier = aws_rds_cluster.primary.id + instance_class = "db.r4.large" + db_subnet_group_name = "default" +} + +resource "aws_rds_cluster" "secondary" { + provider = aws.secondary + engine = "aurora" + engine_version = "5.6.mysql_aurora.1.22.2" + cluster_identifier = "test-secondary-cluster" + global_cluster_identifier = aws_rds_global_cluster.example.id + db_subnet_group_name = "default" +} + +resource "aws_rds_cluster_instance" "secondary" { + provider = aws.secondary + identifier = "test-secondary-cluster-instance" + cluster_identifier = aws_rds_cluster.secondary.id + instance_class = "db.r4.large" + db_subnet_group_name = "default" + + depends_on = [ + aws_rds_cluster_instance.primary + ] +} +``` + +### New PostgreSQL Global Cluster + ```terraform provider "aws" { @@ -24,45 +77,64 @@ provider "aws" { provider "aws" { alias = "secondary" - region = "us-west-2" + region = "us-east-1" } resource "aws_rds_global_cluster" "example" { - provider = aws.primary - - global_cluster_identifier = "example" + global_cluster_identifier = "global-test" + engine = "aurora-postgresql" + engine_version = "11.9" + database_name = "example_db" } resource "aws_rds_cluster" "primary" { - provider = aws.primary - - # ... other configuration ... + provider = aws.primary + engine = "aurora-postgresql" + engine_version = "11.9" + cluster_identifier = "test-primary-cluster" + master_username = "username" + master_password = "somepass123" + database_name = "example_db" global_cluster_identifier = aws_rds_global_cluster.example.id + db_subnet_group_name = "default" } resource "aws_rds_cluster_instance" "primary" { - provider = aws.primary - - # ... other configuration ... - cluster_identifier = aws_rds_cluster.primary.id + provider = aws.primary + engine = "aurora-postgresql" + engine_version = "11.9" + identifier = "test-primary-cluster-instance" + cluster_identifier = aws_rds_cluster.primary.id + instance_class = "db.r4.large" + db_subnet_group_name = "default" } resource "aws_rds_cluster" "secondary" { - depends_on = [aws_rds_cluster_instance.primary] - provider = aws.secondary - - # ... other configuration ... + provider = aws.secondary + engine = "aurora-postgresql" + engine_version = "11.9" + cluster_identifier = "test-secondary-cluster" global_cluster_identifier = aws_rds_global_cluster.example.id + skip_final_snapshot = true + db_subnet_group_name = "default" + + depends_on = [ + aws_rds_cluster_instance.primary + ] } resource "aws_rds_cluster_instance" "secondary" { - provider = aws.secondary - - # ... other configuration ... - cluster_identifier = aws_rds_cluster.secondary.id + provider = aws.secondary + engine = "aurora-postgresql" + engine_version = "11.9" + identifier = "test-secondary-cluster-instance" + cluster_identifier = aws_rds_cluster.secondary.id + instance_class = "db.r4.large" + db_subnet_group_name = "default" } ``` + ### New Global Cluster From Existing DB Cluster ```terraform From c555bb7d093ce4eba9891b96ca8dbd4a21b86dd6 Mon Sep 17 00:00:00 2001 From: bill-rich Date: Wed, 19 May 2021 09:36:40 -0700 Subject: [PATCH 2/2] Improve example code maintainability --- .../docs/r/rds_global_cluster.html.markdown | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/website/docs/r/rds_global_cluster.html.markdown b/website/docs/r/rds_global_cluster.html.markdown index 04b3043fa8fe..a418d42d4f5b 100644 --- a/website/docs/r/rds_global_cluster.html.markdown +++ b/website/docs/r/rds_global_cluster.html.markdown @@ -26,8 +26,8 @@ resource "aws_rds_global_cluster" "example" { resource "aws_rds_cluster" "primary" { provider = aws.primary - engine = "aurora" - engine_version = "5.6.mysql_aurora.1.22.2" + engine = aws_rds_global_cluster.example.engine + engine_version = aws_rds_global_cluster.example.engine_version cluster_identifier = "test-primary-cluster" master_username = "username" master_password = "somepass123" @@ -46,8 +46,8 @@ resource "aws_rds_cluster_instance" "primary" { resource "aws_rds_cluster" "secondary" { provider = aws.secondary - engine = "aurora" - engine_version = "5.6.mysql_aurora.1.22.2" + engine = aws_rds_global_cluster.example.engine + engine_version = aws_rds_global_cluster.example.engine_version cluster_identifier = "test-secondary-cluster" global_cluster_identifier = aws_rds_global_cluster.example.id db_subnet_group_name = "default" @@ -89,8 +89,8 @@ resource "aws_rds_global_cluster" "example" { resource "aws_rds_cluster" "primary" { provider = aws.primary - engine = "aurora-postgresql" - engine_version = "11.9" + engine = aws_rds_global_cluster.example.engine + engine_version = aws_rds_global_cluster.example.engine_version cluster_identifier = "test-primary-cluster" master_username = "username" master_password = "somepass123" @@ -101,8 +101,8 @@ resource "aws_rds_cluster" "primary" { resource "aws_rds_cluster_instance" "primary" { provider = aws.primary - engine = "aurora-postgresql" - engine_version = "11.9" + engine = aws_rds_global_cluster.example.engine + engine_version = aws_rds_global_cluster.example.engine_version identifier = "test-primary-cluster-instance" cluster_identifier = aws_rds_cluster.primary.id instance_class = "db.r4.large" @@ -111,8 +111,8 @@ resource "aws_rds_cluster_instance" "primary" { resource "aws_rds_cluster" "secondary" { provider = aws.secondary - engine = "aurora-postgresql" - engine_version = "11.9" + engine = aws_rds_global_cluster.example.engine + engine_version = aws_rds_global_cluster.example.engine_version cluster_identifier = "test-secondary-cluster" global_cluster_identifier = aws_rds_global_cluster.example.id skip_final_snapshot = true @@ -125,8 +125,8 @@ resource "aws_rds_cluster" "secondary" { resource "aws_rds_cluster_instance" "secondary" { provider = aws.secondary - engine = "aurora-postgresql" - engine_version = "11.9" + engine = aws_rds_global_cluster.example.engine + engine_version = aws_rds_global_cluster.example.engine_version identifier = "test-secondary-cluster-instance" cluster_identifier = aws_rds_cluster.secondary.id instance_class = "db.r4.large"