Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,10 @@ Temporary Items
.csr
.pem
replace-default-config.sh

# Terraform
**/.terraform/
*.tfstate
*.tfstate.*
crash.log
crash.*.log
31 changes: 31 additions & 0 deletions terraform/adb_with_cross-region_standby/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Autonomous AI Database with a cross-region standby

This Terraform example creates an Autonomous AI Database with a cross-region standby.

You can run it by updating the file _terraform.tfvars_ file with the settings you want.

Enter your tenancy OCID, user OCID, user fingerprint, private key file path, region name, and compartment OCID. Change the other settings like database name and compute count to your liking and enter the ADMIN user password you want.

```tenancy_ocid = ""
user_ocid = ""
fingerprint = ""
private_key_path = ""

compartment_ocid = ""

primary_region = "us-ashburn-1"
standby_region = "us-phoenix-1"

adb_display_name = "primarydb"
adb_db_name = "primarydb"

admin_password = ""

db_workload = "OLTP"

compute_count = 2
data_storage_size_in_tbs = 1
```



32 changes: 32 additions & 0 deletions terraform/adb_with_cross-region_standby/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
resource "oci_database_autonomous_database" "primary" {
provider = oci.primary

compartment_id = var.compartment_ocid

display_name = var.adb_display_name
db_name = var.adb_db_name

db_workload = var.db_workload
compute_model = var.compute_model
compute_count = var.compute_count
data_storage_size_in_tbs = var.data_storage_size_in_tbs

admin_password = var.admin_password
}

# Cross-region standby (Autonomous Data Guard)
resource "oci_database_autonomous_database" "standby" {
provider = oci.standby

compartment_id = var.compartment_ocid

# Create standby in another region:
source = "CROSS_REGION_DATAGUARD"
source_id = oci_database_autonomous_database.primary.id

display_name = "${var.adb_display_name}-standby"
db_name = oci_database_autonomous_database.primary.db_name

depends_on = [oci_database_autonomous_database.primary]
}

8 changes: 8 additions & 0 deletions terraform/adb_with_cross-region_standby/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
output "primary_adb_id" {
value = oci_database_autonomous_database.primary.id
}

output "standby_adb_id" {
value = oci_database_autonomous_database.standby.id
}

18 changes: 18 additions & 0 deletions terraform/adb_with_cross-region_standby/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
provider "oci" {
alias = "primary"
tenancy_ocid = var.tenancy_ocid
user_ocid = var.user_ocid
fingerprint = var.fingerprint
private_key_path = var.private_key_path
region = var.primary_region
}

provider "oci" {
alias = "standby"
tenancy_ocid = var.tenancy_ocid
user_ocid = var.user_ocid
fingerprint = var.fingerprint
private_key_path = var.private_key_path
region = var.standby_region
}

20 changes: 20 additions & 0 deletions terraform/adb_with_cross-region_standby/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
tenancy_ocid = ""
user_ocid = ""
fingerprint = ""
private_key_path = ""

compartment_ocid = ""

primary_region = "us-ashburn-1"
standby_region = "us-phoenix-1"

adb_display_name = "primarydb"
adb_db_name = "primarydb"

admin_password = ""

db_workload = "OLTP"

compute_count = 2
data_storage_size_in_tbs = 1

35 changes: 35 additions & 0 deletions terraform/adb_with_cross-region_standby/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
variable "tenancy_ocid" { type = string }
variable "user_ocid" { type = string }
variable "fingerprint" { type = string }
variable "private_key_path" { type = string }

variable "compartment_ocid" { type = string }

variable "primary_region" { type = string }
variable "standby_region" { type = string }

variable "adb_display_name" { type = string }
variable "adb_db_name" { type = string }

variable "admin_password" {
type = string
sensitive = true
}

variable "db_workload" {
type = string
}

variable "compute_model" {
type = string
default = "ECPU"
}

variable "compute_count" {
type = number
}

variable "data_storage_size_in_tbs" {
type = number
}

11 changes: 11 additions & 0 deletions terraform/adb_with_cross-region_standby/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
terraform {
required_version = ">= 1.5.0"

required_providers {
oci = {
source = "oracle/oci"
version = ">= 5.0.0"
}
}
}

26 changes: 26 additions & 0 deletions terraform/adb_with_local_standby/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Autonomous AI Database with a local standby

This Terraform example creates an Autonomous AI Database with a local standby.

You can run it by updating the file _terraform.tfvars_ file with the settings you want.

Enter your tenancy OCID, user OCID, user fingerprint, private key file path, region name, and compartment OCID. Change the other settings like database name and compute count to your liking and enter the ADMIN user password you want.

```tenancy_ocid = ""
user_ocid = ""
fingerprint = ""
private_key_path = ""
region = "us-ashburn-1"

compartment_ocid = ""

db_name = "primarydb"
display_name = "primarydb"
admin_password = ""
compute_count = 2
data_storage_tbs = 1
db_workload = "OLTP"
```



16 changes: 16 additions & 0 deletions terraform/adb_with_local_standby/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
resource "oci_database_autonomous_database" "primary" {
compartment_id = var.compartment_ocid

db_name = var.db_name
display_name = var.display_name
db_workload = var.db_workload

admin_password = var.admin_password
compute_model = var.compute_model
compute_count = var.compute_count
data_storage_size_in_tbs = var.data_storage_tbs

# Local (in-region) standby
is_local_data_guard_enabled = true
}

6 changes: 6 additions & 0 deletions terraform/adb_with_local_standby/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
output "adb_id" { value = oci_database_autonomous_database.primary.id }

output "local_standby_db" {
value = oci_database_autonomous_database.primary.local_standby_db
}

8 changes: 8 additions & 0 deletions terraform/adb_with_local_standby/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
provider "oci" {
tenancy_ocid = var.tenancy_ocid
user_ocid = var.user_ocid
fingerprint = var.fingerprint
private_key_path = var.private_key_path
region = var.region
}

14 changes: 14 additions & 0 deletions terraform/adb_with_local_standby/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
tenancy_ocid = ""
user_ocid = ""
fingerprint = ""
private_key_path = ""
region = "us-ashburn-1"

compartment_ocid = ""

db_name = "primarydb"
display_name = "primarydb"
admin_password = ""
compute_count = 2
data_storage_tbs = 1
db_workload = "OLTP"
54 changes: 54 additions & 0 deletions terraform/adb_with_local_standby/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
variable "tenancy_ocid" {
type = string
}

variable "user_ocid" {
type = string
}

variable "fingerprint" {
type = string
}

variable "private_key_path" {
type = string
}

variable "region" {
type = string
}

variable "compartment_ocid" {
type = string
}

variable "db_name" {
type = string
}

variable "display_name" {
type = string
}

variable "admin_password" {
type = string
sensitive = true
}

variable "compute_model" {
type = string
default = "ECPU"
}

variable "compute_count" {
type = number
}

variable "data_storage_tbs" {
type = number
}

variable "db_workload" {
type = string
}

10 changes: 10 additions & 0 deletions terraform/adb_with_local_standby/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
terraform {
required_version = ">= 1.5"
required_providers {
oci = {
source = "oracle/oci"
version = ">= 6.0.0"
}
}
}