|
| 1 | +provider "oci" { |
| 2 | + tenancy_ocid = var.tenancy_ocid |
| 3 | + user_ocid = var.user_ocid |
| 4 | + fingerprint = var.fingerprint |
| 5 | + private_key_path = var.private_key_path |
| 6 | + region = var.region |
| 7 | +} |
| 8 | + |
| 9 | +#### Begin Resources #### |
| 10 | +resource "oci_identity_tag_namespace" "tag-namespace1" { |
| 11 | + #Required |
| 12 | + compartment_id = var.tenancy_ocid |
| 13 | + description = "tagNamespace1" |
| 14 | + name = "testexamples-tag-namespace1" |
| 15 | +} |
| 16 | + |
| 17 | +resource "oci_identity_tag" "tag1" { |
| 18 | + #Required |
| 19 | + description = "tf example tag" |
| 20 | + name = "tf-example-tag" |
| 21 | + tag_namespace_id = oci_identity_tag_namespace.tag-namespace1.id |
| 22 | +} |
| 23 | + |
| 24 | +resource "local_file" "activation_file" { |
| 25 | + filename = "/tmp/activation.zip" |
| 26 | + content = "" |
| 27 | +} |
| 28 | + |
| 29 | +resource "random_string" "db_unique_name" { |
| 30 | + length = 8 |
| 31 | + special = false |
| 32 | + min_numeric = 0 |
| 33 | + min_special = 0 |
| 34 | +} |
| 35 | + |
| 36 | +resource "oci_database_exadata_infrastructure" "primary_exadata_infrastructure" { |
| 37 | + activation_file = local_file.activation_file.filename |
| 38 | + admin_network_cidr = "192.168.0.0/16" |
| 39 | + cloud_control_plane_server1 = "10.32.88.1" |
| 40 | + cloud_control_plane_server2 = "10.32.88.3" |
| 41 | + compartment_id = var.compartment_ocid |
| 42 | + storage_count = 3 |
| 43 | + compute_count = 2 |
| 44 | + |
| 45 | + contacts { |
| 46 | + |
| 47 | + is_primary = "true" |
| 48 | + name = "Shravan Thatikonda" |
| 49 | + phone_number = "1234567891" |
| 50 | + } |
| 51 | + |
| 52 | + display_name = "PrimaryExaDataInfrastructure" |
| 53 | + dns_server = [ |
| 54 | + "10.231.225.65"] |
| 55 | + gateway = "10.32.88.5" |
| 56 | + infini_band_network_cidr = "10.31.8.0/21" |
| 57 | + netmask = "255.255.255.0" |
| 58 | + ntp_server = [ |
| 59 | + "10.231.225.76"] |
| 60 | + shape = "ExadataCC.X7" |
| 61 | + time_zone = "US/Pacific" |
| 62 | +} |
| 63 | + |
| 64 | +resource "oci_database_exadata_infrastructure" "standby_exadata_infrastructure" { |
| 65 | + activation_file = local_file.activation_file.filename |
| 66 | + admin_network_cidr = "192.168.0.0/16" |
| 67 | + cloud_control_plane_server1 = "10.32.88.1" |
| 68 | + cloud_control_plane_server2 = "10.32.88.3" |
| 69 | + compartment_id = var.compartment_ocid |
| 70 | + storage_count = 3 |
| 71 | + compute_count = 2 |
| 72 | + |
| 73 | + contacts { |
| 74 | + |
| 75 | + is_primary = "true" |
| 76 | + name = "John Doe" |
| 77 | + phone_number = "1234567891" |
| 78 | + } |
| 79 | + |
| 80 | + display_name = "StandbyExaDataInfrastructure" |
| 81 | + dns_server = [ |
| 82 | + "10.231.225.65"] |
| 83 | + gateway = "10.32.88.5" |
| 84 | + infini_band_network_cidr = "10.31.8.0/21" |
| 85 | + netmask = "255.255.255.0" |
| 86 | + ntp_server = [ |
| 87 | + "10.231.225.76"] |
| 88 | + shape = "ExadataCC.X7" |
| 89 | + time_zone = "US/Pacific" |
| 90 | +} |
| 91 | + |
| 92 | +resource "oci_database_vm_cluster_network" "primary_vm_cluster_network" { |
| 93 | + compartment_id = var.compartment_ocid |
| 94 | + display_name = "primaryVmClusterRecommendedNetwork" |
| 95 | + dns = [ |
| 96 | + "192.168.10.10"] |
| 97 | + ntp = [ |
| 98 | + "192.168.10.20"] |
| 99 | + |
| 100 | + exadata_infrastructure_id = oci_database_exadata_infrastructure.primary_exadata_infrastructure.id |
| 101 | + |
| 102 | + scans { |
| 103 | + hostname = "primary-prefix-nsubz-scan" |
| 104 | + ips = [ |
| 105 | + "192.168.19.7", |
| 106 | + "192.168.19.6", |
| 107 | + "192.168.19.8", |
| 108 | + ] |
| 109 | + port = 1521 |
| 110 | + scan_listener_port_tcp = 1521 |
| 111 | + scan_listener_port_tcp_ssl = 2484 |
| 112 | + } |
| 113 | + vm_networks { |
| 114 | + domain_name = "oracle.com" |
| 115 | + gateway = "192.169.20.1" |
| 116 | + netmask = "255.255.0.0" |
| 117 | + network_type = "BACKUP" |
| 118 | + nodes { |
| 119 | + hostname = "myprefix2-cghdm1" |
| 120 | + ip = "192.169.19.18" |
| 121 | + db_server_id = data.oci_database_db_servers.primary_db_servers.db_servers.0.id |
| 122 | + } |
| 123 | + nodes { |
| 124 | + hostname = "myprefix2-cghdm2" |
| 125 | + ip = "192.169.19.20" |
| 126 | + db_server_id = data.oci_database_db_servers.primary_db_servers.db_servers.1.id |
| 127 | + |
| 128 | + } |
| 129 | + vlan_id = "11" |
| 130 | + } |
| 131 | + vm_networks { |
| 132 | + domain_name = "oracle.com" |
| 133 | + gateway = "192.168.20.1" |
| 134 | + netmask = "255.255.0.0" |
| 135 | + network_type = "CLIENT" |
| 136 | + nodes { |
| 137 | + hostname = "primaryprefix1-r64zc1" |
| 138 | + ip = "192.168.19.10" |
| 139 | + vip = "192.168.19.11" |
| 140 | + vip_hostname = "myprefix1-r64zc1-vip" |
| 141 | + db_server_id = data.oci_database_db_servers.primary_db_servers.db_servers.0.id |
| 142 | + } |
| 143 | + nodes { |
| 144 | + hostname = "primaryprefix1-r64zc2" |
| 145 | + ip = "192.168.19.14" |
| 146 | + vip = "192.168.19.15" |
| 147 | + vip_hostname = "primaryprefix1-r64zc2-vip" |
| 148 | + db_server_id = data.oci_database_db_servers.primary_db_servers.db_servers.1.id |
| 149 | + } |
| 150 | + vlan_id = "10" |
| 151 | + } |
| 152 | + #Optional |
| 153 | + defined_tags = { |
| 154 | + "${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}" = "updatedvalue" |
| 155 | + } |
| 156 | + freeform_tags = { |
| 157 | + "Department" = "Accounting" |
| 158 | + } |
| 159 | + validate_vm_cluster_network = true |
| 160 | +} |
| 161 | + |
| 162 | +resource "oci_database_vm_cluster_network" "standby_vm_cluster_network" { |
| 163 | + compartment_id = var.compartment_ocid |
| 164 | + display_name = "standbyVmClusterRecommendedNetwork" |
| 165 | + dns = [ |
| 166 | + "192.168.10.10"] |
| 167 | + ntp = [ |
| 168 | + "192.168.10.20"] |
| 169 | + |
| 170 | + exadata_infrastructure_id = oci_database_exadata_infrastructure.standby_exadata_infrastructure.id |
| 171 | + |
| 172 | + scans { |
| 173 | + hostname = "standby-prefix-nsubz-scan" |
| 174 | + ips = [ |
| 175 | + "192.168.19.7", |
| 176 | + "192.168.19.6", |
| 177 | + "192.168.19.8", |
| 178 | + ] |
| 179 | + port = 1521 |
| 180 | + scan_listener_port_tcp = 1521 |
| 181 | + scan_listener_port_tcp_ssl = 2484 |
| 182 | + } |
| 183 | + vm_networks { |
| 184 | + domain_name = "oracle.com" |
| 185 | + gateway = "192.169.20.1" |
| 186 | + netmask = "255.255.0.0" |
| 187 | + network_type = "BACKUP" |
| 188 | + nodes { |
| 189 | + hostname = "myprefix2-cghdm1" |
| 190 | + ip = "192.169.19.18" |
| 191 | + db_server_id = data.oci_database_db_servers.standby_db_servers.db_servers.0.id |
| 192 | + } |
| 193 | + nodes { |
| 194 | + hostname = "myprefix2-cghdm2" |
| 195 | + ip = "192.169.19.20" |
| 196 | + db_server_id = data.oci_database_db_servers.standby_db_servers.db_servers.1.id |
| 197 | + } |
| 198 | + vlan_id = "11" |
| 199 | + } |
| 200 | + vm_networks { |
| 201 | + domain_name = "oracle.com" |
| 202 | + gateway = "192.168.20.1" |
| 203 | + netmask = "255.255.0.0" |
| 204 | + network_type = "CLIENT" |
| 205 | + nodes { |
| 206 | + hostname = "standbyprefix1-r64zc1" |
| 207 | + ip = "192.168.19.10" |
| 208 | + vip = "192.168.19.11" |
| 209 | + vip_hostname = "standbyprefix1-r64zc1-vip" |
| 210 | + db_server_id = data.oci_database_db_servers.standby_db_servers.db_servers.0.id |
| 211 | + |
| 212 | + } |
| 213 | + nodes { |
| 214 | + hostname = "standbyprefix1-r64zc2" |
| 215 | + ip = "192.168.19.14" |
| 216 | + vip = "192.168.19.15" |
| 217 | + vip_hostname = "standbyprefix1-r64zc2-vip" |
| 218 | + db_server_id = data.oci_database_db_servers.standby_db_servers.db_servers.1.id |
| 219 | + |
| 220 | + } |
| 221 | + |
| 222 | + vlan_id = "10" |
| 223 | + } |
| 224 | + #Optional |
| 225 | + defined_tags = { |
| 226 | + "${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}" = "updatedvalue" |
| 227 | + } |
| 228 | + freeform_tags = { |
| 229 | + "Department" = "Accounting" |
| 230 | + } |
| 231 | + validate_vm_cluster_network = true |
| 232 | +} |
| 233 | + |
| 234 | +resource "oci_database_autonomous_vm_cluster" "primary_autonomous_vm_cluster" { |
| 235 | + #Required |
| 236 | + compartment_id = var.compartment_ocid |
| 237 | + display_name = "PrimaryVmCluster" |
| 238 | + exadata_infrastructure_id = oci_database_exadata_infrastructure.primary_exadata_infrastructure.id |
| 239 | + vm_cluster_network_id = oci_database_vm_cluster_network.primary_vm_cluster_network.id |
| 240 | + cpu_core_count_per_node = "20" |
| 241 | + autonomous_data_storage_size_in_tbs = "2.0" |
| 242 | + memory_per_oracle_compute_unit_in_gbs = "5" |
| 243 | + total_container_databases = "2" |
| 244 | + #Optional |
| 245 | + is_local_backup_enabled = "false" |
| 246 | + license_model = "LICENSE_INCLUDED" |
| 247 | + time_zone = "US/Pacific" |
| 248 | + defined_tags = { |
| 249 | + "${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}" = "SampleTagValue" |
| 250 | + } |
| 251 | + |
| 252 | + freeform_tags = { |
| 253 | + "Department" = "Finance" |
| 254 | + } |
| 255 | +} |
| 256 | + |
| 257 | +resource "oci_database_autonomous_vm_cluster" "standby_autonomous_vm_cluster" { |
| 258 | + #Required |
| 259 | + compartment_id = var.compartment_ocid |
| 260 | + display_name = "StandbyVmCluster" |
| 261 | + exadata_infrastructure_id = oci_database_exadata_infrastructure.standby_exadata_infrastructure.id |
| 262 | + vm_cluster_network_id = oci_database_vm_cluster_network.standby_vm_cluster_network.id |
| 263 | + cpu_core_count_per_node = "20" |
| 264 | + autonomous_data_storage_size_in_tbs = "2.0" |
| 265 | + memory_per_oracle_compute_unit_in_gbs = "5" |
| 266 | + total_container_databases = "2" |
| 267 | + #Optional |
| 268 | + is_local_backup_enabled = "false" |
| 269 | + license_model = "LICENSE_INCLUDED" |
| 270 | + time_zone = "US/Pacific" |
| 271 | + defined_tags = { |
| 272 | + "${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}" = "SampleTagValue" |
| 273 | + } |
| 274 | + |
| 275 | + freeform_tags = { |
| 276 | + "Department" = "Finance" |
| 277 | + } |
| 278 | +} |
| 279 | + |
| 280 | +data "oci_database_db_servers" "primary_db_servers" { |
| 281 | + #Required |
| 282 | + compartment_id = var.compartment_ocid |
| 283 | + exadata_infrastructure_id = oci_database_exadata_infrastructure.primary_exadata_infrastructure.id |
| 284 | +} |
| 285 | + |
| 286 | +data "oci_database_db_servers" "standby_db_servers" { |
| 287 | + #Required |
| 288 | + compartment_id = var.compartment_ocid |
| 289 | + exadata_infrastructure_id = oci_database_exadata_infrastructure.standby_exadata_infrastructure.id |
| 290 | +} |
| 291 | + |
| 292 | +resource "oci_database_autonomous_container_database" "test_autonomous_container_database_primary" { |
| 293 | + #Required |
| 294 | + autonomous_vm_cluster_id = oci_database_autonomous_vm_cluster.primary_autonomous_vm_cluster.id |
| 295 | + display_name = "PrimaryACD" |
| 296 | + patch_model = "RELEASE_UPDATES" |
| 297 | + db_version = "19.25.0.1.0" |
| 298 | + db_name = "PRIMARY" |
| 299 | + |
| 300 | + #Optional |
| 301 | + backup_config { |
| 302 | + backup_destination_details { |
| 303 | + type = "LOCAL" |
| 304 | + } |
| 305 | + recovery_window_in_days = "7" |
| 306 | + } |
| 307 | + |
| 308 | + compartment_id = var.compartment_ocid |
| 309 | + freeform_tags = var.autonomous_database_freeform_tags |
| 310 | + service_level_agreement_type = "STANDARD" |
| 311 | + |
| 312 | + maintenance_window_details { |
| 313 | + preference = "CUSTOM_PREFERENCE" |
| 314 | + |
| 315 | + days_of_week { |
| 316 | + name = "MONDAY" |
| 317 | + } |
| 318 | + |
| 319 | + hours_of_day = ["4"] |
| 320 | + |
| 321 | + months { |
| 322 | + name = "JANUARY" |
| 323 | + } |
| 324 | + |
| 325 | + months { |
| 326 | + name = "APRIL" |
| 327 | + } |
| 328 | + |
| 329 | + months { |
| 330 | + name = "JULY" |
| 331 | + } |
| 332 | + |
| 333 | + months { |
| 334 | + name = "OCTOBER" |
| 335 | + } |
| 336 | + |
| 337 | + weeks_of_month = ["2"] |
| 338 | + } |
| 339 | + version_preference = "LATEST_RELEASE_UPDATE" |
| 340 | + |
| 341 | + lifecycle { |
| 342 | + ignore_changes = [ |
| 343 | + peer_autonomous_container_database_display_name, |
| 344 | + peer_autonomous_exadata_infrastructure_id, |
| 345 | + peer_autonomous_vm_cluster_id, |
| 346 | + peer_cloud_autonomous_vm_cluster_id, |
| 347 | + peer_db_unique_name, |
| 348 | + service_level_agreement_type, |
| 349 | + protection_mode, |
| 350 | + peer_autonomous_container_database_backup_config, |
| 351 | + ] |
| 352 | + } |
| 353 | + |
| 354 | +} |
| 355 | + |
| 356 | +resource "oci_database_autonomous_container_database_add_standby" "test_autonomous_container_database_add_standby" { |
| 357 | + autonomous_container_database_id = oci_database_autonomous_container_database.test_autonomous_container_database_primary.id |
| 358 | + fast_start_fail_over_lag_limit_in_seconds = "0" |
| 359 | + is_automatic_failover_enabled = "true" |
| 360 | + peer_autonomous_container_database_backup_config { |
| 361 | + backup_destination_details { |
| 362 | + type = "LOCAL" |
| 363 | + } |
| 364 | + recovery_window_in_days = "7" |
| 365 | + } |
| 366 | + peer_autonomous_container_database_compartment_id = var.compartment_ocid |
| 367 | + peer_autonomous_container_database_display_name = "FirstStandby" |
| 368 | + peer_autonomous_vm_cluster_id = oci_database_autonomous_vm_cluster.standby_autonomous_vm_cluster.id |
| 369 | + protection_mode = "MAXIMUM_AVAILABILITY" |
| 370 | + standby_maintenance_buffer_in_days = "7" |
| 371 | +} |
| 372 | + |
| 373 | +resource "oci_database_autonomous_container_database_snapshot_standby" "test_autonomous_container_database_snapshot_standby" { |
| 374 | + autonomous_container_database_id = oci_database_autonomous_container_database_add_standby.test_autonomous_container_database_add_standby.dataguard_group_members.1.autonomous_container_database_id |
| 375 | + role = "SNAPSHOT_STANDBY" |
| 376 | + connection_strings_type="SNAPSHOT_SERVICES" |
| 377 | + depends_on = [oci_database_autonomous_container_database_add_standby.test_autonomous_container_database_add_standby] |
| 378 | +} |
| 379 | + |
| 380 | +resource "oci_database_autonomous_container_database_snapshot_standby" "test_autonomous_container_database_regular_standby" { |
| 381 | + autonomous_container_database_id = oci_database_autonomous_container_database_add_standby.test_autonomous_container_database_add_standby.dataguard_group_members.1.autonomous_container_database_id |
| 382 | + role = "STANDBY" |
| 383 | + depends_on = [oci_database_autonomous_container_database_snapshot_standby.test_autonomous_container_database_snapshot_standby] |
| 384 | +} |
| 385 | + |
| 386 | +#### End Resources #### |
| 387 | +####################### |
| 388 | + |
| 389 | + |
| 390 | + |
| 391 | + |
| 392 | + |
0 commit comments