Skip to content

Commit

Permalink
Merge pull request #19167 from hashicorp/rds_postgres_cluster
Browse files Browse the repository at this point in the history
Add examples for mysql and postgresql
  • Loading branch information
bill-rich authored May 21, 2021
2 parents 1edf6e4 + c555bb7 commit a632d44
Showing 1 changed file with 92 additions and 20 deletions.
112 changes: 92 additions & 20 deletions website/docs/r/rds_global_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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 = 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"
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 = 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"
}
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" {
Expand All @@ -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 = 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"
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 = 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"
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 = 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
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 = 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"
db_subnet_group_name = "default"
}
```


### New Global Cluster From Existing DB Cluster

```terraform
Expand Down

0 comments on commit a632d44

Please sign in to comment.