delphix-integrations / terraform-provider-delphix

Repository for Delphix Terraform Provider built on DCT APIs.
https://integrations.delphix.com
11 stars 9 forks source link

HUBS-1692 | Additional params support for provision #54

Closed Uddipaan-Hazarika closed 1 year ago

Uddipaan-Hazarika commented 1 year ago

Problem:

There are some newly added params for RAC and Multi Tenant TDE oracle vdb provisioning that we didnt support yet.

Solution:

Added support for the below params: make_current_account_owner config_params additional_mount_points vcdb_tde_key_identifier cdb_tde_keystore_password target_vcdb_tde_keystore_path tde_key_identifier tde_exported_key_file_secret parent_tde_keystore_password parentTdeKeystorePath oracle_rac_custom_env_vars oracle_rac_custom_env_files

Testing

These tests are also properly documented in the respective JIRA for it. i.e, https://delphix.atlassian.net/browse/HUBS-1694 below is the list of validation along with the tf file configured: Additional mount point update tf: `variable "tags_var" { type = set(object({ key = string value = string }))

default = [ { "key": "string", "value": "string", }, { "key": "string1", "value": "string1", } ] }

resource "delphix_vdb" "test_postgres_tf" { auto_select_repository = true source_data_id = "4-APPDATA_CONTAINER-21" name = "test_postgres_tf2"

dynamic "tags" { for_each = var.tags_var content{ key = tags.value.key value = tags.value.value } }

appdata_source_params = jsonencode({ mountLocation = "/mnt/GAT" postgresPort = 5434 configSettingsStg = [{ propertyName: "timezone", value:"GMT", commentProperty:false}] })

additional_mount_points { shared_path = "/" mount_path = "/work" environment_id = "4-UNIX_HOST_ENVIRONMENT-14" } }`

console: `uddipaan.hazarika@Uddipaan-Hazarikas-MacBook-Pro snapshot % terraform apply --auto-approve delphix_vdb.test_postgres_tf: Refreshing state... [id=4-APPDATA_CONTAINER-25]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: ~ update in-place

Terraform will perform the following actions:

delphix_vdb.test_postgres_tf will be updated in-place

~ resource "delphix_vdb" "test_postgres_tf" { id = "4-APPDATA_CONTAINER-25" name = "test_postgres_tf2"

(12 unchanged attributes hidden)

  + additional_mount_points {
      + environment_id = "4-UNIX_HOST_ENVIRONMENT-14"
      + mount_path     = "/work"
      + shared_path    = "/"
    }

    # (2 unchanged blocks hidden)
}

Plan: 0 to add, 1 to change, 0 to destroy. delphix_vdb.test_postgres_tf: Modifying... [id=4-APPDATA_CONTAINER-25] delphix_vdb.test_postgres_tf: Still modifying... [id=4-APPDATA_CONTAINER-25, 10s elapsed] delphix_vdb.test_postgres_tf: Modifications complete after 14s [id=4-APPDATA_CONTAINER-25]

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.`

appdata_config_param update: tf: 'resource "delphix_vdb" "test_postgres_tf" { auto_select_repository = true source_data_id = "4-APPDATA_CONTAINER-21" name = "test_postgres_tf3"

dynamic "tags" { for_each = var.tags_var content{ key = tags.value.key value = tags.value.value } }

appdata_source_params = jsonencode({ mountLocation = "/mnt/GAT" postgresPort = 5434 configSettingsStg = [{ propertyName: "timezone", value:"GMT", commentProperty:false}] })

appdata_config_params = jsonencode({ name = "Postgres-5434 - /mnt/GAT/data2" })}'

console: `uddipaan.hazarika@Uddipaan-Hazarikas-MacBook-Pro snapshot % terraform apply --auto-approve delphix_vdb.test_postgres_tf: Refreshing state... [id=4-APPDATA_CONTAINER-47]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: ~ update in-place

Terraform will perform the following actions:

delphix_vdb.test_postgres_tf will be updated in-place

~ resource "delphix_vdb" "test_postgres_tf" { ~ appdata_config_params = jsonencode( ~ { ~ name = "Postgres-5434 - /mnt/GAT/data" -> "Postgres-5434 - /mnt/GAT/data2" } ) id = "4-APPDATA_CONTAINER-47" name = "test_postgres_tf3"

(13 unchanged attributes hidden)

    # (2 unchanged blocks hidden)
}

Plan: 0 to add, 1 to change, 0 to destroy. delphix_vdb.test_postgres_tf: Modifying... [id=4-APPDATA_CONTAINER-47] delphix_vdb.test_postgres_tf: Still modifying... [id=4-APPDATA_CONTAINER-47, 10s elapsed] delphix_vdb.test_postgres_tf: Still modifying... [id=4-APPDATA_CONTAINER-47, 20s elapsed] delphix_vdb.test_postgres_tf: Still modifying... [id=4-APPDATA_CONTAINER-47, 30s elapsed] delphix_vdb.test_postgres_tf: Modifications complete after 31s [id=4-APPDATA_CONTAINER-47]`

Config_params: tf: `variable "tags_var" { type = set(object({ key = string value = string }))

default = [ { "key": "string", "value": "string", }, { "key": "string1", "value": "string1", } ] }

resource "delphix_vdb" "test_postgres_tf" { auto_select_repository = true source_data_id = "4-APPDATA_CONTAINER-21" name = "test_postgres_tf3"

dynamic "tags" { for_each = var.tags_var content{ key = tags.value.key value = tags.value.value } }

appdata_source_params = jsonencode({ mountLocation = "/mnt/GAT" postgresPort = 5434 configSettingsStg = [{ propertyName: "timezone", value:"GMT", commentProperty:false}] })

appdata_config_params = jsonencode({ name = "Postgres-5434 - /mnt/GAT/data2" })

config_params = jsonencode({ processes = 150 })} `

console: `uddipaan.hazarika@Uddipaan-Hazarikas-MacBook-Pro snapshot % terraform apply --auto-approve

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:

Terraform will perform the following actions:

delphix_vdb.test_postgres_tf will be created

Plan: 1 to add, 0 to change, 0 to destroy. delphix_vdb.test_postgres_tf: Creating... delphix_vdb.test_postgres_tf: Still creating... [10s elapsed] delphix_vdb.test_postgres_tf: Still creating... [20s elapsed] delphix_vdb.test_postgres_tf: Creation complete after 27s [id=4-APPDATA_CONTAINER-48]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.`

Update config params: tf: `uddipaan.hazarika@Uddipaan-Hazarikas-MacBook-Pro snapshot % terraform apply --auto-approve delphix_vdb.test_postgres_tf: Refreshing state... [id=4-APPDATA_CONTAINER-48]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: ~ update in-place

Terraform will perform the following actions:

delphix_vdb.test_postgres_tf will be updated in-place

~ resource "delphix_vdb" "test_postgres_tf" { ~ appdata_config_params = jsonencode( ~ { ~ name = "Postgres-5434 - /mnt/GAT/data" -> "Postgres-5434 - /mnt/GAT/data2" } ) ~ config_params = jsonencode( ~ null -> {

Plan: 0 to add, 1 to change, 0 to destroy. delphix_vdb.test_postgres_tf: Modifying... [id=4-APPDATA_CONTAINER-48] delphix_vdb.test_postgres_tf: Still modifying... [id=4-APPDATA_CONTAINER-48, 10s elapsed] delphix_vdb.test_postgres_tf: Modifications complete after 20s [id=4-APPDATA_CONTAINER-48]

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.`

TDE Params: (just validating the DCT api request payload) tf: `resource "delphix_vdb" "vdb_name" { provision_type = "snapshot" auto_select_repository = true source_data_id = "6-ORACLE_DB_CONTAINER-2" //4-ORACLE_DB_CONTAINER-27

pre_refresh { name = "n" command = "time" shell = "bash" }

vcdb_name = "my_vcdb" //(MT) vcdb_database_name = "VCCD_6QQ" //(MT) target_vcdb_tde_keystore_path = "/foo/cdb/tde" //(MT) parent_tde_keystore_password = "delphix" //(MT) cdb_tde_keystore_password = "delphix" //(MT) tde_key_identifier = "inbakooufdfekobwawxmwdgmjjypmjinvbc" //(MT) vcdb_tde_key_identifier = "inbakooufdfekobwawxmwdgmjjypmjinpoc" //(MT) parent_tde_keystore_path = "/foo/bar/tde" //(MT) tde_exported_key_file_secret = "delphix" //(MT) }`

Payload: `POST /v3/vdbs/provision_by_snapshot HTTP/1.1 Host: dct.dlpxdc.co User-Agent: Terraform/1.3.9 (+https://www.terraform.io/) Terraform-Plugin-SDK/2.10.1 terraform-provider-delphix/dev Content-Length: 553 Accept: application/json Authorization: apk 1.wYP5M7oC8yVFrgGMCWmMidsoPqLULH3fCVghpdlr95pP203pqgLO3EM6hAOQSf4V Content-Type: application/json X-Dct-Client-Name: Terraform Accept-Encoding: gzip

{"auto_select_repository":true,"cdb_tde_keystore_password":"delphix","make_current_account_owner":true,"parentTdeKeystorePath":"/foo/bar/tde","parent_tde_keystore_password":"delphix","pre_refresh":[{"command":"time","name":"n","shell":"bash"}],"source_data_id":"6-ORACLE_DB_CONTAINER-2","target_vcdb_tde_keystore_path":"/foo/cdb/tde","tde_exported_key_file_secret":"delphix","tde_key_identifier":"inbakooufdfekobwawxmwdgmjjypmjinvbc","vcdb_database_name":"VCCD_6QQ","vcdb_name":"my_vcdb","vcdb_tde_key_identifier":"inbakooufdfekobwawxmwdgmjjypmjinpoc"}`

RAC PARAMS: tf: `resource "delphix_vdb" "vdb_name" { provision_type = "snapshot" auto_select_repository = true source_data_id = "4-ORACLE_DB_CONTAINER-51" //4-ORACLE_DB_CONTAINER-27

pre_refresh { name = "n" command = "time" shell = "bash" }

oracle_rac_custom_env_vars { node_id = "ORACLE_CLUSTER_NODE-3" name = "name" value = "value" } oracle_rac_custom_env_files { node_id = "ORACLE_CLUSTER_NODE-3" path_parameters = "mnt/provision" } }`

Payload: {"auto_select_repository":true,"make_current_account_owner":true,"oracle_rac_custom_env_files":[{"node_id":"ORACLE_CLUSTER_NODE-3","path_parameters":"mnt/provision"}],"oracle_rac_custom_env_vars":[{"name":"name","node_id":"ORACLE_CLUSTER_NODE-3","value":"value"}],"pre_refresh":[{"command":"time","name":"n","shell":"bash"}],"source_data_id":"4-ORACLE_DB_CONTAINER-51"}

make_current_owner: `uddipaan.hazarika@Uddipaan-Hazarikas-MacBook-Pro snapshot % terraform apply --auto-approve

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:

create

Terraform will perform the following actions:

delphix_vdb.test_postgres_tf will be created

resource "delphix_vdb" "test_postgres_tf" {

appdata_config_params = jsonencode( { + name = "Postgres-5434 - /mnt/GAT/data2" })

appdata_source_params = jsonencode( { + configSettingsStg = [ + { + commentProperty = false + propertyName = "timezone" + value = "GMT" }, ] + mountLocation = "/mnt/GAT" + postgresPort = 5434 })

auto_select_repository = true

config_params = jsonencode( { + processes = 151 })

creation_date = (known after apply)

database_type = (known after apply)

database_version = (known after apply)

engine_id = (known after apply)

environment_id = (known after apply)

fqdn = (known after apply)

group_name = (known after apply)

id = (known after apply)

ip_address = (known after apply)

make_current_account_owner = true

name = "test_postgres_tf3"

parent_id = (known after apply)

provision_type = "snapshot"

source_data_id = "4-APPDATA_CONTAINER-21"

tags {

key = "string"

value = "string"}

tags {

key = "string1"

value = "string1"}}

Plan: 1 to add, 0 to change, 0 to destroy. delphix_vdb.test_postgres_tf: Creating... delphix_vdb.test_postgres_tf: Still creating... [10s elapsed] delphix_vdb.test_postgres_tf: Still creating... [20s elapsed] delphix_vdb.test_postgres_tf: Still creating... [30s elapsed] delphix_vdb.test_postgres_tf: Still creating... [40s elapsed] delphix_vdb.test_postgres_tf: Creation complete after 46s [id=4-APPDATA_CONTAINER-49]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed. uddipaan.hazarika@Uddipaan-Hazarikas-MacBook-Pro snapshot % terraform apply --auto-approve delphix_vdb.test_postgres_tf: Refreshing state... [id=4-APPDATA_CONTAINER-49]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: ~ update in-place

Terraform will perform the following actions:

delphix_vdb.test_postgres_tf will be updated in-place

~ resource "delphix_vdb" "test_postgres_tf" { ~ appdata_config_params = jsonencode( ~ { ~ name = "Postgres-5434 - /mnt/GAT/data" -> "Postgres-5434 - /mnt/GAT/data2" } ) ~ config_params = jsonencode( ~ null -> {

Plan: 0 to add, 1 to change, 0 to destroy. delphix_vdb.test_postgres_tf: Modifying... [id=4-APPDATA_CONTAINER-49] delphix_vdb.test_postgres_tf: Still modifying... [id=4-APPDATA_CONTAINER-49, 10s elapsed] delphix_vdb.test_postgres_tf: Modifications complete after 19s [id=4-APPDATA_CONTAINER-49]

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.`