|
| 1 | +/** |
| 2 | +* Summary: This template showcases a mock example to |
| 3 | +* 1) Provision an Azure VM. |
| 4 | +* 2) Create a Target environment from that VM. |
| 5 | +* 3) Link and Sync a dSource. Create a new snapshot. |
| 6 | +* 4) Provision a new VDB from that Oracle dSource's snapshot. |
| 7 | +* *** Warning: This is only an example. It will not work out of the box.*** |
| 8 | +*/ |
| 9 | + |
| 10 | +terraform { |
| 11 | + required_providers { |
| 12 | + delphix = { |
| 13 | + version = ">=3.3.2" |
| 14 | + source = "delphix-integrations/delphix" |
| 15 | + } |
| 16 | + azurerm = { |
| 17 | + source = "hashicorp/azurerm" |
| 18 | + version = "~>3.0" |
| 19 | + } |
| 20 | + } |
| 21 | +} |
| 22 | + |
| 23 | +# *** Requirement***: Various variables used throughout the example. |
| 24 | +locals { |
| 25 | + dct-key = "<1.XXXX>" |
| 26 | + dct-host = "<DCT HOSTNAME>" |
| 27 | + vm-hostname = "oracle-linux-host" |
| 28 | + vm-username = "<USERNAME>" |
| 29 | + vm-password = "<PASSWORD>" |
| 30 | + source-db-name = "<SOURCE DATABASE NAME>" // Name of Database dynamically identified on the source environment |
| 31 | + dsource-name = "full_deploy_dsource" |
| 32 | + vdb-name = "full_deploy_vdb" |
| 33 | +} |
| 34 | + |
| 35 | +provider "delphix" { |
| 36 | + tls_insecure_skip = true |
| 37 | + key = local.dct-key |
| 38 | + host = loca.dct-host |
| 39 | +} |
| 40 | + |
| 41 | + |
| 42 | +# *** Requirement ***: This is an example only and will not work without significant modification and additional files. |
| 43 | +# See the official documentation here for a full VM deployment: https://learn.microsoft.com/en-us/azure/virtual-machines/linux/quick-create-terraform |
| 44 | +# The VM creation terraform resource can be replaced with an equivalent resource GCP, AWS, VMWare, etc that's compatible with Delphix Continuous Data. |
| 45 | +# Consult your organization's DevOps expert for guidance on how to provision a VM that's approved for your company. |
| 46 | +resource "azurerm_linux_virtual_machine" "azure_vm" { |
| 47 | + name = "Delphix Oracle Target" |
| 48 | + location = azurerm_resource_group.rg.location // Not provided |
| 49 | + resource_group_name = azurerm_resource_group.rg.name // Not provided |
| 50 | + network_interface_ids = [azurerm_network_interface.my_terraform_nic.id] // Not provided |
| 51 | + size = "Standard_DS1_v2" |
| 52 | + |
| 53 | + os_disk { |
| 54 | + name = "myOsDisk" |
| 55 | + caching = "ReadWrite" |
| 56 | + storage_account_type = "Premium_LRS" |
| 57 | + } |
| 58 | + |
| 59 | + source_image_reference { |
| 60 | + publisher = "Canonical" |
| 61 | + offer = "0001-com-ubuntu-server-jammy" |
| 62 | + sku = "22_04-lts-gen2" |
| 63 | + version = "latest" |
| 64 | + } |
| 65 | + |
| 66 | + computer_name = local.vm-hostname |
| 67 | + admin_username = local.vm-username |
| 68 | + admin_password = local.vm-password // Not secure. Example only |
| 69 | + |
| 70 | + boot_diagnostics { |
| 71 | + storage_account_uri = azurerm_storage_account.my_storage_account.primary_blob_endpoint // Not provided |
| 72 | + } |
| 73 | +} |
| 74 | + |
| 75 | +# Add the Azure VM as a Delphix environment. |
| 76 | +# Docs: https://registry.terraform.io/providers/delphix-integrations/delphix/latest/docs/resources/environment |
| 77 | +resource "delphix_environment" "linux-oracle-target" { |
| 78 | + name = local.vm-hostname |
| 79 | + os_name = "UNIX" |
| 80 | + hostname = local.vm-hostname |
| 81 | + username = local.vm-username |
| 82 | + password = local.vm-password |
| 83 | + engine_id = 1 |
| 84 | + toolkit_path = "/home/delphix_os/toolkit" |
| 85 | + description = "This is a unix target for the Oracle VDB." |
| 86 | + } |
| 87 | + |
| 88 | + |
| 89 | +# If we were ingesting a PostgreSQL (or AppData) database, we would need to configure a Source Config (Source) |
| 90 | +# resource "delphix_database_postgresql" "postgresql_source_config" { |
| 91 | +# name = local.source-db-name + "source config" |
| 92 | +# repository_value = "PostgreSQL Repo" |
| 93 | +# engine_value = "1" |
| 94 | +# environment_value = local.vm-hostname |
| 95 | +# } |
| 96 | + |
| 97 | +# Link and Sync the dSource and take a new snapshot |
| 98 | +# *** Requirement *** This is an Oracle dSource. Updates are likely required. |
| 99 | +# Docs: https://registry.terraform.io/providers/delphix-integrations/delphix/latest/docs/resources/oracle_dsource |
| 100 | +resource "delphix_oracle_dsource" "full_oracle_dsource" { |
| 101 | + name = local.dsource-name |
| 102 | + source_value = local.source-db-name |
| 103 | + group_id = "full_deployment_group" |
| 104 | + environment_user_id = local.vm-username |
| 105 | + log_sync_enabled = false |
| 106 | + link_now = true |
| 107 | + make_current_account_owner = true |
| 108 | +} |
| 109 | + |
| 110 | + |
| 111 | +# Provision by Snapshot the 1 Oracle VDB on the newly created environment |
| 112 | +# Docs: https://registry.terraform.io/providers/delphix-integrations/delphix/latest/docs/resources/vdb |
| 113 | +resource "delphix_vdb" "vdb_provision_loop" { |
| 114 | + name = local.vdb-name |
| 115 | + source_data_id = local.dsource-name |
| 116 | + environment_id = local.vm-hostname |
| 117 | + auto_select_repository = true |
| 118 | +} |
0 commit comments