diff --git a/.goreleaser.yml b/.goreleaser.yml index 6e58448..8e77634 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,7 +1,7 @@ # Visit https://goreleaser.com for documentation on how to customize this # behavior. env: - - PROVIDER_VERSION=3.3.0 + - PROVIDER_VERSION=3.3.1 before: hooks: # this is just an example and not a requirement for provider building/publishing diff --git a/docs/resources/database_postgresql.md b/docs/resources/database_postgresql.md index 5b880fc..1141198 100644 --- a/docs/resources/database_postgresql.md +++ b/docs/resources/database_postgresql.md @@ -67,7 +67,7 @@ resource "delphix_database_postgresql" "source" { * `key` - Key of the tag * `value` - Value of the tag -## Import (Beta) +## Import Use the [`import` block](https://developer.hashicorp.com/terraform/language/import) to add source configs created directly in Data Control Tower into a Terraform state file. @@ -79,5 +79,3 @@ import { } ``` -*This is a beta feature. Delphix offers no guarantees of support or compatibility.* - diff --git a/docs/resources/vdb.md b/docs/resources/vdb.md index 3ac8cb8..69d10e1 100644 --- a/docs/resources/vdb.md +++ b/docs/resources/vdb.md @@ -1,276 +1,242 @@ -# Resource: delphix_vdb - -In Delphix terminology, a virtual database (VDB) is a full read/write copy of the source data. It is created (provisioned) from either a dSource or another VDB's data snapshot. -A VDB is created and managed by the Delphix Continuous Data Engine. - -The VDB (delphix_vdb) resource allows Terraform to create, update, and delete Delphix VDBs. This specifically enables the `plan`, `apply`, `update`, and `destroy` Terraform commands. All supported parameters are listed below. - -## Example Usage -Provisioning can be done using one of three methods: provision by snapshot, timestamp, and bookmark. - -```hcl -# Provision a VDB using latest snapshot. - -resource "delphix_vdb" "vdb_name_provision_by_snapshot" { - auto_select_repository = true - source_data_id = "" - snapshot_id = "" # Leave empty to select the latest snapshot -} - -# Provision a VDB from a bookmark and on a Target environment - -resource "delphix_vdb" "vdb_name_provision_by_bookmark_on_target_environment" { - provision_type = "bookmark" - auto_select_repository = true - bookmark_id = "" - environment_id = "" -} - -# Provision a VDB using timestamp and configure post refresh hook - -resource "delphix_vdb" "vdb_name_provion_by_timestamp_with_hook" { - provision_type = "timestamp" - auto_select_repository = true - source_data_id = "" - timestamp = "2021-05-01T08:51:34.148000+00:00" # Timestamp must be available on the source dataset. - - post_refresh { - command = "echo \"Hello World\"" - name = "Sample Hook" - shell = "SHELL" - } -} - -``` - -## Argument Reference - -* `provision_type` - The type of provisioning to be carried out. Defaults to snapshot. Valid values are `[snapshot, bookmark, timestamp]` - -* `timestamp` - The point in time from which to execute the provision operation. Mutually exclusive with timestamp_in_database_timezone. If the timestamp is not set, selects the latest point. - -* `timestamp_in_database_timezone` - The point in time from which to execute the provision operation, expressed as a date-time in the timezone of the source database. Mutually exclusive with timestamp. - -* `snapshot_id` - The ID or name of the Snapshot from which to execute the provision operation. If the `snapshot_id` is empty or the paramter is not specified, the latest snapshot is automatically selected. - -* `bookmark_id` - The ID or name of the Bookmark from which to execute the provision operation. The Bookmark must contain only one VDB. - -* `source_data_id` - The ID or name of the source dataset (dSource, VDB, or Snapshot) to provision from. All other objects referenced by the following parameters must live on the same Continuous Data Engine as the chosen source. - -* `engine_id` - The ID or name of the Continuous Data Engine onto which to provision. If the source ID unambiguously identifies a source object, this parameter is unnecessary and ignored. - -* `target_group_id` - The ID of the Continuous Data Engine's Dataset Group into which the VDB will be provisioned. If empty, the "Unassigned" Dataset Group is used. - -* `name` - [Updatable] The unique name of the VDB. If empty, a name is randomly generated. - -* `environment_id` - The ID or name of the Target environment where to provision the VDB. If "repository_id" unambigously identifies a repository, then this value is ignored. - -* `environment_user_id` - [Updatable] The environment user ID to use to connect to the Target environment. - -* `repository_id` - The ID of the Target environment's repository where to provision the VDB. A repository typically corresponds to a database installation (Oracle home, database instance, etc). Setting this parameter may implicitly determines the environment where to provision the VDB. - -* `auto_select_repository` - TRUE or FALSE value to automatically select a compatible environment and repository. Mutually exclusive with "repository_id". - -* `pre_refresh` - [Updatable] The commands to execute on the Target environment before refreshing the VDB. This is a map of three parameters: - * `name` - Name of the hook. - * `command` - (Required, if hook is specified) Command to be executed. - * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]`. - -* `post_refresh` - [Updatable] The commands to execute on the Target environment after refreshing the VDB. This is a map of three parameters: - * `name` - Name of the hook. - * `command` - (Required, if hook is specified) Command to be executed. - * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]`. - -* `pre_rollback` - [Updatable] The commands to execute on the Target environment before a rollback on the VDB. This is a map of three parameters: - * `name` - Name of the hook. - * `command` - (Required, if hook is specified) Command to be executed. - * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]`. - -* `post_rollback` - [Updatable] The commands to execute on the Target environment after a rollback on the VDB. This is a map of three parameters: - * `name` - Name of the hook. - * `command` - (Required, if hook is specified) Command to be executed. - * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]`. - -* `configure_clone` - [Updatable] The commands to execute on the Target environment when the VDB is created or refreshed. This is a map of three parameters: - * `name` - Name of the hook. - * `command` - (Required, if hook is specified) Command to be executed. - * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]`. - -* `pre_snapshot` - [Updatable] The commands to execute on the Target environment before snapshotting a virtual database. These commands can quiesce any data prior to snapshotting. This is a map of five parameters: - * `name` - Name of the hook. - * `command` - (Required, if hook is specified) Command to be executed. - * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]`. - -* `post_snapshot` - [Updatable] The commands to execute on the Target environment after snapshotting a virtual database. This is a map of three parameters: - * `name` - Name of the hook. - * `command` - (Required, if hook is specified) Command to be executed. - * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]`. - -* `pre_start` - [Updatable] The commands to execute on the Target environment before starting a virtual database. This is a map of three parameters: - * `name` - Name of the hook. - * `command` - (Required, if hook is specified) Command to be executed. - * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]`. - -* `post_start` - [Updatable] The commands to execute on the Target environment after starting a virtual database. This is a map of three parameters: - * `name` - Name of the hook. - * `command` - (Required, if hook is specified) Command to be executed. - * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]`. - -* `pre_stop` - [Updatable] The commands to execute on the Target environment before stopping a virtual database. This is a map of three parameters: - * `name` - Name of the hook. - * `command` - (Required, if hook is specified) Command to be executed. - * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]`. - -* `post_stop` - [Updatable] The commands to execute on the Target environment after stopping a virtual database. This is a map of three parameters: - * `name` - Name of the hook. - * `command` - (Required, if hook is specified) Command to be executed. - * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]`. - -* `vdb_restart` - [Updatable] Indicates whether the Continuous Data Engine should automatically restart this virtual database when Target environment reboot is detected. - -* `snapshot_policy_id` - The ID of the Snapshot Policy for the VDB. - -* `retention_policy_id` - The ID of the Snapshot Retention Policy for the VDB. - -* `masked` - TRUE or FALSE boolean to set a VDB as "Masked". Note: You should define a `configure_clone` script in the Hooks step to mask the dataset. The selection of this option will cause the data to be marked as masked, regardless of whether you have defined a script to do so or not. -If you do not define a script to mask the dataset, the data will not be masked unless there is a masking job associated with the dataset. - -* `custom_env_vars` - -Environment variable to be set when a VDB is created. See the Continuous Data ENgine documentation for the list of allowed/denied environment variables and rules about substitution. This is an ordered map of key-value pairs. For eg: { "MY_ENV_VAR1": "$ORACLE_HOME", "MY_ENV_VAR2": "$CRS_HOME/after" } - -* `custom_env_files` - Environment files to be sourced when a VDB is created. This path can be followed by parameters. Paths and parameters are separated by spaces. Valid values are a list of env_files. For eg: [ "/export/home/env_file_1", "/export/home/env_file_2" ] - -* `tags` - [Updatable] The tags to be created for the VDB. This is a map of two parameters: - * `key` - (Required) Key of the tag - * `value` - (Required) Value of the tag - -* `make_current_account_owner` - Boolean to determine if the account provisioning this VDB will be the "Owner" of the VDB. - -* `config_params` - [Updatable] The database configuration override parameters. - -* `appdata_source_params` - [Updatable] The JSON payload conforming to the DraftV4 schema based on the type of application data being manipulated. These values are unique to each AppData (PostgreSQL, MySQL, etc) connector. Consult the connector documentation for more details. - -* `additional_mount_points` - [Updatable] Specifies additional locations on which to mount a subdirectory of an AppData container - * `shared_path` - (Required) Relative path within the container of the directory that should be mounted. - * `mount_path` - Absolute path on the target environment were the filesystem should be mounted - * `environment_id` - The entity ID of the environment on which the file system will be mounted. - -* `instance_name` - The VDB's SID name (Oracle Only). (This parameter is available starting DCT v22+) - -* `open_reset_logs` - TRUE or FALSE value which determines whether to open the database after provision (Oracle Only). - -* `online_log_size` - The online log size in MB (Oracle Only). - -* `online_log_groups` - The number of online log groups (Oracle Only). - -* `archive_log` - TRUE or FALSE boolean to create a VDB in `archivelog` mode (Oracle Only). - -* `new_dbid` - [Updatable] TRUE or FALSE boolean to generate a new DB ID for the created VDB (Oracle Only). - -* `listener_ids` - [Updatable] The listener IDs for this provision operation. This is a list of listener ids. For eg: [ "listener-123", "listener-456" ] (Oracle Only). - -* `file_mapping_rules` - The VDB file mapping rules (Oracle Only). Rules must be line separated (\n or \r) and each line must have the format "pattern:replacement". Lines are applied in order. - -* `unique_name` - The VDB's db_unique_name (Oracle Only). - -* `auxiliary_template_id` - The ID of the configuration template to apply to the auxiliary container database (CDB). This is only relevant when provisioning a Multitenant pluggable database into an existing CDB, i.e when the cdb_id property is set. (Oracle Only) - -* `cdb_id` - The ID of the container database (CDB) to provision an Oracle Multitenant database into. If empty, a new vCDB will be provisioned. (Oracle only) - -* `os_username` - The name of the privileged user to run the provision operation (Oracle only). - -* `os_password` - The password of the privileged user to run the provision operation (Oracle only). - -* `vcdb_tde_key_identifier` - ID of the key created by the Continuous Data Engine. (Oracle Multitenant Only) - -* `cdb_tde_keystore_password` - [Updatable] The password for the Transparent Data Encryption keystore associated with the CDB. (Oracle Multitenant Only) - -* `target_vcdb_tde_keystore_path` - [Updatable] Path to the keystore of the vCDB. (Oracle Multitenant Only) - -* `tde_key_identifier` - [Updatable] ID of the key created by the Continuous Data Engine. (Oracle Multitenant Only) - -* `tde_exported_key_file_secret` - Secret to be used while exporting and importing vPDB encryption keys if Transparent Data Encryption is enabled on the vPDB. (Oracle Multitenant Only) - -* `parent_tde_keystore_password` - [Updatable] The password of the keystore specified in parentTdeKeystorePath. (Oracle Multitenant Only) - -* `parent_tde_keystore_path` - [Updatable] Path to a copy of the parent's Oracle transparent data encryption keystore on the target host. Required to provision from snapshots containing encrypted database files. (Oracle Multitenant Only) - -* `vcdb_name` - The name of the provisioned vCDB when the cdb_id property is not set (Oracle Multitenant Only). - -* `vcdb_database_name` - The database name of the provisioned vCDB wwhen the cdb_id property is not set. Defaults to the value of the vcdb_name property (Oracle Multitenant Only). - -* `cluster_node_ids` - The cluster node ids, name, or addresses for this provision operation (Oracle RAC Only). - -* `oracle_rac_custom_env_vars` - Environment variable to be set when the engine creates an Oracle RAC VDB. See the Engine documentation for the list of allowed/denied environment variables and rules about substitution. - * `node_id` - (Required) The node id of the cluster. - * `name` - (Required) Name of the environment variable - * `value` - (Required) Value of the environment variable. - -* `oracle_rac_custom_env_files` - Environment files to be sourced when the Engine creates an Oracle RAC VDB. This path can be followed by parameters. Paths and parameters are separated by spaces. - * `node_id` - (Required) The node id of the cluster. - * `path_parameters` - (Required) This references a file from which certain parameters will be loaded. - -* `db_username` - [Updatable] The username of the database (Oracle, SAP ASE only). Only for update. - -* `db_password` - [Updatable] The password of the database (Oracle, SAP ASE only). Only for update. - -* `template_id` - [Updatable] The ID of the VDB Configuration Template (Oracle, SQL Server Only). - -* `database_name` - The name of the database on the Target environment. Defaults to "name" (Oracle, MSSQL, SAP ASE). - -* `mount_point` - [Updatable] The mount point for the VDB (Oracle, ASE Only). - -* `truncate_log_on_checkpoint` - TRUE or FALSE value to truncate the logs on checkpoints (SAP ASE only). - -* `recovery_model` - Recovery model of the source database. Valid values are `[ FULL, SIMPLE, BULK_LOGGED ]` (SQL Server Only). - -* `pre_script` - [Updatable] PowerShell script or executable to run prior to provisioning (SQL Server Only). - -* `post_script` - [Updatable] PowerShell script or executable to run after provisioning (SQL Server Only). - -* `cdc_on_provision` - [Updatable] Option to enable change data capture (CDC) on both the provisioned VDB and subsequent snapshot-related operations (e.g. refresh, rewind) (SQL Server Only). - - -## Attribute Reference - -* `id` - The VDB object entity ID. - -* `database_type` - The database type of this VDB. - -* `name` - The container name of this VDB. - -* `database_version` - The database version of this VDB. - -* `engine_id` - A reference to the Engine that this VDB belongs to. - -* `environment_id` - A reference to the Environment that hosts this VDB. - -* `ip_address` - The IP address of the VDB's host. - -* `fqdn` - The FQDN of the VDB's host. - -* `parent_id` - A reference to the parent dataset of this VDB. - -* `group_name` - The name of the group containing this VDB. - -* `tags` - A list of key value pair. - -* `creation_date` - The date this VDB was created. - -## Import (Beta) - -Use the [`import` block](https://developer.hashicorp.com/terraform/language/import) to add VDBs created directly in Data Control Tower into a Terraform state file. - -For example: -```terraform -import { - to = delphix_vdb.vdb_import_demo - id = "vdb_id" -} -``` - -*This is a beta feature. Delphix offers no guarantees of support or compatibility.* - -## Limitations - -Not all properties are supported through the `update` command. Properties that are not supported by the `update` command are presented via an error message at runtime. +# Resource: delphix_vdb + +In Delphix, a virtual database (VDB) is a full read/write copy of the source data. A VDB is created and managed by Data Control Tower (DCT) and Delphix Continuous Data Engine and it is provisioned (created) from a dSource or a VDB's data snapshot. + +The VDB (delphix_vdb) resource allows Terraform to create, update, and delete Delphix VDBs. The resource enables the `plan`, `apply`, `update`, and `destroy` Terraform commands. + + +## Example Usage +Provisioning can be done using one of three methods: provision by snapshot, bookmark, or timestamp. + +### Provisioning a VDB using latest snapshot. +```terraform + +resource "delphix_vdb" "vdb_name_provision_by_snapshot" { + auto_select_repository = true + source_data_id = "" + snapshot_id = "" # Leave empty to select the latest snapshot +} + +``` +### Provisioning a VDB from a bookmark and on a Target environment +```terraform +resource "delphix_vdb" "vdb_name_provision_by_bookmark_on_target_environment" { + provision_type = "bookmark" + auto_select_repository = true + bookmark_id = "" + environment_id = "" +} +``` +### Provisioning a VDB using timestamp and configure post refresh hook +```terraform +resource "delphix_vdb" "vdb_name_provion_by_timestamp_with_hook" { + provision_type = "timestamp" + auto_select_repository = true + source_data_id = "" + timestamp = "2021-05-01T08:51:34.148000+00:00" # Timestamp must be available on the source dataset. + post_refresh { + command = "echo \"Hello World\"" + name = "Sample Hook" + shell = "SHELL" + } +} +``` + +## Argument References + +### General Provisioning Requirements +The following arguments apply to all database platform types. + +* `name` - (Required) The unique name of the VDB. If empty, a name is randomly generated. [Updatable] +* `source_data_id` - (Required) The ID or name of the source dataset (dSource, VDB, Snapshot, or timestamp point) to provision from. + * All other objects referenced by the following parameters must live on the same Continuous Data Engine as the chosen source. +* `provision_type` - The type of provisioning to be carried out. Defaults to snapshot. + * Valid values are `[snapshot, bookmark, timestamp]`. This value determines which matching `snapshot_id`, `bookmark_id`, and `timestamp` argument is required. +* `snapshot_id` - The ID or name of the Snapshot from which to execute the provision operation. If the `snapshot_id` is empty or the parameter is not specified, the latest snapshot is automatically selected. +* `bookmark_id` - The ID or name of the Bookmark from which to execute the provision operation. The Bookmark must contain only one VDB. +* `timestamp` or `timestamp_in_database_timezone` - The point in time from which to execute the provision operation. + * If the `provision_type` is set to `timestamp`, but a `timestamp` value is not provided, then the latest available point is selected. + +### Oracle +The following arguments apply to the Oracle database type. + +__General Oracle__ +
The following arguments apply to all Oracle deployment configurations. + +* `database_name` - The name of the database on the Target environment. + * Defaults to "name". +* `unique_name` - The VDB's unique name (aka db_unique_name). +* `db_username` - The username of the database. If blank, this VDB will use its parent’s credentials [Updatable] +* `db_password` - The password of the database. If blank, this VDB will use its parent’s credentials [Updatable] +* `template_id` - The ID of the VDB Configuration Template. [Updatable] +* `mount_point` - The mount point for the VDB. [Updatable] +* `os_username` - The name of the Target’s operating system user to run the provision operation. +* `os_password` - The password of the Target’s operating system user to run the provision operation. +* `instance_name` - The VDB's SID name. + * This parameter is available starting from Data Control Tower (DCT) v22+. +* `open_reset_logs` - TRUE or FALSE value which determines whether to open the database after provision. +* `online_log_size` - The online log size in MB. +* `online_log_groups` - The number of online log groups. +* `archive_log` - TRUE or FALSE boolean to create a VDB in `archivelog` mode. +* `new_dbid` - TRUE or FALSE boolean to generate a new DB ID for the created VDB. [Updatable] +* `listener_ids` - The listener IDs for this provision operation. This is a list of listener IDs. For eg: `[ "listener-123", "listener-456" ]`. [Updatable] +* `file_mapping_rules` - The VDB file mapping rules. Rules must be line separated (\n or \r) and each line must have the format "pattern:replacement". Lines are applied in order. + +__Oracle Multitenant__ +
In addition to the General Oracle arguments, the following list applies to the Oracle Multitenant deployment configuration. + +* `cdb_id` - The ID of the container database (CDB) to provision an Oracle Multitenant database into. + * If empty, a new vCDB will be provisioned. +* `vcdb_name` - The name of the provisioned vCDB when the `cdb_id` property is not set. +* `vcdb_database_name` - The database name of the provisioned vCDB when the `cdb_id` property is not set. + * Defaults to the value of the `vcdb_name` property. +* `auxiliary_template_id` - The ID of the configuration template to apply to the auxiliary container database (CDB). This is only relevant when provisioning a Multitenant pluggable database into an existing CDB, i.e when the `cdb_id` property is set. +* `vcdb_tde_key_identifier` - ID of the key created by the Delphix Continuous Data Engine. +* `cdb_tde_keystore_password` - The password for the Transparent Data Encryption keystore associated with the CDB. [Updatable] +* `target_vcdb_tde_keystore_path` - [Updatable] Path to the keystore of the vCDB. +* `tde_key_identifier` - ID of the key created by the Continuous Data Engine. [Updatable] +* `tde_exported_key_file_secret` - Secret to be used when exporting and importing vPDB encryption keys if Transparent Data Encryption is enabled on the vPDB. +* `parent_tde_keystore_password` - The password of the keystore specified in parentTdeKeystorePath. [Updatable] +* `parent_tde_keystore_path` - Path to a copy of the parent's Oracle Transparent Data Encryption keystore on the target host. Required to provision from snapshots containing encrypted database files. [Updatable] + +__Oracle Real Applications Clusters (RAC)__ +
In addition to the General Oracle arguments, the following list applies to the Oracle RAC deployment configuration. All properties marked as required are necessary for Oracle RAC provisions. + +* `cluster_node_ids` - The cluster node IDs, name, or addresses for this provision operation. +* `oracle_rac_custom_env_vars` - Environment variable to be set when the engine creates an Oracle RAC VDB. See the Delphix Continuous Data Engine documentation for the list of allowed/denied environment variables and rules about substitution. + * `node_id` - (Required) The node ID of the cluster. + * `name` - (Required) Name of the environment variable + * `value` - (Required) Value of the environment variable. +* `oracle_rac_custom_env_files` - Environment files to be sourced when the Delphix Continuous Data Engine creates an Oracle RAC VDB. This path can be followed by parameters. Paths and parameters are separated by spaces. + * `node_id` - (Required) The node ID of the cluster. + * `path_parameters` - (Required) This references a file from which certain parameters will be loaded. + +### SQL Server +The following arguments apply to the Microsoft SQL Server database type. + +* `database_name` - The name of the database on the Target environment. Defaults to "name". +* `template_id` - The ID of the VDB Configuration Template. [Updatable] +* `recovery_model` - Recovery model of the source database. Valid values are `[ FULL, SIMPLE, BULK_LOGGED ]`. +* `cdc_on_provision` - Option to enable change data capture (CDC) on the provisioned VDB and subsequent snapshot-related operations (e.g. refresh, rewind). [Updatable] +* `pre_script` - PowerShell script or executable to run prior to provisioning. [Updatable] +* `post_script` - PowerShell script or executable to run after provisioning. [Updatable] + +### SAP ASE +The following arguments apply to the SAP ASE database type. + +* `database_name` - The name of the database on the Target environment. Defaults to "name". +* `db_username` - The username of the database. If blank, this VDB will use its parent’s credentials. [Updatable] +* `db_password` - The password of the database. If blank, this VDB will use its parent’s credentials. [Updatable] +* `mount_point` - The mount point for the VDB. [Updatable] +* `truncate_log_on_checkpoint` - TRUE or FALSE value to truncate the logs on checkpoints. + +### Other Databases +The following arguments apply to all other databases supported by the AppData (vSDK) framework and include database types such as PostgreSQL, MySQL, MongoDB, etc. + +* `appdata_source_params` - (Required) The JSON payload conforming to the DraftV4 schema based on the type of application data being manipulated. [Updatable] + * Consult the connector documentation for more details. +* `additional_mount_points` - Specifies additional locations on which to mount a subdirectory of an AppData container. [Updatable] + * `shared_path` - (Required) Relative path within the container of the directory that should be mounted. + * `mount_path` - Absolute path on the Target environment where the filesystem should be mounted. + * `environment_id` - The entity ID of the environment on which the file system will be mounted. + +### Target Engine, Environment and Repository +The following arguments allow users to determine where the VDB will be provisioned. +If left blank, DCT will auto-select a location based on the source. + +* `auto_select_repository` - (Required, unless `repository_id`, `environment_id`, or `cdb_id` are specified). TRUE or FALSE value to automatically select a compatible environment and repository. +* `engine_id` - The ID or name of the Continuous Data Engine onto which to provision. If the source ID unambiguously identifies a source object, this parameter is unnecessary and ignored. +* `environment_id` - The ID or name of the Target environment where to provision the VDB. + * If `repository_id` unambiguously identifies a repository, then this value is ignored. +* `environment_user_id` - The environment user ID to use to connect to the Target environment. [Updatable] +* `repository_id` - The ID of the Target environment's repository where to provision the VDB. A repository typically corresponds to a database installation (Oracle home, database instance, etc). Setting this parameter may implicitly determine the environment where to provision the VDB. +* `target_group_id` - The ID of the Continuous Data Engine's Dataset Group into which the VDB will be provisioned. If empty, the "Unassigned" Dataset Group is used. + * We encourage all users to avoid this argument as it will be deprecated and removed in the future. + +### Advanced +The following arguments are applicable to all database types, but they are not often necessary for simple provisions. + +* `custom_env_vars` - Environment variable to be set when a VDB is created. See the Delphix Continuous Data Engine documentation for the list of allowed/denied environment variables and rules about substitution. This is an ordered map of key-value pairs. For eg: { "MY_ENV_VAR1": "$ORACLE_HOME", "MY_ENV_VAR2": "$CRS_HOME/path/here" } +* `custom_env_files` - Environment files to be sourced when a VDB is created. This path can be followed by parameters. Paths and parameters are separated by spaces. Valid values are a list of env_files. For eg: [ "/export/home/env_file_1", "/export/home/env_file_2" ] +* `config_params` - The database configuration override parameters. [Updatable] +* `pre_refresh` - The commands to execute on the Target environment before refreshing the VDB. [Updatable] +This is a map of three parameters: + * name - Name of the hook. + * command - (Required, if hook is specified). Command to be executed. + * shell - Type of shell. Valid values are `[bash, shell, expect, ps, psd]`. +* `post_refresh` - The commands to execute on the Target environment after refreshing the VDB. [Updatable] +This is a map of three parameters: + * name - Name of the hook. + * command - (Required, if hook is specified). Command to be executed. + * shell - Type of shell. Valid values are `[bash, shell, expect, ps, psd]`. +* `pre_rollback` - The commands to execute on the Target environment before a rollback on the VDB. [Updatable] +This is a map of three parameters: + * `name` - Name of the hook. + * `command` - (Required, if hook is specified). Command to be executed. + * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]`. +* `post_rollback` - The commands to execute on the Target environment after a rollback on the VDB. [Updatable] +This is a map of three parameters: + * `name` - Name of the hook. + * `command` - (Required, if hook is specified). Command to be executed. + * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]`. +* `configure_clone` - The commands to execute on the Target environment when the VDB is created or refreshed. [Updatable] +This is a map of three parameters: + * `name` - Name of the hook. + * `command` - (Required, if hook is specified). Command to be executed. + * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]`. +* `pre_snapshot` - The commands to execute on the Target environment before snapshotting a virtual database. These commands can quiesce any data prior to snapshotting. [Updatable] +This is a map of five parameters: + * `name` - Name of the hook. + * `command` - (Required, if hook is specified). Command to be executed. + * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]`. +* `post_snapshot` - The commands to execute on the Target environment after snapshotting a virtual database. [Updatable] +This is a map of three parameters: + * `name` - Name of the hook. + * `command` - (Required, if hook is specified). Command to be executed. + * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]`. +* `pre_start` - The commands to execute on the Target environment before starting a virtual database. [Updatable] +This is a map of three parameters: + * `name` - Name of the hook. + * `command` - (Required, if hook is specified). Command to be executed. + * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]`. +* `post_start` - The commands to execute on the Target environment after starting a virtual database. [Updatable] +This is a map of three parameters: + * `name` - Name of the hook. + * `command` - (Required, if hook is specified). Command to be executed. + * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]`. +* `pre_stop` - The commands to execute on the Target environment before stopping a virtual database. [Updatable] +This is a map of three parameters: + * `name` - Name of the hook. + * `command` - (Required, if hook is specified). Command to be executed. + * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]`. +* `post_stop` - The commands to execute on the Target environment after stopping a virtual database. [Updatable] +This is a map of three parameters: + * `name` - Name of the hook. + * `command` - (Required, if hook is specified) Command to be executed. + * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]`. +* `vdb_restart` - Indicates whether the Delphix Continuous Data Engine should automatically restart this virtual database when Target environment reboot is detected. [Updatable] +* `snapshot_policy_id` - The ID of the Snapshot Policy for the VDB. +* `retention_policy_id` - The ID of the Snapshot Retention Policy for the VDB. +* `masked` - TRUE or FALSE boolean to set a VDB as "Masked". + * You should define a `configure_clone` script in the Hooks step to mask the dataset. The selection of this option will cause the data to be marked as masked, regardless of whether you have defined a script to do so or not. If you do not define a script to mask the dataset, the data will not be masked unless there is a masking job associated with the dataset. +* `tags` - The tags to be created for the VDB. [Updatable] +This is a map of two required parameters: + * `key` - Key of the tag. + * `value` - Value of the tag. +* `make_current_account_owner` - Default True. Boolean to determine if the account provisioning this VDB will be the "Owner" of the VDB. + +## Import (Beta) +Use the [`import` block](https://developer.hashicorp.com/terraform/language/import) to add VDBs created directly in DCT into a Terraform state file. + +For example: +```terraform +import { + to = delphix_vdb.vdb_import_demo + id = "vdb_id" +} +``` +*This is a beta feature. Delphix offers no guarantees of support or compatibility.* + +## Limitations + +Not all properties are supported through the `update` command. Properties that are not supported by the `update` command are presented via an error message at runtime. \ No newline at end of file diff --git a/internal/provider/commons.go b/internal/provider/commons.go index 77ce1f3..7032bd8 100644 --- a/internal/provider/commons.go +++ b/internal/provider/commons.go @@ -51,6 +51,7 @@ var updatableVdbKeys = map[string]bool{ "new_dbid": true, "mount_point": true, "tags": true, + "database_name": true, } var isDestructiveVdbUpdate = map[string]bool{ diff --git a/internal/provider/resource_appdata_dsource_test.go b/internal/provider/resource_appdata_dsource_test.go index 5a3c79d..05214a1 100644 --- a/internal/provider/resource_appdata_dsource_test.go +++ b/internal/provider/resource_appdata_dsource_test.go @@ -17,11 +17,11 @@ func TestDsource_create_positive(t *testing.T) { name := os.Getenv("DSOURCE_NAME") environmentUser := os.Getenv("DSOURCE_ENV_USER") stagingEnvironment := os.Getenv("DSOURCE_STAGE_ENV") - postgresPort := os.Getenv("DSOURCE_POSTGRES_PORT") + parameters := os.Getenv("DSOURCE_PARAMETERS") resource.Test(t, resource.TestCase{ PreCheck: func() { - testDsourcePreCheck(t, sourceId, groupId, name, environmentUser, stagingEnvironment, postgresPort) + testDsourcePreCheck(t, sourceId, groupId, name, environmentUser, stagingEnvironment, parameters) }, Providers: testAccProviders, CheckDestroy: testDsourceDestroy, @@ -31,13 +31,13 @@ func TestDsource_create_positive(t *testing.T) { ExpectError: regexp.MustCompile(`.*`), }, { - Config: testDsourceBasic(sourceId, groupId, name, environmentUser, stagingEnvironment, postgresPort), + Config: testDsourceBasic(sourceId, groupId, name, environmentUser, stagingEnvironment, parameters), Check: resource.ComposeTestCheckFunc( testDsourceExists("delphix_appdata_dsource.new_data_dsource", sourceId), resource.TestCheckResourceAttr("delphix_appdata_dsource.new_data_dsource", "source_id", sourceId)), }, { - Config: testDsourceUpdate(sourceId, groupId, "update_same_dsource", environmentUser, stagingEnvironment, postgresPort), + Config: testDsourceUpdate(sourceId, groupId, "update_same_dsource", environmentUser, stagingEnvironment, parameters), Check: resource.ComposeAggregateTestCheckFunc( // irrelevant ), @@ -47,7 +47,7 @@ func TestDsource_create_positive(t *testing.T) { }) } -func testDsourcePreCheck(t *testing.T, sourceId string, groupId string, name string, environmentUser string, stagingEnvironment string, postgresPort string) { +func testDsourcePreCheck(t *testing.T, sourceId string, groupId string, name string, environmentUser string, stagingEnvironment string, parameters string) { testAccPreCheck(t) if sourceId == "" { t.Fatal("DSOURCE_SOURCE_ID must be set for env acceptance tests") @@ -64,12 +64,12 @@ func testDsourcePreCheck(t *testing.T, sourceId string, groupId string, name str if stagingEnvironment == "" { t.Fatal("DSOURCE_STAGE_ENV must be set for env acceptance tests") } - if postgresPort == "" { - t.Fatal("DSOURCE_POSTGRES_PORT must be set for env acceptance tests") + if parameters == "" { + t.Fatal("DSOURCE_PARAMETERS must be set for env acceptance tests") } } -func testDsourceBasic(sourceId string, groupId string, name string, environmentUser string, stagingEnvironment string, postgresPort string) string { +func testDsourceBasic(sourceId string, groupId string, name string, environmentUser string, stagingEnvironment string, parameters string) string { return fmt.Sprintf(` resource "delphix_appdata_dsource" "new_data_dsource" { source_value = "%s" @@ -86,10 +86,10 @@ resource "delphix_appdata_dsource" "new_data_dsource" { resync = true }) } - `, sourceId, groupId, name, environmentUser, stagingEnvironment, postgresPort) + `, sourceId, groupId, name, environmentUser, stagingEnvironment, parameters) } -func testDsourceUpdate(sourceId string, groupId string, name string, environmentUser string, stagingEnvironment string, postgresPort string) string { +func testDsourceUpdate(sourceId string, groupId string, name string, environmentUser string, stagingEnvironment string, parameters string) string { return fmt.Sprintf(` resource "delphix_appdata_dsource" "new_data_dsource" { source_value = "%s" @@ -106,7 +106,7 @@ resource "delphix_appdata_dsource" "new_data_dsource" { resync = true }) } - `, sourceId, groupId, name, environmentUser, stagingEnvironment, postgresPort) + `, sourceId, groupId, name, environmentUser, stagingEnvironment, parameters) } func testDsourceExists(n string, sourceId string) resource.TestCheckFunc { diff --git a/internal/provider/resource_vdb.go b/internal/provider/resource_vdb.go index ded2882..75de157 100644 --- a/internal/provider/resource_vdb.go +++ b/internal/provider/resource_vdb.go @@ -1591,7 +1591,10 @@ func resourceVdbRead(ctx context.Context, d *schema.ResourceData, meta interface d.Set("post_stop", flattenHooks(result.GetHooks().PostStop)) d.Set("pre_rollback", flattenHooks(result.GetHooks().PreRollback)) d.Set("post_rollback", flattenHooks(result.GetHooks().PostRollback)) - d.Set("database_name", result.GetDatabaseName()) + if !*result.IsAppdata { + d.Set("database_name", result.GetDatabaseName()) + } + d.Set("tags", flattenTags(result.GetTags())) d.Set("vdb_restart", result.GetVdbRestart()) @@ -1927,7 +1930,6 @@ func resourceVdbUpdate(ctx context.Context, d *schema.ResourceData, meta interfa tflog.Debug(ctx, "tag to be deleted: "+toTagArray(oldTag)[0].GetKey()+" "+toTagArray(oldTag)[0].GetValue()) deleteTag := *dctapi.NewDeleteTag() tagDelResp, tagDelErr := client.VDBsAPI.DeleteVdbTags(ctx, vdbId).DeleteTag(deleteTag).Execute() - tflog.Debug(ctx, "tag delete response: "+tagDelResp.Status) if diags := apiErrorResponseHelper(ctx, nil, tagDelResp, tagDelErr); diags != nil { revertChanges(d, changedKeys) updateFailure = true diff --git a/internal/provider/resource_vdb_group.go b/internal/provider/resource_vdb_group.go index b7835c0..3bf1250 100644 --- a/internal/provider/resource_vdb_group.go +++ b/internal/provider/resource_vdb_group.go @@ -30,7 +30,7 @@ func resourceVdbGroup() *schema.Resource { }, "vdb_ids": { Type: schema.TypeList, - Required: true, + Optional: true, Elem: &schema.Schema{ Type: schema.TypeString, }, @@ -45,9 +45,9 @@ func resourceVdbGroupCreate(ctx context.Context, d *schema.ResourceData, meta in client := meta.(*apiClient).client - apiRes, httpRes, err := client.VDBGroupsAPI.CreateVdbGroup(ctx).CreateVDBGroupRequest(*dctapi.NewCreateVDBGroupRequest( - d.Get("name").(string), - )).Execute() + vdbGroupCreateReq := *dctapi.NewCreateVDBGroupRequest(d.Get("name").(string)) + vdbGroupCreateReq.SetVdbIds(toStringArray(d.Get("vdb_ids"))) + apiRes, httpRes, err := client.VDBGroupsAPI.CreateVdbGroup(ctx).CreateVDBGroupRequest(vdbGroupCreateReq).Execute() if diags := apiErrorResponseHelper(ctx, apiRes, httpRes, err); diags != nil { return diags @@ -74,6 +74,7 @@ func resourceVdbGroupRead(ctx context.Context, d *schema.ResourceData, meta inte apiRes, httpRes, err := client.VDBGroupsAPI.GetVdbGroup(ctx, vdbGroupId).Execute() if diags := apiErrorResponseHelper(ctx, apiRes, httpRes, err); diags != nil { + d.SetId("") return diags } diff --git a/internal/provider/resource_vdb_test.go b/internal/provider/resource_vdb_test.go index 72847b7..24a61fa 100644 --- a/internal/provider/resource_vdb_test.go +++ b/internal/provider/resource_vdb_test.go @@ -93,9 +93,6 @@ func testAccVdbAppDataPreCheck(t *testing.T) { if err := os.Getenv("APPDATA_SOURCE_PARAMS"); err == "" { t.Fatal("APPDATA_SOURCE_PARAMS must be set for vdb acceptance tests") } - if err := os.Getenv("APPDATA_CONFIG_PARAMS"); err == "" { - t.Fatal("APPDATA_CONFIG_PARAMS must be set for vdb acceptance tests") - } } func testAccCheckDctVDBConfigBasic() string { @@ -111,15 +108,13 @@ func testAccCheckDctVDBConfigBasic() string { func testAccCheckDctVDBConfigAppDataBasic() string { appdata_datasource_id := os.Getenv("APPDATA_DATASOURCE_ID") appdata_source_params := os.Getenv("APPDATA_SOURCE_PARAMS") - appdata_config_params := os.Getenv("APPDATA_CONFIG_PARAMS") return fmt.Sprintf(` resource "delphix_vdb" "new_appdata" { auto_select_repository = true source_data_id = "%s" appdata_source_params = jsonencode(%s) - appdata_config_params = jsonencode(%s) } - `, appdata_datasource_id, appdata_source_params, appdata_config_params) + `, appdata_datasource_id, appdata_source_params) } func testAccCheckDctVDBBookmarkConfigBasic() string { @@ -185,8 +180,6 @@ func testAccCheckDctVDBBookmarkConfigBasic() string { } `, bookmark_id) - print(resource) - return resource } @@ -314,8 +307,6 @@ func testAccCheckVdbDestroy(s *terraform.State) error { func testAccCheckVdbDestroyBookmark(s *terraform.State) error { client := testAccProvider.Meta().(*apiClient).client - - print("Deleting parent vdb " + vdb_id) deleteVdbParams := dctapi.NewDeleteVDBParametersWithDefaults() deleteVdbParams.SetForce(false) client.VDBsAPI.DeleteVdb(context.Background(), vdb_id).DeleteVDBParameters(*deleteVdbParams).Execute() diff --git a/internal/provider/utility.go b/internal/provider/utility.go index 54060d1..7c9ed39 100644 --- a/internal/provider/utility.go +++ b/internal/provider/utility.go @@ -5,6 +5,7 @@ import ( "io" "math" "net/http" + "reflect" "strconv" "time" @@ -285,7 +286,9 @@ func enableVDB(ctx context.Context, client *dctapi.APIClient, vdbId string) diag func revertChanges(d *schema.ResourceData, changedKeys []string) { for _, key := range changedKeys { old, _ := d.GetChange(key) - d.Set(key, old) + if !reflect.ValueOf(old).IsZero() { // so that a previously optional param is not set to blank erroraneously + d.Set(key, old) + } } }