Skip to content

Commit d384cb4

Browse files
Merge pull request #2 from nick-mathison/2025-tf-example-updates
adding Nick's example changes
2 parents f33558b + bf9c74b commit d384cb4

File tree

8 files changed

+143
-12
lines changed

8 files changed

+143
-12
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
This file show cases how to provision a full stack of deployment including an Azure VM, add the environment Delphix, ingest an Oracle dSource, and provision 1 VDB.
2+
3+
This is a great example of disaster recovery scenarios or showcasing the full power of Delphix.
4+
5+
Note: This example will not work out of the box, by default, as you might not have the same Oracle configuration and the Azure VM is half implementated. Consult the comments within the file for further direction.
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
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+
}
File renamed without changes.

examples/simple-provision/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_providers {
33
delphix = {
44
source = "delphix-integrations/delphix"
5-
version = "3.1.0"
5+
version = ">=3.1.0"
66
}
77
}
88
}

examples/vdb/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
terraform {
22
required_providers {
33
delphix = {
4-
version = "1.0-beta"
4+
version = ">=3.3.2"
55
source = "delphix.com/dct/delphix"
66
}
77
}

examples/vdb/postgresql/bookmark/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ provider "delphix" {
1818
}
1919

2020
resource "delphix_vdb" "example" {
21-
bookmark_id = ""
21+
bookmark_id = "bookmark_name"
2222
name = "vdb_to_be_created"
2323
source_data_id = "dsource-name"
2424
vdb_restart = true

examples/vdb_group/main.tf

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,50 @@
11
/**
2-
* Summary: This template showcases the properties available when creating an app data dsource.
2+
* Summary: This template showcases a simple example to
3+
* 1) Set local VDB variables
4+
* 2) Provision 5 VDBs using a for_each loop
5+
* 3) Place the 5 VDBs into a single VDB Group using a for loop
36
*/
47

58
terraform {
69
required_providers {
710
delphix = {
8-
version = "VERSION"
11+
version = ">=3.3.2"
912
source = "delphix-integrations/delphix"
1013
}
1114
}
1215
}
1316

17+
// *** Requirement***: Update the key and host with valid credentials.
1418
provider "delphix" {
1519
tls_insecure_skip = true
1620
key = "1.XXXX"
1721
host = "HOSTNAME"
1822
}
1923

2024

25+
// Create variables for the VDBs.
26+
// *** Requirement***: Update the Snapshot ID with a valid Snapshot. The same snapshot can be reused.
2127
locals {
2228
vdbs = {
29+
"vdb1" = { snapshot_id = "6-ORACLE_DB_CONTAINER-7", name = "us1" },
30+
"vdb2" = { snapshot_id = "6-ORACLE_DB_CONTAINER-1", name = "us2" },
31+
"vdb3" = { snapshot_id = "6-ORACLE_DB_CONTAINER-5", name = "us3" },
2332
"vdb4" = { snapshot_id = "6-ORACLE_DB_CONTAINER-21", name = "us4" },
24-
"vdb5" = { snapshot_id = "6-ORACLE_DB_CONTAINER-23", name = "us5" },
25-
"vdb1" = { snapshot_id = "6-ORACLE_DB_CONTAINER-7", name = "us1" },
26-
"vdb2" = { snapshot_id = "6-ORACLE_DB_CONTAINER-1", name = "us2" },
27-
"vdb3" = { snapshot_id = "6-ORACLE_DB_CONTAINER-5", name = "us3" }
33+
"vdb5" = { snapshot_id = "6-ORACLE_DB_CONTAINER-23", name = "us5" }
2834
}
2935
}
3036

31-
resource "delphix_vdb" "example" {
37+
// Provision by Snapshot the 5 VDBs in a loop.
38+
// Instead of a for_each loop, you could optionally copy this resource 4 more times and replace the values directly.
39+
resource "delphix_vdb" "vdb_provision_loop" {
3240
for_each = try(local.vdbs, {})
3341
name = each.value.name
3442
source_data_id = each.value.snapshot_id
3543
auto_select_repository = true
3644

3745
}
38-
39-
#sort helps to maintain thr order of the vdbs to avoid erroneous drift
46+
// Place the 5 VDBs in a single VDB Group.
47+
// The sort() function helps to maintain the order of the vdbs to avoid erroneous drift.
4048
resource "delphix_vdb_group" "this" {
4149
name = "random"
4250
vdb_ids = sort(flatten([for vdb in delphix_vdb.example : vdb.id]))

0 commit comments

Comments
 (0)