diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b0b46c8..785393f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,7 +28,7 @@ jobs: name: Set up Go uses: actions/setup-go@v2 with: - go-version: 1.16 + go-version: 1.17 - name: Import GPG key id: import_gpg diff --git a/.goreleaser.yml b/.goreleaser.yml index 95057ea..9444a8c 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=0.1-beta + - PROVIDER_VERSION=1.0.1 before: hooks: # this is just an example and not a requirement for provider building/publishing @@ -33,12 +33,12 @@ builds: - goos: darwin goarch: '386' binary: terraform-provider-delphix - hooks: - post: + hooks: + post: - cmd: ./dev_copy.sh - env: + env: - CP_PATH={{ .Path }} - - CP_TARGET={{ .Target }} + - CP_TARGET={{ .Target }} - CP_VERSION={{ .Env.PROVIDER_VERSION }} archives: - format: zip @@ -49,6 +49,18 @@ checksum: name_template: '{{ .ProjectName }}_{{ .Env.PROVIDER_VERSION }}_manifest.json' name_template: '{{ .ProjectName }}_{{ .Env.PROVIDER_VERSION }}_SHA256SUMS' algorithm: sha256 +signs: + - artifacts: checksum + args: + # if you are using this in a GitHub action or some other automated pipeline, you + # need to pass the batch flag to indicate its not interactive. + - "--batch" + - "--local-user" + - "{{ .Env.GPG_FINGERPRINT }}" # set this environment variable for your signing key + - "--output" + - "${signature}" + - "--detach-sign" + - "${artifact}" release: extra_files: - glob: 'terraform-registry-manifest.json' @@ -56,4 +68,4 @@ release: # If you want to manually examine the release before its live, uncomment this line: # draft: true changelog: - skip: true \ No newline at end of file + skip: true diff --git a/GNUmakefile b/GNUmakefile index bb6f014..62b4f27 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -3,7 +3,7 @@ HOSTNAME=delphix.com NAMESPACE=dct NAME=delphix BINARY=terraform-provider-${NAME} -VERSION=0.1-beta +VERSION=1.0.1 OS_ARCH=darwin_amd64 default: install @@ -29,9 +29,9 @@ install: build mkdir -p ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH} mv ${BINARY} ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH} -test: - go test -i $(TEST) || exit 1 - echo $(TEST) | xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4 +test: + go test -i $(TEST) || exit 1 + echo $(TEST) | xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4 -testacc: - TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m +testacc: + TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m diff --git a/README.md b/README.md index b84c68d..cbe4d36 100644 --- a/README.md +++ b/README.md @@ -1,33 +1,44 @@ # Terraform Provider Delphix +![CodeQL](https://github.com/delphix-integrations/terraform-provider-delphix/actions/workflows/codeql.yml/badge.svg?branch=main) +![Release](https://github.com/delphix-integrations/terraform-provider-delphix/actions/workflows/release.yml/badge.svg?event=release) +![Version](https://img.shields.io/github/v/release/delphix-integrations/terraform-provider-delphix) + Terraform Provider for Delphix enables Terraform to create and manage Delphix Continuous Data & Continuous Compliance infrastructure using the Delphix Control Tower (DCT) APIs. -Full documentation can he found [here](https://integrations.delphix.com/Terraform/) +Full implementation directions can be found on the [Delphix Ecosystem Documentation](https://ecosystem.delphix.com/docs/overview-3) and [Terraform Provider Registry](https://registry.terraform.io/providers/delphix-integrations/delphix/latest/docs). -## Getting Started (Development) -This guide will eventually cover the following +## Prerequisites +1. Install Delphix Control Tower (DCT). For more information, visit the [DCT documentation](https://docs.delphix.com/dct). +2. Delphix Continuous Data and Continuous Compliance engines must be connected to DCT. +3. An API key must be created for authenticating with DCT APIs. Refer to the [DCT API keys documentation](https://dct.delphix.com/docs/api-keys-2) for more info. +4. Additional infrastructure required for testing the provider operations. [e.g Hosts to be added as environments, dSources to create VDBs from] +5. Development setup for Golang. -1. Setup DCT APi Gateway On Premise by following the [DCT API Gateway setup](https://github.com/delphix/orbital-api-gateway) -2. Install IDE [Visual Studio Code](https://code.visualstudio.com) +## Getting Started (Development) + +This guide covers the following -3. Install guide for [golang](https://go.dev/dl/) +1. Install IDE [Visual Studio Code](https://code.visualstudio.com). -4. Install guide for [Goreleaser](https://goreleaser.com/install/) +2. Install guide for [Golang](https://go.dev/dl/). -5. Install Go Plugin for VS Code +3. Install guide for [GoReleaser](https://goreleaser.com/install/). -6. Install [Terraform](https://www.terraform.io/downloads) +4. Install Go Plugin for VS Code. -7. Fork this repo and clone it locally. Switch to develop branch which always heads to the latest development code. +5. Install [Terraform](https://www.terraform.io/downloads). -8. Run following command to create binaries: +6. Fork this repo and clone it locally. Switch to the `develop` branch which always heads to the latest development code. + +7. Run following command to create binaries: ```goreleaser release --skip-publish --snapshot --rm-dist``` -9. Execute example main.tf file under /examples/ directory using the following commands: +8. Execute example main.tf file under /examples/ directory using the following commands: ``` terraform init @@ -35,13 +46,5 @@ This guide will eventually cover the following terraform apply ``` -## Prerequisites - -- Delphix Control Tower (DCT) API Gateway must be installed on-premise. -- Delphix Engines must be registered with DCT-OnPrem. -- API-Keys must be created for authenticating with DCT-OnPrem. Refer to DCT guide for more info. -- Additional infrastructure required for testing the provider operations [ e.g Hosts to be added as environments, dSources to create VDBs from] -- Development setup for GoLang. - ## Contributing This project is currently not accepting external contributions. diff --git a/docs/index.md b/docs/index.md index 9d89f5a..f8eaaa6 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,10 +1,15 @@ -# Terraform-Provider-Delphix +# Delphix Provider !> **NOTE** -It is a beta version as of now and it requires Delphix Control Tower 2.0. to work. +The Terraform Provider for Delphix requires the Delphix Continuous Data Platform and Data Control Tower (DCT). -Delphix Terraform provider to interact with different infrastructure resources supported by Delphix. You must configure the provider -with the proper API key generated by DCT and register your Delphix Engine before you can use it. + +The Terraform Provider for Delphix enables customers to natively manage data-as-code along with their infrastructure. +With Terraform and Delphix, customers can now automatically provision, manage and teardown any number of ephemeral data environments to drive enterprise DevOps workflows including test data management. + +This provider leverages the Delphix APIs available with the Delphix Data Control Tower (DCT). The provider must be configured with the proper API key generated by DCT and registered with associated Delphix engines before use + +To learn more about Delphix and DCT APIs, refer to [Delphix Docs](https://docs.delphix.com) and [DCT Docs](https://docs.delphix.com/dct) respectively. Please [Contact us](ask-integrations@delphix.com) (ask-integrations@delphix.com) with any questions. ## Example Usage @@ -12,17 +17,17 @@ with the proper API key generated by DCT and register your Delphix Engine before terraform { required_providers { delphix = { + source = "delphix-integrations/delphix" version = "1.0.0" - source = "delphix.com/local/delphix" } } } # Configure the DXI Provider provider "delphix" { - tls_insecure_skip = true - key = "1.XXXX" - host = "HOSTNAME" + tls_insecure_skip = true + key = "dct_api_key" + host = "dct_hostname" } # Provision a VDB @@ -34,7 +39,8 @@ resource "delphix_vdb" "vdb_name" { ## Configuration and API Key Generation -For generation of the API key, please refer to [Authentication](https://docs.delphix.com/dctmc/authentication). +Delphix Provider uses DCT APIs to communicate with the Delphix engines. Authentication to DCT APIs are handled using API Keys. +For generation of the API key, please refer to [Authentication](https://docs.delphix.com/dct/authentication-170164311.html). ## Argument Reference diff --git a/docs/resources/environment.md b/docs/resources/environment.md index 85abebc..1ae7775 100644 --- a/docs/resources/environment.md +++ b/docs/resources/environment.md @@ -1,10 +1,15 @@ # Resource: delphix_environment -An environment is a a grouping of a single host or a cluster of hosts. environment allows creating hosts or a cluster of hosts. +In Delphix, an environment is either a single instance host or cluster of hosts that run database software. + +Environments can either be a source (where data comes from), staging (where data are prepared/masked) or target (where data are delivered and used by developers and testers). + +Each environment has its own properties and information depending on the type of environment it is ## Example Usage -### Creating a UNIX standalone environment +### Create UNIX standalone environment + ```hcl resource "delphix_environment" "unix_env_name" { engine_id = 2 @@ -31,7 +36,7 @@ resource "delphix_environment" "unix_env_name" { is_target = false } ``` -### Creating a UNIX cluster +### Create UNIX cluster ```hcl resource "delphix_environment" "unixcluster" { engine_id = 2 @@ -41,11 +46,44 @@ resource "delphix_environment" "unixcluster" { hostname = "db.host.com" toolkit_path = "/home/delphix" name = "unixcluster" - description = "This is a unix target." + description = "This is a unix target." is_cluster = true cluster_home = "/u01/app/19.0.0.0/grid" } ``` +### Creating UNIX standalone target environment using HashiCorp Vault +```hcl +resource "delphix_environment" "wintgt" { + engine_id = 2 + os_name = "UNIX" + hostname = "xxx" + toolkit_path = "/home/delphix" + name = "unixtgt" + + vault = "vault-name" + hashicorp_vault_engine = "xxx" + hashicorp_vault_secret_path = "xxx" + hashicorp_vault_username_key = "xxx" + hashicorp_vault_secret_key = "xxx" + + description = "This is unix target." + } +``` +### Creating UNIX standalone target environment using CyberArk Vault +```hcl +resource "delphix_environment" "wintgt" { + engine_id = 2 + os_name = "UNIX" + hostname = "xxx" + toolkit_path = "/home/delphix" + name = "unixtgt" + + vault = "vault-name" + cyberark_query_string = "xxx" + + description = "This is unix target." + } +``` ### Creating a WINDOWS standalone target environment ```hcl resource "delphix_environment" "wintgt" { @@ -124,34 +162,37 @@ resource "delphix_environment" "fc-tgt-cluster" { ## Argument Reference -* `name` - (Optional) The name of the environment. -* `engine_id` - (Required) The ID of the Engine onto which to create the environment. +* `engine_id` - (Required) The DCT ID of the Engine on which to create the environment. This ID can be obtained by querying the DCT engines API. A Delphix Engine must be registered with DCT first for it to create an Engine ID. * `os_name` - (Required) Operating system type of the environment. Valid values are `[UNIX, WINDOWS]` +* `hostname` - (Required) Host Name or IP Address of the host that being added to Delphix. +* `name` - (Optional) The name of the environment. * `is_cluster` - (Optional) Whether the environment to be created is a cluster. -* `cluster_home` - (Optional) Absolute path to cluster home drectory. This parameter is mandatory for UNIX cluster environments. -* `hostname` - (Required) host address of the machine. -* `staging_environment` - (Optional) Id of the connector environment which is used to connect to this source environment. This is mandatory parameter when creating Windows source environments. -* `connector_port` - (Optional) Specify port on which Delphix connector will run. This is mandatory parameter when creating Windows target environments. +* `cluster_home` - (Optional) Absolute path to cluster home drectory. This parameter is (Required) for UNIX cluster environments. +* `staging_environment` - (Optional) Id of the environment where Delphix Connector is installed. This is a (Required) parameter when creating Windows source environments. +* `connector_port` - (Optional) Specify port on which Delphix connector will run. This is a (Required) parameter when creating Windows target environments. * `is_target` - (Optional) Whether the environment to be created is a target cluster environment. This property is used only when creating Windows cluster environments. -* `ssh_port` - (Optional) ssh port of the host. -* `toolkit_path` - (Optional) The path for the toolkit that resides on the host. -* `username` - (Optional) Username of the OS. -* `password` - (Optional) Password of the OS. +* `ssh_port` - (Optional) ssh port of the environment. +* `toolkit_path` - (Optional) The path where Delphix toolkit can be pushed. +* `username` - (Optional) OS username for Delphix. +* `password` - (Optional) OS user's password. * `vault` - (Optional) The name or reference of the vault from which to read the host credentials. * `hashicorp_vault_engine` - (Optional) Vault engine name where the credential is stored. * `hashicorp_vault_secret_path` - (Optional) Path in the vault engine where the credential is stored. * `hashicorp_vault_username_key` - (Optional) Key for the username in the key-value store. * `hashicorp_vault_secret_key` - (Optional) Key for the password in the key-value store. * `cyberark_vault_query_string` - (Optional) Query to find a credential in the CyberArk vault. -* `nfs_addresses` - (Optional) array of ip address or hostnames. Valid values are a list of addresses. For eg: `["192.168.10.2"]` -* `ase_db_username` - (Optional) username of the SAP ASE database. -* `ase_db_password` - (Optional) password of the SAP ASE database. +* `use_kerberos_authentication` - (Optional) Whether to use kerberos authentication. +* `use_engine_public_key` - (Optional) Whether to use public key authentication. +* `nfs_addresses` - (Optional) Array of ip address or hostnames. Valid values are a list of addresses. For eg: `["192.168.10.2"]` +* `ase_db_username` - (Optional) Username for the SAP ASE database. +* `ase_db_password` - (Optional) Password for the SAP ASE database. * `ase_db_vault` - (Optional) The name or reference of the vault from which to read the ASE database credentials. * `ase_db_hashicorp_vault_engine` - (Optional) Vault engine name where the credential is stored. * `ase_db_hashicorp_vault_secret_path` - (Optional) Path in the vault engine where the credential is stored. * `ase_db_hashicorp_vault_username_key` - (Optional) Key for the username in the key-value store. * `ase_db_hashicorp_vault_secret_key` - (Optional) Key for the password in the key-value store. * `ase_db_cyberark_vault_query_string` - (Optional) Query to find a credential in the CyberArk vault. +* `ase_db_use_kerberos_authentication` - (Optional) Whether to use kerberos authentication for ASE DB discovery. * `java_home` - (Optional) The path to the user managed Java Development Kit (JDK). If not specified, then the OpenJDK will be used. * `dsp_keystore_path` - (Optional) DSP keystore path. * `dsp_keystore_password` - (Optional) DSP keystore password. @@ -159,10 +200,13 @@ resource "delphix_environment" "fc-tgt-cluster" { * `dsp_truststore_path` - (Optional) DSP truststore path. * `dsp_truststore_password` - (Optional) DSP truststore password. * `description` - (Optional) The environment description. +* `tags` - (Optional) The tags to be created for this environment. This is a map of 2 parameters: + * `key` - (Required) Key of the tag + * `value` - (Required) Value of the tag ## Attribute Reference * `namespace` - The namespace of this environment for replicated and restored objects. * `engine_id` - A reference to the Engine that this Environment connection is associated with. * `enabled` - True if this environment is enabled. -* `hosts` - The hosts that are part of this environment. \ No newline at end of file +* `hosts` - The hosts that are part of this environment. diff --git a/docs/resources/vdb.md b/docs/resources/vdb.md index 2c812b7..a07b88b 100644 --- a/docs/resources/vdb.md +++ b/docs/resources/vdb.md @@ -1,6 +1,11 @@ # Resource: delphix_vdb -The VDB resource allows the provisioning, updation and deletion of a Delphix virtual database infrastructure (VDB). However, update is not supported for all parameters, the ones supported is mentioned below. +In Delphix terminology, a VDB is a database provisioned from either a dSource or another VDB which is a full read/write copy of the source data. +A VDB is created and managed by the Delphix Continuous Data Engine. + + +The VDB resource allows terraform to CREATE (also known as Provision), READ, UPDATE and DELETE Delphix Virtual Databases (VDB). +Update operation does not support all VDB parameters. The supported parameters are listed below. ## Example Usage Provisioning can be done in 2 methods, provision by snapshot and provision by timestamp. @@ -27,6 +32,15 @@ resource "delphix_vdb" "vdb_name2" { } } +# Provision a VDB from a bookmark with a single VDB + +resource "delphix_vdb" "test_vdb" { + provision_type = "bookmark" + auto_select_repository = true + bookmark_id = "BOOKMARK_ID" + environment_id = "ENV_ID" +} + # Provision a VDB using snapshot and pre refresh hooks resource "delphix_vdb" "vdb_name" { @@ -43,9 +57,9 @@ resource "delphix_vdb" "vdb_name" { ## Argument Reference -* `source_data_id` - (Required) The ID of the source object (dSource or VDB) to provision from. All other objects referenced by the parameters must live on the same engine as the source. +* `source_data_id` - (Optional) The ID or name of the source object (dSource or VDB) to provision from. All other objects referenced by the parameters must live on the same engine as the source. -* `engine_id` - (Optional) The ID of the Engine onto which to provision. If the source ID unambiguously identifies a source object, this parameter is unnecessary and ignored. +* `engine_id` - (Optional) The ID or name of the Engine onto which to provision. If the source ID unambiguously identifies a source object, this parameter is unnecessary and ignored. * `target_group_id` - (Optional) The ID of the group into which the VDB will be provisioned. If unset, a group is selected randomly on the Engine. @@ -53,13 +67,21 @@ resource "delphix_vdb" "vdb_name" { * `database_name` - (Optional) The name of the database on the target environment. Defaults to vdb_name. +* `cdb_id` - (Optional) The ID of the container database (CDB) to provision an Oracle Multitenant database into. When this is not set, a new vCDB will be provisioned. + +* `cluster_node_ids` - (Optional) The cluster node ids, name or addresses for this provision operation (Oracle RAC Only). + * `truncate_log_on_checkpoint` - (Optional) Whether to truncate log on checkpoint (ASE only). -* `username` - (Optional) [Updatable] The name of the privileged user to run the provision operation (Oracle Only). +* `os_username` - (Optional) The name of the privileged user to run the provision operation (Oracle Only). -* `password` - (Optional) [Updatable] The password of the privileged user to run the provision operation (Oracle Only). +* `os_password` - (Optional) The password of the privileged user to run the provision operation (Oracle Only). -* `environment_id` - (Optional) The ID of the target environment where to provision the VDB. If repository_id unambigously identifies a repository, this is unnecessary and ignored. Otherwise, a compatible repository is randomly selected on the environment. +* `db_username` - (Optional) [Updatable] The username of the database user (Oracle, ASE Only). Only for update. + +* `db_password` - (Optional) [Updatable] The password of the database user (Oracle, ASE Only). Only for update. + +* `environment_id` - (Optional) The ID or name of the target environment where to provision the VDB. If repository_id unambigously identifies a repository, this is unnecessary and ignored. Otherwise, a compatible repository is randomly selected on the environment. * `environment_user_id` - (Optional)[Updatable] The environment user ID to use to connect to the target environment. @@ -67,63 +89,85 @@ resource "delphix_vdb" "vdb_name" { * `auto_select_repository` - (Optional) Option to automatically select a compatible environment and repository. Mutually exclusive with repository_id. -* `pre_refresh` - (Optional) The commands to execute on the target environment before refreshing the VDB. This is a map of 3 parameters: +* `pre_refresh` - (Optional) The commands to execute on the target environment before refreshing the VDB. This is a map of 5 parameters: * `name` - Name of the hook * `command` - (Required)Command to be executed - * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]` Default is `bash` + * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]` + * `element_id` - Element ID for the hook + * `has_credentials` - Flag to indicate if it has credentials -* `post_refresh` - (Optional) The commands to execute on the target environment after refreshing the VDB. This is a map of 3 parameters: +* `post_refresh` - (Optional) The commands to execute on the target environment after refreshing the VDB. This is a map of 5 parameters: * `name` - Name of the hook * `command` - (Required)Command to be executed - * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]` Default is `bash` + * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]` + * `element_id` - Element ID for the hook + * `has_credentials` - Flag to indicate if it has credentials -* `pre_rollback` - (Optional) The commands to execute on the target environment before rewinding the VDB. This is a map of 3 parameters: +* `pre_rollback` - (Optional) The commands to execute on the target environment before rewinding the VDB. This is a map of 5 parameters: * `name` - Name of the hook * `command` - (Required)Command to be executed - * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]` Default is `bash` + * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]` + * `element_id` - Element ID for the hook + * `has_credentials` - Flag to indicate if it has credentials -* `post_rollback` - (Optional) The commands to execute on the target environment after rewinding the VDB. This is a map of 3 parameters: +* `post_rollback` - (Optional) The commands to execute on the target environment after rewinding the VDB. This is a map of 5 parameters: * `name` - Name of the hook * `command` - (Required)Command to be executed - * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]` Default is `bash` + * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]` + * `element_id` - Element ID for the hook + * `has_credentials` - Flag to indicate if it has credentials -* `configure_clone` - (Optional) The commands to execute on the target environment when the VDB is created or refreshed. This is a map of 3 parameters: +* `configure_clone` - (Optional) The commands to execute on the target environment when the VDB is created or refreshed. This is a map of 5 parameters: * `name` - Name of the hook * `command` - (Required)Command to be executed - * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]` Default is `bash` + * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]` + * `element_id` - Element ID for the hook + * `has_credentials` - Flag to indicate if it has credentials -* `pre_snapshot` - (Optional) The commands to execute on the target environment before snapshotting a virtual source. These commands can quiesce any data prior to snapshotting. This is a map of 3 parameters: +* `pre_snapshot` - (Optional) The commands to execute on the target environment before snapshotting a virtual source. These commands can quiesce any data prior to snapshotting. This is a map of 5 parameters: * `name` - Name of the hook * `command` - (Required)Command to be executed - * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]` Default is `bash` + * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]` + * `element_id` - Element ID for the hook + * `has_credentials` - Flag to indicate if it has credentials -* `post_snapshot` - (Optional) The commands to execute on the target environment after snapshotting a virtual source. This is a map of 3 parameters: +* `post_snapshot` - (Optional) The commands to execute on the target environment after snapshotting a virtual source. This is a map of 5 parameters: * `name` - Name of the hook * `command` - (Required)Command to be executed - * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]` Default is `bash` + * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]` + * `element_id` - Element ID for the hook + * `has_credentials` - Flag to indicate if it has credentials -* `pre_start` - (Optional) The commands to execute on the target environment before starting a virtual source. This is a map of 3 parameters: +* `pre_start` - (Optional) The commands to execute on the target environment before starting a virtual source. This is a map of 5 parameters: * `name` - Name of the hook * `command` - (Required)Command to be executed - * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]` Default is `bash` + * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]` -* `post_start` - (Optional) The commands to execute on the target environment after starting a virtual source. This is a map of 3 parameters: +* `post_start` - (Optional) The commands to execute on the target environment after starting a virtual source. This is a map of 5 parameters: * `name` - Name of the hook * `command` - (Required)Command to be executed - * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]` Default is `bash` + * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]` + * `element_id` - Element ID for the hook + * `has_credentials` - Flag to indicate if it has credentials -* `pre_stop` - (Optional) The commands to execute on the target environment before stopping a virtual source. This is a map of 3 parameters: +* `pre_stop` - (Optional) The commands to execute on the target environment before stopping a virtual source. This is a map of 5 parameters: * `name` - Name of the hook * `command` - (Required)Command to be executed - * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]` Default is `bash` + * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]` + * `element_id` - Element ID for the hook + * `has_credentials` - Flag to indicate if it has credentials -* `post_stop` - (Optional) The commands to execute on the target environment after stopping a virtual source. This is a map of 3 parameters: +* `post_stop` - (Optional) The commands to execute on the target environment after stopping a virtual source. This is a map of 5 parameters: * `name` - Name of the hook * `command` - (Required)Command to be executed - * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]` Default is `bash` + * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]` + * `element_id` - Element ID for the hook + * `has_credentials` - Flag to indicate if it has credentials * `vdb_restart` - (Optional) [Updatable] Indicates whether the Engine should automatically restart this virtual source when target host reboot is detected. +* `auxiliary_template_id` - (Optional) The ID of the configuration template to apply to the auxiliary container database. 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) + * `template_id` - (Optional) [Updatable] The ID of the target VDB Template (Oracle Only). * `file_mapping_rules` - (Optional) Target 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. @@ -132,6 +176,10 @@ resource "delphix_vdb" "vdb_name" { * `unique_name` - (Optional) Target VDB db_unique_name (Oracle Only). +* `vcdb_name` - (Optional) When provisioning an Oracle Multitenant vCDB (when the cdb_id property is not set), the name of the provisioned vCDB (Oracle Multitenant Only). + +* `vcdb_database_name` - (Optional) When provisioning an Oracle Multitenant vCDB (when the cdb_id property is not set), the database name of the provisioned vCDB. Defaults to the value of the vcdb_name property. (Oracle Multitenant Only). + * `mount_point` - (Optional) Mount point for the VDB (Oracle, ASE Only). * `open_reset_logs` - (Optional) Whether to open the database after provision (Oracle Only). @@ -167,7 +215,13 @@ Environment variable to be set when the engine creates a VDB. See the Engine doc * `timestamp_in_database_timezone` - (Optional) The point in time from which to execute the operation, expressed as a date-time in the timezone of the source database. Mutually exclusive with timestamp. -* `snapshot_id` - (Optional) The ID of the snapshot from which to execute the operation. If the snapshot_id is not, selects the latest snapshot. +* `snapshot_id` - (Optional) The ID or name of the snapshot from which to execute the operation. If the snapshot_id is not, selects the latest snapshot. + +* `bookmark_id` - (Optional) The ID or name of the bookmark from which to execute the operation. The bookmark must contain only one VDB. + +* `tags` - (Optional) The tags to be created for VDB. This is a map of 2 parameters: + * `key` - (Required) Key of the tag + * `value` - (Required) Value of the tag ## Attribute Reference diff --git a/examples/environment/main.tf b/examples/environment/main.tf index 4aa91db..668a864 100644 --- a/examples/environment/main.tf +++ b/examples/environment/main.tf @@ -1,7 +1,7 @@ terraform { required_providers { delphix = { - version = "1.0-beta" + version = "1.0.0-beta" source = "delphix.com/dct/delphix" } } @@ -25,6 +25,37 @@ resource "delphix_environment" "unixtgt" { description = "This is a unix target." } +/* Unix Standalone using Hashicorp vault +resource "delphix_environment" "unixtgt" { + engine_id = 1 + os_name = "UNIX" + hostname = "xxx" + + vault = "xxx" + hashicorp_vault_engine = "xxx" + hashicorp_vault_secret_path = "xxx" + hashicorp_vault_username_key = "xxx" + hashicorp_vault_secret_key = "xxx" + + toolkit_path = "/home/delphix_os/toolkit" + name = "unixtgt" + description = "This is a unix target." +} */ + +/* Unix Standalone using CyberArk vault +resource "delphix_environment" "unixtgt" { + engine_id = 1 + os_name = "UNIX" + hostname = "xxx" + + vault = "xxx" + cyberark_query_string = "xxx" + + toolkit_path = "/home/delphix_os/toolkit" + name = "unixtgt" + description = "This is a unix target." +} */ + /* Win Standalone - Target*/ /* resource "delphix_environment" "wintgt" { engine_id = 2 diff --git a/go.mod b/go.mod index d16d686..8da7a7f 100644 --- a/go.mod +++ b/go.mod @@ -2,14 +2,18 @@ module terraform-provider-delphix go 1.17 -require github.com/delphix/dct-sdk-go v1.0.0-beta3 +require ( + github.com/delphix/dct-sdk-go v1.2.0 + github.com/hashicorp/terraform-plugin-sdk v1.17.2 +) require ( github.com/agext/levenshtein v1.2.2 // indirect + github.com/apparentlymart/go-cidr v1.1.0 // indirect github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/fatih/color v1.7.0 // indirect - github.com/google/go-cmp v0.5.7 // indirect + github.com/google/go-cmp v0.5.8 // indirect github.com/hashicorp/errwrap v1.0.0 // indirect github.com/hashicorp/go-checkpoint v0.5.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect @@ -19,7 +23,7 @@ require ( github.com/hashicorp/go-plugin v1.4.3 // indirect github.com/hashicorp/go-uuid v1.0.2 // indirect github.com/hashicorp/go-version v1.4.0 // indirect - github.com/hashicorp/hc-install v0.3.1 // indirect + github.com/hashicorp/hc-install v0.3.2 // indirect github.com/hashicorp/hcl/v2 v2.11.1 // indirect github.com/hashicorp/logutils v1.0.0 // indirect github.com/hashicorp/terraform-exec v0.16.0 // indirect @@ -42,7 +46,7 @@ require ( github.com/vmihailenco/tagparser v0.1.1 // indirect github.com/zclconf/go-cty v1.10.0 // indirect golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e // indirect - golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect + golang.org/x/oauth2 v0.0.0-20220622183110-fd043fe589d2 // indirect golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect golang.org/x/text v0.3.7 // indirect google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d // indirect diff --git a/go.sum b/go.sum index 343a563..a910e1f 100644 --- a/go.sum +++ b/go.sum @@ -33,6 +33,9 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9 dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= +github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= +github.com/Masterminds/sprig v2.22.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o= github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= github.com/Microsoft/go-winio v0.4.16 h1:FtSW/jqD+l4ba5iPBj9CODVtgfYAD8w2wS923g/cFDk= github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0= @@ -43,9 +46,12 @@ github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE= github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= +github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412/go.mod h1:WPjqKcmVOxf0XSf3YxCJs6N6AOSrOx3obionmG7T0y0= +github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs= github.com/andybalholm/crlf v0.0.0-20171020200849-670099aa064f/go.mod h1:k8feO4+kXDxro6ErPXBRTJ/ro2mf0SsFG8s7doP9kJE= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= +github.com/apparentlymart/go-cidr v1.1.0 h1:2mAhrMoF+nhXqxTzSZMUzDHkLjmIHC+Zzn4tdgBZjnU= github.com/apparentlymart/go-cidr v1.1.0/go.mod h1:EBcsNrHc3zQeuaeCeCtQruQm+n9/YjEn/vI25Lg7Gwc= github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM= github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0 h1:MzVXffFUye+ZcSR6opIgz9Co7WcDx6ZcY+RjfFHoA0I= @@ -55,9 +61,16 @@ github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/ github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec= github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= +github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= +github.com/aws/aws-sdk-go v1.15.78/go.mod h1:E3/ieXAlvM0XWO57iftYVDLLvQ824smPP3ATZkfNZeM= +github.com/aws/aws-sdk-go v1.37.0/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= +github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4= +github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= @@ -72,8 +85,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/delphix/dct-sdk-go v1.0.0-beta3 h1:BqGqe/BeXB6jrk/tLBYDwrFh0qyncxTQqS87FRjWGdc= -github.com/delphix/dct-sdk-go v1.0.0-beta3/go.mod h1:HCJfdjYSs5eo1FpU4mGTMmVzb5zHn9EP6IzqA/+MKC8= +github.com/delphix/dct-sdk-go v1.2.0 h1:/YM+CjuXv1cx3xBDYGk1ST3QcAG4EAF5ty96elnnh+M= +github.com/delphix/dct-sdk-go v1.2.0/go.mod h1:jHmLaVSOGroT5E298s7GU3TobaZ8SH0RqUhFo5WkPqo= github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg= github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -89,10 +102,14 @@ github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeME github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4= github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E= +github.com/go-git/go-billy/v5 v5.0.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= +github.com/go-git/go-billy/v5 v5.1.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= github.com/go-git/go-billy/v5 v5.2.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= github.com/go-git/go-billy/v5 v5.3.1 h1:CPiOUAzKtMRvolEKw+bG1PLRpT7D3LIs3/3ey4Aiu34= github.com/go-git/go-billy/v5 v5.3.1/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= +github.com/go-git/go-git-fixtures/v4 v4.0.2-0.20200613231340-f56387b50c12/go.mod h1:m+ICp2rF3jDhFgEZ/8yziagdT1C+ZpZcrJjappBCDSw= github.com/go-git/go-git-fixtures/v4 v4.2.1/go.mod h1:K8zd3kDUAykwTdDCr+I0per6Y6vMiRR/nnVTBtavnB0= +github.com/go-git/go-git/v5 v5.3.0/go.mod h1:xdX4bWJ48aOrdhnl2XqHYstHbbp6+LFS4r4X+lNVprw= github.com/go-git/go-git/v5 v5.4.2 h1:BXyZu9t0VkbiHtqrsvdq39UDhGJTl1h55VW6CSC4aY4= github.com/go-git/go-git/v5 v5.4.2/go.mod h1:gQ1kArt6d+n+BGd+/B/I74HwRTLhth2+zti4ihgckDc= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= @@ -129,6 +146,7 @@ github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -138,10 +156,12 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o= github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= +github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= +github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= @@ -166,38 +186,57 @@ github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9n github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUKaCaGKZ/dR2roBXv0vKbSCnssIldfQdI= github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320/go.mod h1:EiZBMaudVLy8fmjf9Npq1dq9RalhveqZG5w/yz3mHWs= +github.com/hashicorp/go-getter v1.5.3/go.mod h1:BrrV/1clo8cCYu6mxvboYg+KutTiFnXjMEgDD8+i7ZI= +github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9uLqI8l75knNv3lV1kA55veR+WUPSiKIWcQHudI= +github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= github.com/hashicorp/go-hclog v0.14.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-hclog v1.2.0 h1:La19f8d7WIlm4ogzNHB0JGqs5AUDAZ2UfCY4sJXcJdM= github.com/hashicorp/go-hclog v1.2.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= +github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= +github.com/hashicorp/go-plugin v1.3.0/go.mod h1:F9eH4LrE/ZsRdbwhfjs9k9HoDUwAHnYtXdgmf1AVNs0= github.com/hashicorp/go-plugin v1.4.3 h1:DXmvivbWD5qdiBts9TpBC7BYL1Aia5sxbRgQB+v6UZM= github.com/hashicorp/go-plugin v1.4.3/go.mod h1:5fGEH17QVwTTcR0zV7yhDPLLmFX9YSZ38b18Udy6vYQ= +github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoDHxNAB65b+Rj1I= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2IGE= github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.3.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.4.0 h1:aAQzgqIrRKRa7w75CKpbBxYsmUoPjzVm1W59ca1L0J4= github.com/hashicorp/go-version v1.4.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/hc-install v0.3.1 h1:VIjllE6KyAI1A244G8kTaHXy+TL5/XYzvrtFi8po/Yk= github.com/hashicorp/hc-install v0.3.1/go.mod h1:3LCdWcCDS1gaHC9mhHCGbkYfoY6vdsKohGjugbZdZak= +github.com/hashicorp/hc-install v0.3.2 h1:oiQdJZvXmkNcRcEOOfM5n+VTsvNjWQeOjfAoO6dKSH8= +github.com/hashicorp/hc-install v0.3.2/go.mod h1:xMG6Tr8Fw1WFjlxH0A9v61cW15pFwgEGqEz0V4jisHs= +github.com/hashicorp/hcl v0.0.0-20170504190234-a4b07c25de5f h1:UdxlrJz4JOnY8W+DbLISwf2B8WXEolNRA8BGCwI9jws= +github.com/hashicorp/hcl v0.0.0-20170504190234-a4b07c25de5f/go.mod h1:oZtUIOe8dh44I2q6ScRibXws4Ajl+d+nod3AaR9vL5w= +github.com/hashicorp/hcl/v2 v2.0.0/go.mod h1:oVVDG71tEinNGYCxinCYadcmKU9bglqW9pV3txagJ90= +github.com/hashicorp/hcl/v2 v2.8.2/go.mod h1:bQTN5mpo+jewjJgh8jr0JUguIi7qPHUF6yIfAEN3jqY= github.com/hashicorp/hcl/v2 v2.11.1 h1:yTyWcXcm9XB0TEkyU/JCRU6rYy4K+mgLtzn2wlrJbcc= github.com/hashicorp/hcl/v2 v2.11.1/go.mod h1:FwWsfWEjyV/CMj8s/gqAuiviY72rJ1/oayI9WftqcKg= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= +github.com/hashicorp/terraform-config-inspect v0.0.0-20191212124732-c6ae6269b9d7/go.mod h1:p+ivJws3dpqbp1iP84+npOyAmTTOLMgCzrXd3GSdn/A= +github.com/hashicorp/terraform-exec v0.13.3/go.mod h1:SSg6lbUsVB3DmFyCPjBPklqf6EYGX0TlQ6QTxOlikDU= github.com/hashicorp/terraform-exec v0.16.0 h1:XUh9pJPcbfZsuhReVvmRarQTaiiCnYogFCCjOvEYuug= github.com/hashicorp/terraform-exec v0.16.0/go.mod h1:wB5JHmjxZ/YVNZuv9npAXKmz5pGyxy8PSi0GRR0+YjA= +github.com/hashicorp/terraform-json v0.10.0/go.mod h1:3defM4kkMfttwiE7VakJDwCd4R+umhSQnvJwORXbprE= github.com/hashicorp/terraform-json v0.13.0 h1:Li9L+lKD1FO5RVFRM1mMMIBDoUHslOniyEi5CM+FWGY= github.com/hashicorp/terraform-json v0.13.0/go.mod h1:y5OdLBCT+rxbwnpxZs9kGL7R9ExU76+cpdY8zHwoazk= github.com/hashicorp/terraform-plugin-go v0.8.0 h1:MvY43PcDj9VlBjYifBWCO/6j1wf106xU8d5Tob/WRs0= github.com/hashicorp/terraform-plugin-go v0.8.0/go.mod h1:E3GuvfX0Pz2Azcl6BegD6t51StXsVZMOYQoGO8mkHM0= github.com/hashicorp/terraform-plugin-log v0.3.0 h1:NPENNOjaJSVX0f7JJTl4f/2JKRPQ7S2ZN9B4NSqq5kA= github.com/hashicorp/terraform-plugin-log v0.3.0/go.mod h1:EjueSP/HjlyFAsDqt+okpCPjkT4NDynAe32AeDC4vps= +github.com/hashicorp/terraform-plugin-sdk v1.17.2 h1:V7DUR3yBWFrVB9z3ddpY7kiYVSsq4NYR67NiTs93NQo= +github.com/hashicorp/terraform-plugin-sdk v1.17.2/go.mod h1:wkvldbraEMkz23NxkkAsFS88A1R9eUiooiaUZyS6TLw= github.com/hashicorp/terraform-plugin-sdk/v2 v2.12.0 h1:rjJxyLUVA180BG0ZXTOree4x2RVvo2jigdYoT2rw5j0= github.com/hashicorp/terraform-plugin-sdk/v2 v2.12.0/go.mod h1:TPjMXvpPNWagHzYOmVPzzRRIBTuaLVukR+esL08tgzg= +github.com/hashicorp/terraform-plugin-test/v2 v2.2.1/go.mod h1:eZ9JL3O69Cb71Skn6OhHyj17sLmHRb+H6VrDcJjKrYU= github.com/hashicorp/terraform-registry-address v0.0.0-20210412075316-9b2996cce896 h1:1FGtlkJw87UsTMg5s8jrekrHmUPUJaMcu6ELiVhQrNw= github.com/hashicorp/terraform-registry-address v0.0.0-20210412075316-9b2996cce896/go.mod h1:bzBPnUIkI0RxauU8Dqo+2KrZZ28Cf48s8V6IHt3p4co= github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKLsbzeOsfXmKNpr3GiT18XAblV0BjCbzL8KQAMZGa0= @@ -205,7 +244,9 @@ github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734/go.mod github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= +github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= @@ -213,11 +254,16 @@ github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE= github.com/jhump/protoreflect v1.6.0/go.mod h1:eaTn3RZAmMBcV0fifFvlm6VHNz3wSkYyXYWUh7ymB74= +github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= +github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 h1:DowS9hvgyYSX4TO5NpyC606/Z4SxnNYbT+WX27or6Ck= github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= +github.com/keybase/go-crypto v0.0.0-20161004153544-93f5b35093ba/go.mod h1:ghbZscTyKdM07+Fw3KSi0hcJm+AlEUWj8QLlPtijN/M= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/compress v1.11.2/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= @@ -230,23 +276,38 @@ github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LE github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= +github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.10 h1:qxFzApOv4WsAL965uUPIsXzAKCZxN2p9UqdhFS4ZW10= github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= +github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/mitchellh/cli v1.1.2/go.mod h1:6iaV0fGdElS6dPBx0EApTxHrcWvmJphyh2n8YBLPPZ4= +github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw= +github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= +github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= +github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= +github.com/mitchellh/go-testing-interface v1.0.4/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4= github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= +github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs= github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/mitchellh/reflectwalk v1.0.1/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= @@ -254,10 +315,13 @@ github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce h1:RPclfga2SEJmgMmz2k github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce/go.mod h1:uFMI8w+ref4v2r9jz+c9i1IfIttS/OkmLfrk1jne5hs= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= +github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= +github.com/posener/complete v1.2.1/go.mod h1:6gapUrK/U1TAN7ciCoNRIdVC5sbdBTUh1DKN0g6uH7E= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= @@ -267,15 +331,19 @@ github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNX github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= +github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/ulikunitz/xz v0.5.8/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= @@ -288,13 +356,18 @@ github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6e github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/zclconf/go-cty v1.0.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= +github.com/zclconf/go-cty v1.2.1/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= github.com/zclconf/go-cty v1.8.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= +github.com/zclconf/go-cty v1.8.2/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= github.com/zclconf/go-cty v1.9.1/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= github.com/zclconf/go-cty v1.10.0 h1:mp9ZXQeIcN8kAwuqorjH+Q+njbJKjLrvB2yIh4q7U+0= github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= +github.com/zclconf/go-cty-yaml v1.0.2/go.mod h1:IP3Ylp0wQpYm50IHK8OZWKMu6sPJIUgKa8XhiVHura0= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= @@ -308,6 +381,7 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e h1:gsTQYXdTw2Gq7RBsWvlQ91b+aEQ6bXFUngBGuR8sPpI= @@ -371,6 +445,8 @@ golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k= @@ -381,8 +457,9 @@ golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4Iltr golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a h1:qfl7ob3DIEs3Ml9oLuPwY2N04gymzAW04WsUQHIClgM= -golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= +golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20220622183110-fd043fe589d2 h1:+jnHzr9VPj32ykQVai5DNahi9+NSp7yYuCsl5eAQtL0= +golang.org/x/oauth2 v0.0.0-20220622183110-fd043fe589d2/go.mod h1:jaDAt6Dkxork7LmZnYtzbRWj0W47D86a3TGe0YHBvmE= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -391,6 +468,7 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -421,6 +499,8 @@ golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -429,6 +509,7 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -482,10 +563,11 @@ golang.org/x/tools v0.0.0-20200713011307-fd294ab11aed/go.mod h1:njjCfa9FT2d7l9Bc golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= +golang.org/x/tools v0.0.0-20201028111035-eafbe7b904eb/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= @@ -503,6 +585,7 @@ google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0M google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= +google.golang.org/api v0.34.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -557,6 +640,8 @@ google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKa google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.45.0 h1:NEpgUqV3Z+ZjkqMsxMg11IaDrXY4RY6CQukSGK0uI1M= @@ -581,12 +666,14 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/cheggaaa/pb.v1 v1.0.27/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/provider/commons.go b/internal/provider/commons.go index 32156bb..a676f75 100644 --- a/internal/provider/commons.go +++ b/internal/provider/commons.go @@ -1,8 +1,13 @@ package provider const ( - Running string = "RUNNING" + Pending string = "PENDING" + Started string = "STARTED" + Timedout string = "TIMEDOUT" Failed string = "FAILED" + Completed string = "COMPLETED" + Canceled string = "CANCELED" + Abandoned string = "ABANDONED" JOB_STATUS_SLEEP_TIME int = 5 STATUS_POLL_SLEEP_TIME int = 20 ) diff --git a/internal/provider/resource_environment.go b/internal/provider/resource_environment.go index b8b9585..2b7bbf8 100644 --- a/internal/provider/resource_environment.go +++ b/internal/provider/resource_environment.go @@ -25,7 +25,7 @@ func resourceEnvironment() *schema.Resource { Optional: true, }, "engine_id": { - Type: schema.TypeInt, + Type: schema.TypeString, Required: true, }, "os_name": { @@ -66,11 +66,71 @@ func resourceEnvironment() *schema.Resource { }, "username": { Type: schema.TypeString, - Required: true, + Optional: true, }, "password": { Type: schema.TypeString, - Required: true, + Optional: true, + }, + "vault": { + Type: schema.TypeString, + Optional: true, + }, + "hashicorp_vault_engine": { + Type: schema.TypeString, + Optional: true, + }, + "hashicorp_vault_secret_path": { + Type: schema.TypeString, + Optional: true, + }, + "hashicorp_vault_username_key": { + Type: schema.TypeString, + Optional: true, + }, + "hashicorp_vault_secret_key": { + Type: schema.TypeString, + Optional: true, + }, + "cyberark_vault_query_string": { + Type: schema.TypeString, + Optional: true, + }, + "use_kerberos_authentication": { + Type: schema.TypeBool, + Optional: true, + }, + "use_engine_public_key": { + Type: schema.TypeBool, + Optional: true, + }, + "ase_db_vault": { + Type: schema.TypeString, + Optional: true, + }, + "ase_db_hashicorp_vault_engine": { + Type: schema.TypeString, + Optional: true, + }, + "ase_db_hashicorp_vault_secret_path": { + Type: schema.TypeString, + Optional: true, + }, + "ase_db_hashicorp_vault_username_key": { + Type: schema.TypeString, + Optional: true, + }, + "ase_db_hashicorp_vault_secret_key": { + Type: schema.TypeString, + Optional: true, + }, + "ase_db_cyberark_vault_query_string": { + Type: schema.TypeString, + Optional: true, + }, + "ase_db_use_kerberos_authentication": { + Type: schema.TypeBool, + Optional: true, }, "nfs_addresses": { Type: schema.TypeList, @@ -115,6 +175,22 @@ func resourceEnvironment() *schema.Resource { Type: schema.TypeString, Optional: true, }, + "tags": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "key": { + Type: schema.TypeString, + Required: true, + }, + "value": { + Type: schema.TypeString, + Optional: true, + }, + }, + }, + }, "namespace": { Type: schema.TypeString, Computed: true, @@ -158,7 +234,7 @@ func resourceEnvironmentCreate(ctx context.Context, d *schema.ResourceData, meta client := meta.(*apiClient).client createEnvParams := dctapi.NewEnvironmentCreateParameters( - int64(d.Get("engine_id").(int)), + d.Get("engine_id").(string), d.Get("os_name").(string), d.Get("hostname").(string), ) @@ -206,6 +282,51 @@ func resourceEnvironmentCreate(ctx context.Context, d *schema.ResourceData, meta if v, has_v := d.GetOk("description"); has_v { createEnvParams.SetDescription(v.(string)) } + if v, has_v := d.GetOk("vault"); has_v { + createEnvParams.SetVault(v.(string)) + } + if v, has_v := d.GetOk("hashicorp_vault_engine"); has_v { + createEnvParams.SetHashicorpVaultEngine(v.(string)) + } + if v, has_v := d.GetOk("hashicorp_vault_secret_path"); has_v { + createEnvParams.SetHashicorpVaultSecretPath(v.(string)) + } + if v, has_v := d.GetOk("hashicorp_vault_username_key"); has_v { + createEnvParams.SetHashicorpVaultUsernameKey(v.(string)) + } + if v, has_v := d.GetOk("hashicorp_vault_secret_key"); has_v { + createEnvParams.SetHashicorpVaultSecretKey(v.(string)) + } + if v, has_v := d.GetOk("cyberark_vault_query_string"); has_v { + createEnvParams.SetCyberarkVaultQueryString(v.(string)) + } + if v, has_v := d.GetOk("use_kerberos_authentication"); has_v { + createEnvParams.SetUseKerberosAuthentication(v.(bool)) + } + if v, has_v := d.GetOk("use_engine_public_key"); has_v { + createEnvParams.SetUseEnginePublicKey(v.(bool)) + } + if v, has_v := d.GetOk("ase_db_vault"); has_v { + createEnvParams.SetAseDbVault(v.(string)) + } + if v, has_v := d.GetOk("ase_db_hashicorp_vault_engine"); has_v { + createEnvParams.SetAseDbHashicorpVaultEngine(v.(string)) + } + if v, has_v := d.GetOk("ase_db_hashicorp_vault_secret_path"); has_v { + createEnvParams.SetAseDbHashicorpVaultSecretPath(v.(string)) + } + if v, has_v := d.GetOk("ase_db_hashicorp_vault_username_key"); has_v { + createEnvParams.SetAseDbHashicorpVaultUsernameKey(v.(string)) + } + if v, has_v := d.GetOk("ase_db_hashicorp_vault_secret_key"); has_v { + createEnvParams.SetAseDbHashicorpVaultSecretKey(v.(string)) + } + if v, has_v := d.GetOk("ase_db_cyberark_vault_query_string"); has_v { + createEnvParams.SetAseDbCyberarkVaultQueryString(v.(string)) + } + if v, has_v := d.GetOk("ase_db_use_kerberos_authentication"); has_v { + createEnvParams.SetAseDbUseKerberosAuthentication(v.(bool)) + } // Clusters os_name := d.Get("os_name").(string) @@ -230,8 +351,11 @@ func resourceEnvironmentCreate(ctx context.Context, d *schema.ResourceData, meta if v, has_v := d.GetOk("nfs_addresses"); has_v { createEnvParams.SetNfsAddresses(toStringArray(v)) } + if v, has_v := d.GetOk("tags"); has_v { + createEnvParams.SetTags(toTagArray(v)) + } - apiReq := client.EnvironmentsApi.CreateEnvironments(ctx) + apiReq := client.EnvironmentsApi.CreateEnvironment(ctx) apiRes, httpRes, err := apiReq.EnvironmentCreateParameters(*createEnvParams).Execute() if diags := apiErrorResponseHelper(apiRes, httpRes, err); diags != nil { @@ -239,15 +363,15 @@ func resourceEnvironmentCreate(ctx context.Context, d *schema.ResourceData, meta } d.SetId(apiRes.GetEnvironmentId()) - job_status, job_err := PollJobStatus(*apiRes.JobId, ctx, client) + job_status, job_err := PollJobStatus(*apiRes.Job.Id, ctx, client) if job_err != "" { ErrorLog.Printf("Job Polling failed but continuing with env creation. Error: %v", job_err) } - if job_status == Failed { + if isJobTerminalFailure(job_status) { d.SetId("") - return diag.Errorf("[NOT OK] Env-Create failed. JobId: %s / Error: %s", *apiRes.JobId, job_err) + return diag.Errorf("[NOT OK] Env-Create %s. JobId: %s / Error: %s", job_status, *apiRes.Job.Id, job_err) } // Get environment info and store state. readDiags := resourceEnvironmentRead(ctx, d, meta) @@ -266,9 +390,16 @@ func resourceEnvironmentRead(ctx context.Context, d *schema.ResourceData, meta i }) if diags != nil { - ErrorLog.Printf("Error Env-Read failed for EnvId:%s. Removing from state file.", envId) - d.SetId("") - return diags + _, diags := PollForObjectDeletion(func() (interface{}, *http.Response, error) { + return client.EnvironmentsApi.GetEnvironmentById(ctx, envId).Execute() + }) + if diags != nil { + ErrorLog.Printf("Error in polling of environment for deletion.") + } else { + ErrorLog.Printf("Error Env-Read failed for EnvId:%s. Removing from state file.", envId) + d.SetId("") + } + return nil } envRes, _ := apiRes.(*dctapi.Environment) @@ -295,12 +426,12 @@ func resourceEnvironmentDelete(ctx context.Context, d *schema.ResourceData, meta return diags } - job_status, job_err := PollJobStatus(*apiRes.JobId, ctx, client) + job_status, job_err := PollJobStatus(*apiRes.Job.Id, ctx, client) if job_err != "" { ErrorLog.Printf("Job Polling failed but continuing with env deletion. Error: %v", job_err) } - if job_status == Failed { - return diag.Errorf("[NOT OK] Env-Delete failed. JobId: %s / Error: %s", *apiRes.JobId, job_err) + if isJobTerminalFailure(job_status) { + return diag.Errorf("[NOT OK] Env-Delete %s. JobId: %s / Error: %s", job_status, *apiRes.Job.Id, job_err) } _, diags := PollForObjectDeletion(func() (interface{}, *http.Response, error) { return client.EnvironmentsApi.GetEnvironmentById(ctx, envId).Execute() diff --git a/internal/provider/resource_vdb.go b/internal/provider/resource_vdb.go index 5757568..2a46828 100644 --- a/internal/provider/resource_vdb.go +++ b/internal/provider/resource_vdb.go @@ -3,7 +3,6 @@ package provider import ( "context" "net/http" - "strconv" "time" dctapi "github.com/delphix/dct-sdk-go" @@ -33,16 +32,12 @@ func resourceVdb() *schema.Resource { }, "source_data_id": { Type: schema.TypeString, - Required: true, + Optional: true, }, "id": { Type: schema.TypeString, Computed: true, }, - "job_id": { - Type: schema.TypeString, - Computed: true, - }, "database_type": { Type: schema.TypeString, Computed: true, @@ -86,7 +81,7 @@ func resourceVdb() *schema.Resource { Type: schema.TypeString, Optional: true, }, - "vdb_name": { + "name": { Type: schema.TypeString, Computed: true, Optional: true, @@ -95,15 +90,31 @@ func resourceVdb() *schema.Resource { Type: schema.TypeString, Optional: true, }, + "cdb_id": { + Type: schema.TypeString, + Optional: true, + }, + "cluster_node_ids": { + Type: schema.TypeString, + Optional: true, + }, "truncate_log_on_checkpoint": { Type: schema.TypeBool, Optional: true, }, - "username": { + "os_username": { + Type: schema.TypeString, + Optional: true, + }, + "os_password": { + Type: schema.TypeString, + Optional: true, + }, + "db_username": { Type: schema.TypeString, Optional: true, }, - "password": { + "db_password": { Type: schema.TypeString, Optional: true, }, @@ -131,7 +142,14 @@ func resourceVdb() *schema.Resource { "shell": { Type: schema.TypeString, Optional: true, - Default: "bash", + }, + "element_id": { + Type: schema.TypeString, + Optional: true, + }, + "has_credentials": { + Type: schema.TypeBool, + Optional: true, }, }, }, @@ -152,7 +170,14 @@ func resourceVdb() *schema.Resource { "shell": { Type: schema.TypeString, Optional: true, - Default: "bash", + }, + "element_id": { + Type: schema.TypeString, + Optional: true, + }, + "has_credentials": { + Type: schema.TypeBool, + Optional: true, }, }, }, @@ -173,7 +198,14 @@ func resourceVdb() *schema.Resource { "shell": { Type: schema.TypeString, Optional: true, - Default: "bash", + }, + "element_id": { + Type: schema.TypeString, + Optional: true, + }, + "has_credentials": { + Type: schema.TypeBool, + Optional: true, }, }, }, @@ -194,7 +226,14 @@ func resourceVdb() *schema.Resource { "shell": { Type: schema.TypeString, Optional: true, - Default: "bash", + }, + "element_id": { + Type: schema.TypeString, + Optional: true, + }, + "has_credentials": { + Type: schema.TypeBool, + Optional: true, }, }, }, @@ -215,7 +254,14 @@ func resourceVdb() *schema.Resource { "shell": { Type: schema.TypeString, Optional: true, - Default: "bash", + }, + "element_id": { + Type: schema.TypeString, + Optional: true, + }, + "has_credentials": { + Type: schema.TypeBool, + Optional: true, }, }, }, @@ -236,7 +282,14 @@ func resourceVdb() *schema.Resource { "shell": { Type: schema.TypeString, Optional: true, - Default: "bash", + }, + "element_id": { + Type: schema.TypeString, + Optional: true, + }, + "has_credentials": { + Type: schema.TypeBool, + Optional: true, }, }, }, @@ -257,7 +310,14 @@ func resourceVdb() *schema.Resource { "shell": { Type: schema.TypeString, Optional: true, - Default: "bash", + }, + "element_id": { + Type: schema.TypeString, + Optional: true, + }, + "has_credentials": { + Type: schema.TypeBool, + Optional: true, }, }, }, @@ -278,7 +338,14 @@ func resourceVdb() *schema.Resource { "shell": { Type: schema.TypeString, Optional: true, - Default: "bash", + }, + "element_id": { + Type: schema.TypeString, + Optional: true, + }, + "has_credentials": { + Type: schema.TypeBool, + Optional: true, }, }, }, @@ -299,7 +366,14 @@ func resourceVdb() *schema.Resource { "shell": { Type: schema.TypeString, Optional: true, - Default: "bash", + }, + "element_id": { + Type: schema.TypeString, + Optional: true, + }, + "has_credentials": { + Type: schema.TypeBool, + Optional: true, }, }, }, @@ -320,7 +394,14 @@ func resourceVdb() *schema.Resource { "shell": { Type: schema.TypeString, Optional: true, - Default: "bash", + }, + "element_id": { + Type: schema.TypeString, + Optional: true, + }, + "has_credentials": { + Type: schema.TypeBool, + Optional: true, }, }, }, @@ -341,7 +422,14 @@ func resourceVdb() *schema.Resource { "shell": { Type: schema.TypeString, Optional: true, - Default: "bash", + }, + "element_id": { + Type: schema.TypeString, + Optional: true, + }, + "has_credentials": { + Type: schema.TypeBool, + Optional: true, }, }, }, @@ -354,6 +442,10 @@ func resourceVdb() *schema.Resource { Type: schema.TypeString, Optional: true, }, + "auxiliary_template_id": { + Type: schema.TypeString, + Optional: true, + }, "file_mapping_rules": { Type: schema.TypeString, Optional: true, @@ -366,6 +458,14 @@ func resourceVdb() *schema.Resource { Type: schema.TypeString, Optional: true, }, + "vcdb_name": { + Type: schema.TypeString, + Optional: true, + }, + "vcdb_database_name": { + Type: schema.TypeString, + Optional: true, + }, "mount_point": { Type: schema.TypeString, Optional: true, @@ -447,6 +547,26 @@ func resourceVdb() *schema.Resource { Type: schema.TypeString, Optional: true, }, + "bookmark_id": { + Type: schema.TypeString, + Optional: true, + }, + "tags": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "key": { + Type: schema.TypeString, + Required: true, + }, + "value": { + Type: schema.TypeString, + Optional: true, + }, + }, + }, + }, }, } } @@ -469,6 +589,17 @@ func toHookArray(array interface{}) []dctapi.Hook { return items } +func toTagArray(array interface{}) []dctapi.Tag { + items := []dctapi.Tag{} + for _, item := range array.([]interface{}) { + item_map := item.(map[string]interface{}) + tag_item := dctapi.NewTag(item_map["key"].(string), item_map["value"].(string)) + + items = append(items, *tag_item) + } + return items +} + func helper_provision_by_snapshot(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics client := meta.(*apiClient).client @@ -479,96 +610,117 @@ func helper_provision_by_snapshot(ctx context.Context, d *schema.ResourceData, m if v, has_v := d.GetOkExists("auto_select_repository"); has_v { provisionVDBBySnapshotParameters.SetAutoSelectRepository(v.(bool)) } - if v, has_v := d.GetOk("source_data_id"); has_v { provisionVDBBySnapshotParameters.SetSourceDataId(v.(string)) } - if v, has_v := d.GetOk("engine_id"); has_v { - eng_id, _ := strconv.Atoi(v.(string)) - provisionVDBBySnapshotParameters.SetEngineId(int64(eng_id)) + provisionVDBBySnapshotParameters.SetEngineId(v.(string)) } - if v, has_v := d.GetOk("target_group_id"); has_v { provisionVDBBySnapshotParameters.SetTargetGroupId(v.(string)) } - - if v, has_v := d.GetOk("vdb_name"); has_v { - provisionVDBBySnapshotParameters.SetVdbName(v.(string)) + if v, has_v := d.GetOk("name"); has_v { + provisionVDBBySnapshotParameters.SetName(v.(string)) } - if v, has_v := d.GetOk("database_name"); has_v { provisionVDBBySnapshotParameters.SetDatabaseName(v.(string)) } - - if v, has_v := d.GetOk("username"); has_v { - provisionVDBBySnapshotParameters.SetUsername(v.(string)) + if v, has_v := d.GetOk("cdb_id"); has_v { + provisionVDBBySnapshotParameters.SetCdbId(v.(string)) } - - if v, has_v := d.GetOk("password"); has_v { - provisionVDBBySnapshotParameters.SetPassword(v.(string)) + if v, has_v := d.GetOk("cluster_node_ids"); has_v { + provisionVDBBySnapshotParameters.SetClusterNodeIds(toStringArray(v)) + } + if v, has_v := d.GetOkExists("truncate_log_on_checkpoint"); has_v { + provisionVDBBySnapshotParameters.SetTruncateLogOnCheckpoint(v.(bool)) + } + if v, has_v := d.GetOk("os_username"); has_v { + provisionVDBBySnapshotParameters.SetOsUsername(v.(string)) + } + if v, has_v := d.GetOk("os_password"); has_v { + provisionVDBBySnapshotParameters.SetOsPassword(v.(string)) } - if v, has_v := d.GetOk("environment_id"); has_v { provisionVDBBySnapshotParameters.SetEnvironmentId(v.(string)) } - if v, has_v := d.GetOk("environment_user_id"); has_v { provisionVDBBySnapshotParameters.SetEnvironmentUserId(v.(string)) } - + if v, has_v := d.GetOk("repository_id"); has_v { + provisionVDBBySnapshotParameters.SetRepositoryId(v.(string)) + } if v, has_v := d.GetOkExists("auto_select_repository"); has_v { provisionVDBBySnapshotParameters.SetAutoSelectRepository(v.(bool)) } - if v, has_v := d.GetOkExists("vdb_restart"); has_v { provisionVDBBySnapshotParameters.SetVdbRestart(v.(bool)) } - + if v, has_v := d.GetOk("template_id"); has_v { + provisionVDBBySnapshotParameters.SetTemplateId(v.(string)) + } + if v, has_v := d.GetOk("auxiliary_template_id"); has_v { + provisionVDBBySnapshotParameters.SetAuxiliaryTemplateId(v.(string)) + } if v, has_v := d.GetOk("file_mapping_rules"); has_v { provisionVDBBySnapshotParameters.SetFileMappingRules(v.(string)) } - if v, has_v := d.GetOk("oracle_instance_name"); has_v { provisionVDBBySnapshotParameters.SetOracleInstanceName(v.(string)) } - if v, has_v := d.GetOk("unique_name"); has_v { provisionVDBBySnapshotParameters.SetUniqueName(v.(string)) } - + if v, has_v := d.GetOk("vcdb_name"); has_v { + provisionVDBBySnapshotParameters.SetVcdbName(v.(string)) + } + if v, has_v := d.GetOk("vcdb_database_name"); has_v { + provisionVDBBySnapshotParameters.SetVcdbDatabaseName(v.(string)) + } if v, has_v := d.GetOk("mount_point"); has_v { provisionVDBBySnapshotParameters.SetMountPoint(v.(string)) } - + if v, has_v := d.GetOkExists("open_reset_logs"); has_v { + provisionVDBBySnapshotParameters.SetOpenResetLogs(v.(bool)) + } if v, has_v := d.GetOk("snapshot_policy_id"); has_v { provisionVDBBySnapshotParameters.SetSnapshotPolicyId(v.(string)) } - if v, has_v := d.GetOk("retention_policy_id"); has_v { provisionVDBBySnapshotParameters.SetRetentionPolicyId(v.(string)) } - + if v, has_v := d.GetOk("recovery_model"); has_v { + provisionVDBBySnapshotParameters.SetRecoveryModel(v.(string)) + } + if v, has_v := d.GetOk("pre_script"); has_v { + provisionVDBBySnapshotParameters.SetPreScript(v.(string)) + } + if v, has_v := d.GetOk("post_script"); has_v { + provisionVDBBySnapshotParameters.SetPostScript(v.(string)) + } + if v, has_v := d.GetOkExists("cdc_on_provision"); has_v { + provisionVDBBySnapshotParameters.SetCdcOnProvision(v.(bool)) + } if v, has_v := d.GetOk("online_log_size"); has_v { provisionVDBBySnapshotParameters.SetOnlineLogSize(int32(v.(int))) } - if v, has_v := d.GetOk("online_log_groups"); has_v { provisionVDBBySnapshotParameters.SetOnlineLogGroups(int32(v.(int))) } - if v, has_v := d.GetOkExists("archive_log"); has_v { provisionVDBBySnapshotParameters.SetArchiveLog(v.(bool)) } - + if v, has_v := d.GetOkExists("new_dbid"); has_v { + provisionVDBBySnapshotParameters.SetNewDbid(v.(bool)) + } + if v, has_v := d.GetOkExists("listener_ids"); has_v { + provisionVDBBySnapshotParameters.SetListenerIds(toStringArray(v)) + } if v, has_v := d.GetOk("snapshot_id"); has_v { provisionVDBBySnapshotParameters.SetSnapshotId(v.(string)) } - if v, has_v := d.GetOk("custom_env_files"); has_v { provisionVDBBySnapshotParameters.SetCustomEnvFiles(toStringArray(v)) } - if v, has_v := d.GetOk("custom_env_vars"); has_v { custom_env_vars := make(map[string]string) @@ -581,46 +733,39 @@ func helper_provision_by_snapshot(ctx context.Context, d *schema.ResourceData, m if v, has_v := d.GetOk("pre_refresh"); has_v { provisionVDBBySnapshotParameters.SetPreRefresh(toHookArray(v)) } - if v, has_v := d.GetOk("post_refresh"); has_v { provisionVDBBySnapshotParameters.SetPostRefresh(toHookArray(v)) } - if v, has_v := d.GetOk("pre_rollback"); has_v { provisionVDBBySnapshotParameters.SetPreRollback(toHookArray(v)) } - if v, has_v := d.GetOk("post_rollback"); has_v { provisionVDBBySnapshotParameters.SetPostRollback(toHookArray(v)) } - if v, has_v := d.GetOk("configure_clone"); has_v { provisionVDBBySnapshotParameters.SetConfigureClone(toHookArray(v)) } - if v, has_v := d.GetOk("pre_snapshot"); has_v { provisionVDBBySnapshotParameters.SetPreSnapshot(toHookArray(v)) } - if v, has_v := d.GetOk("post_snapshot"); has_v { provisionVDBBySnapshotParameters.SetPostSnapshot(toHookArray(v)) } - if v, has_v := d.GetOk("pre_start"); has_v { provisionVDBBySnapshotParameters.SetPreStart(toHookArray(v)) } - if v, has_v := d.GetOk("post_start"); has_v { provisionVDBBySnapshotParameters.SetPostStart(toHookArray(v)) } - if v, has_v := d.GetOk("pre_stop"); has_v { provisionVDBBySnapshotParameters.SetPreStop(toHookArray(v)) } - if v, has_v := d.GetOk("post_stop"); has_v { provisionVDBBySnapshotParameters.SetPostStop(toHookArray(v)) } + if v, has_v := d.GetOk("tags"); has_v { + provisionVDBBySnapshotParameters.SetTags(toTagArray(v)) + } req := client.VDBsApi.ProvisionVdbBySnapshot(ctx) @@ -629,16 +774,16 @@ func helper_provision_by_snapshot(ctx context.Context, d *schema.ResourceData, m return diags } - d.SetId(*apiRes.Vdb.Id) + d.SetId(*apiRes.VdbId) - job_res, job_err := PollJobStatus(*apiRes.JobId, ctx, client) + job_res, job_err := PollJobStatus(*apiRes.Job.Id, ctx, client) if job_err != "" { ErrorLog.Printf("Job Polling failed but continuing with provisioning. Error: %s", job_err) } InfoLog.Printf("Job result is %s", job_res) - if job_res == Failed { - ErrorLog.Printf("Job %s Failed!", apiRes.GetJobId()) - return diag.Errorf("[NOT OK] Job %s Failed with error %s", apiRes.GetJobId(), job_err) + if job_res == Failed || job_res == Canceled || job_res == Abandoned { + ErrorLog.Printf("Job %s %s!", job_res, *apiRes.Job.Id) + return diag.Errorf("[NOT OK] Job %s %s with error %s", *apiRes.Job.Id, job_res, job_err) } readDiags := resourceVdbRead(ctx, d, meta) @@ -659,122 +804,107 @@ func helper_provision_by_timestamp(ctx context.Context, d *schema.ResourceData, // Setters for provisionVDBByTimestampParameters if v, has_v := d.GetOk("engine_id"); has_v { // provisionVDBByTimestampParameters.SetEngineId(int64(v.(int))) - eng_id, _ := strconv.Atoi(v.(string)) - provisionVDBByTimestampParameters.SetEngineId(int64(eng_id)) + provisionVDBByTimestampParameters.SetEngineId(v.(string)) } - if v, has_v := d.GetOk("target_group_id"); has_v { provisionVDBByTimestampParameters.SetTargetGroupId(v.(string)) } - - if v, has_v := d.GetOk("vdb_name"); has_v { - provisionVDBByTimestampParameters.SetVdbName(v.(string)) + if v, has_v := d.GetOk("name"); has_v { + provisionVDBByTimestampParameters.SetName(v.(string)) } - if v, has_v := d.GetOk("database_name"); has_v { provisionVDBByTimestampParameters.SetDatabaseName(v.(string)) } - + if v, has_v := d.GetOk("cdb_id"); has_v { + provisionVDBByTimestampParameters.SetCdbId(v.(string)) + } + if v, has_v := d.GetOk("cluster_node_ids"); has_v { + provisionVDBByTimestampParameters.SetClusterNodeIds(toStringArray(v)) + } if v, has_v := d.GetOkExists("truncate_log_on_checkpoint"); has_v { provisionVDBByTimestampParameters.SetTruncateLogOnCheckpoint(v.(bool)) } - - if v, has_v := d.GetOk("username"); has_v { - provisionVDBByTimestampParameters.SetUsername(v.(string)) + if v, has_v := d.GetOk("os_username"); has_v { + provisionVDBByTimestampParameters.SetOsUsername(v.(string)) } - - if v, has_v := d.GetOk("password"); has_v { - provisionVDBByTimestampParameters.SetPassword(v.(string)) + if v, has_v := d.GetOk("os_password"); has_v { + provisionVDBByTimestampParameters.SetOsPassword(v.(string)) } - if v, has_v := d.GetOk("environment_id"); has_v { provisionVDBByTimestampParameters.SetEnvironmentId(v.(string)) } - if v, has_v := d.GetOk("environment_user_id"); has_v { provisionVDBByTimestampParameters.SetEnvironmentUserId(v.(string)) } - if v, has_v := d.GetOk("repository_id"); has_v { provisionVDBByTimestampParameters.SetRepositoryId(v.(string)) } - if v, has_v := d.GetOkExists("auto_select_repository"); has_v { provisionVDBByTimestampParameters.SetAutoSelectRepository(v.(bool)) } - if v, has_v := d.GetOkExists("vdb_restart"); has_v { provisionVDBByTimestampParameters.SetVdbRestart(v.(bool)) } - if v, has_v := d.GetOk("template_id"); has_v { provisionVDBByTimestampParameters.SetTemplateId(v.(string)) } - + if v, has_v := d.GetOk("auxiliary_template_id"); has_v { + provisionVDBByTimestampParameters.SetAuxiliaryTemplateId(v.(string)) + } if v, has_v := d.GetOk("file_mapping_rules"); has_v { provisionVDBByTimestampParameters.SetFileMappingRules(v.(string)) } - if v, has_v := d.GetOk("oracle_instance_name"); has_v { provisionVDBByTimestampParameters.SetOracleInstanceName(v.(string)) } - if v, has_v := d.GetOk("unique_name"); has_v { provisionVDBByTimestampParameters.SetUniqueName(v.(string)) } - + if v, has_v := d.GetOk("vcdb_name"); has_v { + provisionVDBByTimestampParameters.SetVcdbName(v.(string)) + } + if v, has_v := d.GetOk("vcdb_database_name"); has_v { + provisionVDBByTimestampParameters.SetVcdbDatabaseName(v.(string)) + } if v, has_v := d.GetOk("mount_point"); has_v { provisionVDBByTimestampParameters.SetMountPoint(v.(string)) } - if v, has_v := d.GetOkExists("open_reset_logs"); has_v { provisionVDBByTimestampParameters.SetOpenResetLogs(v.(bool)) } - if v, has_v := d.GetOk("snapshot_policy_id"); has_v { provisionVDBByTimestampParameters.SetSnapshotPolicyId(v.(string)) } - if v, has_v := d.GetOk("retention_policy_id"); has_v { provisionVDBByTimestampParameters.SetRetentionPolicyId(v.(string)) } - if v, has_v := d.GetOk("recovery_model"); has_v { provisionVDBByTimestampParameters.SetRecoveryModel(v.(string)) } - if v, has_v := d.GetOk("pre_script"); has_v { provisionVDBByTimestampParameters.SetPreScript(v.(string)) } - if v, has_v := d.GetOk("post_script"); has_v { provisionVDBByTimestampParameters.SetPostScript(v.(string)) } - if v, has_v := d.GetOkExists("cdc_on_provision"); has_v { provisionVDBByTimestampParameters.SetCdcOnProvision(v.(bool)) } - if v, has_v := d.GetOk("online_log_size"); has_v { provisionVDBByTimestampParameters.SetOnlineLogSize(int32(v.(int))) } - if v, has_v := d.GetOk("online_log_groups"); has_v { provisionVDBByTimestampParameters.SetOnlineLogGroups(int32(v.(int))) } - if v, has_v := d.GetOkExists("archive_log"); has_v { provisionVDBByTimestampParameters.SetArchiveLog(v.(bool)) } - if v, has_v := d.GetOkExists("new_dbid"); has_v { provisionVDBByTimestampParameters.SetNewDbid(v.(bool)) } - if v, has_v := d.GetOk("listener_ids"); has_v { provisionVDBByTimestampParameters.SetListenerIds(toStringArray(v)) } - if v, has_v := d.GetOk("custom_env_vars"); has_v { custom_env_vars := make(map[string]string) @@ -783,11 +913,9 @@ func helper_provision_by_timestamp(ctx context.Context, d *schema.ResourceData, } provisionVDBByTimestampParameters.SetCustomEnvVars(custom_env_vars) } - if v, has_v := d.GetOk("custom_env_files"); has_v { provisionVDBByTimestampParameters.SetCustomEnvFiles(toStringArray(v)) } - if v, has_v := d.GetOk("timestamp"); has_v { tt, err := time.Parse(time.RFC3339, v.(string)) if err != nil { @@ -796,54 +924,45 @@ func helper_provision_by_timestamp(ctx context.Context, d *schema.ResourceData, } provisionVDBByTimestampParameters.SetTimestamp(tt) } - if v, has_v := d.GetOk("timestamp_in_database_timezone"); has_v { provisionVDBByTimestampParameters.SetTimestampInDatabaseTimezone(v.(string)) } - if v, has_v := d.GetOk("pre_refresh"); has_v { provisionVDBByTimestampParameters.SetPreRefresh(toHookArray(v)) } - if v, has_v := d.GetOk("post_refresh"); has_v { provisionVDBByTimestampParameters.SetPostRefresh(toHookArray(v)) } - if v, has_v := d.GetOk("pre_rollback"); has_v { provisionVDBByTimestampParameters.SetPreRollback(toHookArray(v)) } - if v, has_v := d.GetOk("post_rollback"); has_v { provisionVDBByTimestampParameters.SetPostRollback(toHookArray(v)) } - if v, has_v := d.GetOk("configure_clone"); has_v { provisionVDBByTimestampParameters.SetConfigureClone(toHookArray(v)) } - if v, has_v := d.GetOk("pre_snapshot"); has_v { provisionVDBByTimestampParameters.SetPreSnapshot(toHookArray(v)) } - if v, has_v := d.GetOk("post_snapshot"); has_v { provisionVDBByTimestampParameters.SetPostSnapshot(toHookArray(v)) } - if v, has_v := d.GetOk("pre_start"); has_v { provisionVDBByTimestampParameters.SetPreStart(toHookArray(v)) } - if v, has_v := d.GetOk("post_start"); has_v { provisionVDBByTimestampParameters.SetPostStart(toHookArray(v)) } - if v, has_v := d.GetOk("pre_stop"); has_v { provisionVDBByTimestampParameters.SetPreStop(toHookArray(v)) } - if v, has_v := d.GetOk("post_stop"); has_v { provisionVDBByTimestampParameters.SetPostStop(toHookArray(v)) } + if v, has_v := d.GetOk("tags"); has_v { + provisionVDBByTimestampParameters.SetTags(toTagArray(v)) + } req := client.VDBsApi.ProvisionVdbByTimestamp(ctx) @@ -852,16 +971,198 @@ func helper_provision_by_timestamp(ctx context.Context, d *schema.ResourceData, return diags } - d.SetId(*apiRes.Vdb.Id) + d.SetId(*apiRes.VdbId) - job_res, job_err := PollJobStatus(apiRes.GetJobId(), ctx, client) + job_res, job_err := PollJobStatus(*apiRes.Job.Id, ctx, client) if job_err != "" { ErrorLog.Printf("Job Polling failed but continuing with provisioning. Error: %v", job_err) } InfoLog.Printf("Job result is %s", job_res) if job_res == "FAILED" { - ErrorLog.Printf("Job %s Failed!", apiRes.GetJobId()) - return diag.Errorf("[NOT OK] Job %s Failed with error %s", apiRes.GetJobId(), job_err) + ErrorLog.Printf("Job %s Failed!", *apiRes.Job.Id) + return diag.Errorf("[NOT OK] Job %s Failed with error %s", *apiRes.Job.Id, job_err) + } + + readDiags := resourceVdbRead(ctx, d, meta) + + if readDiags.HasError() { + return readDiags + } + + return diags +} + +func helper_provision_by_bookmark(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + var diags diag.Diagnostics + client := meta.(*apiClient).client + + provisionVDBFromBookmarkParameters := dctapi.NewProvisionVDBFromBookmarkParameters(d.Get("bookmark_id").(string)) + + // Setters for provisionVDBFromBookmarkParameters + if v, has_v := d.GetOk("target_group_id"); has_v { + provisionVDBFromBookmarkParameters.SetTargetGroupId(v.(string)) + } + if v, has_v := d.GetOk("name"); has_v { + provisionVDBFromBookmarkParameters.SetName(v.(string)) + } + if v, has_v := d.GetOk("database_name"); has_v { + provisionVDBFromBookmarkParameters.SetDatabaseName(v.(string)) + } + if v, has_v := d.GetOk("cdb_id"); has_v { + provisionVDBFromBookmarkParameters.SetCdbId(v.(string)) + } + if v, has_v := d.GetOk("cluster_node_ids"); has_v { + provisionVDBFromBookmarkParameters.SetClusterNodeIds(toStringArray(v)) + } + if v, has_v := d.GetOkExists("truncate_log_on_checkpoint"); has_v { + provisionVDBFromBookmarkParameters.SetTruncateLogOnCheckpoint(v.(bool)) + } + if v, has_v := d.GetOk("os_username"); has_v { + provisionVDBFromBookmarkParameters.SetOsUsername(v.(string)) + } + if v, has_v := d.GetOk("os_password"); has_v { + provisionVDBFromBookmarkParameters.SetOsPassword(v.(string)) + } + if v, has_v := d.GetOk("environment_id"); has_v { + provisionVDBFromBookmarkParameters.SetEnvironmentId(v.(string)) + } + if v, has_v := d.GetOk("environment_user_id"); has_v { + provisionVDBFromBookmarkParameters.SetEnvironmentUserId(v.(string)) + } + if v, has_v := d.GetOk("repository_id"); has_v { + provisionVDBFromBookmarkParameters.SetRepositoryId(v.(string)) + } + if v, has_v := d.GetOkExists("auto_select_repository"); has_v { + provisionVDBFromBookmarkParameters.SetAutoSelectRepository(v.(bool)) + } + if v, has_v := d.GetOkExists("vdb_restart"); has_v { + provisionVDBFromBookmarkParameters.SetVdbRestart(v.(bool)) + } + if v, has_v := d.GetOk("template_id"); has_v { + provisionVDBFromBookmarkParameters.SetTemplateId(v.(string)) + } + if v, has_v := d.GetOk("auxiliary_template_id"); has_v { + provisionVDBFromBookmarkParameters.SetAuxiliaryTemplateId(v.(string)) + } + if v, has_v := d.GetOk("file_mapping_rules"); has_v { + provisionVDBFromBookmarkParameters.SetFileMappingRules(v.(string)) + } + if v, has_v := d.GetOk("oracle_instance_name"); has_v { + provisionVDBFromBookmarkParameters.SetOracleInstanceName(v.(string)) + } + if v, has_v := d.GetOk("unique_name"); has_v { + provisionVDBFromBookmarkParameters.SetUniqueName(v.(string)) + } + if v, has_v := d.GetOk("vcdb_name"); has_v { + provisionVDBFromBookmarkParameters.SetVcdbName(v.(string)) + } + if v, has_v := d.GetOk("vcdb_database_name"); has_v { + provisionVDBFromBookmarkParameters.SetVcdbDatabaseName(v.(string)) + } + if v, has_v := d.GetOk("mount_point"); has_v { + provisionVDBFromBookmarkParameters.SetMountPoint(v.(string)) + } + if v, has_v := d.GetOkExists("open_reset_logs"); has_v { + provisionVDBFromBookmarkParameters.SetOpenResetLogs(v.(bool)) + } + if v, has_v := d.GetOk("snapshot_policy_id"); has_v { + provisionVDBFromBookmarkParameters.SetSnapshotPolicyId(v.(string)) + } + if v, has_v := d.GetOk("retention_policy_id"); has_v { + provisionVDBFromBookmarkParameters.SetRetentionPolicyId(v.(string)) + } + if v, has_v := d.GetOk("recovery_model"); has_v { + provisionVDBFromBookmarkParameters.SetRecoveryModel(v.(string)) + } + if v, has_v := d.GetOk("pre_script"); has_v { + provisionVDBFromBookmarkParameters.SetPreScript(v.(string)) + } + if v, has_v := d.GetOk("post_script"); has_v { + provisionVDBFromBookmarkParameters.SetPostScript(v.(string)) + } + if v, has_v := d.GetOkExists("cdc_on_provision"); has_v { + provisionVDBFromBookmarkParameters.SetCdcOnProvision(v.(bool)) + } + if v, has_v := d.GetOk("online_log_size"); has_v { + provisionVDBFromBookmarkParameters.SetOnlineLogSize(int32(v.(int))) + } + if v, has_v := d.GetOk("online_log_groups"); has_v { + provisionVDBFromBookmarkParameters.SetOnlineLogGroups(int32(v.(int))) + } + if v, has_v := d.GetOkExists("archive_log"); has_v { + provisionVDBFromBookmarkParameters.SetArchiveLog(v.(bool)) + } + if v, has_v := d.GetOkExists("new_dbid"); has_v { + provisionVDBFromBookmarkParameters.SetNewDbid(v.(bool)) + } + if v, has_v := d.GetOk("listener_ids"); has_v { + provisionVDBFromBookmarkParameters.SetListenerIds(toStringArray(v)) + } + if v, has_v := d.GetOk("custom_env_vars"); has_v { + custom_env_vars := make(map[string]string) + + for k, v := range v.(map[string]interface{}) { + custom_env_vars[k] = v.(string) + } + provisionVDBFromBookmarkParameters.SetCustomEnvVars(custom_env_vars) + } + if v, has_v := d.GetOk("custom_env_files"); has_v { + provisionVDBFromBookmarkParameters.SetCustomEnvFiles(toStringArray(v)) + } + if v, has_v := d.GetOk("pre_refresh"); has_v { + provisionVDBFromBookmarkParameters.SetPreRefresh(toHookArray(v)) + } + if v, has_v := d.GetOk("post_refresh"); has_v { + provisionVDBFromBookmarkParameters.SetPostRefresh(toHookArray(v)) + } + if v, has_v := d.GetOk("pre_rollback"); has_v { + provisionVDBFromBookmarkParameters.SetPreRollback(toHookArray(v)) + } + if v, has_v := d.GetOk("post_rollback"); has_v { + provisionVDBFromBookmarkParameters.SetPostRollback(toHookArray(v)) + } + if v, has_v := d.GetOk("configure_clone"); has_v { + provisionVDBFromBookmarkParameters.SetConfigureClone(toHookArray(v)) + } + if v, has_v := d.GetOk("pre_snapshot"); has_v { + provisionVDBFromBookmarkParameters.SetPreSnapshot(toHookArray(v)) + } + if v, has_v := d.GetOk("post_snapshot"); has_v { + provisionVDBFromBookmarkParameters.SetPostSnapshot(toHookArray(v)) + } + if v, has_v := d.GetOk("pre_start"); has_v { + provisionVDBFromBookmarkParameters.SetPreStart(toHookArray(v)) + } + if v, has_v := d.GetOk("post_start"); has_v { + provisionVDBFromBookmarkParameters.SetPostStart(toHookArray(v)) + } + if v, has_v := d.GetOk("pre_stop"); has_v { + provisionVDBFromBookmarkParameters.SetPreStop(toHookArray(v)) + } + if v, has_v := d.GetOk("post_stop"); has_v { + provisionVDBFromBookmarkParameters.SetPostStop(toHookArray(v)) + } + if v, has_v := d.GetOk("tags"); has_v { + provisionVDBFromBookmarkParameters.SetPostStop(toHookArray(v)) + } + + req := client.VDBsApi.ProvisionVdbFromBookmark(ctx) + + apiRes, httpRes, err := req.ProvisionVDBFromBookmarkParameters(*provisionVDBFromBookmarkParameters).Execute() + if diags := apiErrorResponseHelper(apiRes, httpRes, err); diags != nil { + return diags + } + + d.SetId(*apiRes.VdbId) + + job_res, job_err := PollJobStatus(*apiRes.Job.Id, ctx, client) + if job_err != "" { + ErrorLog.Printf("Job Polling failed but continuing with provisioning. Error: %s", job_err) + } + InfoLog.Printf("Job result is %s", job_res) + if job_res == Failed || job_res == Canceled || job_res == Abandoned { + ErrorLog.Printf("Job %s %s!", job_res, *apiRes.Job.Id) + return diag.Errorf("[NOT OK] Job %s %s with error %s", *apiRes.Job.Id, job_res, job_err) } readDiags := resourceVdbRead(ctx, d, meta) @@ -874,23 +1175,35 @@ func helper_provision_by_timestamp(ctx context.Context, d *schema.ResourceData, } func resourceVdbCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + if _, has_v := d.GetOk("db_username"); has_v { + return diag.Errorf("db_username can not be set when creating a VDB.") + } + if _, has_v := d.GetOk("db_password"); has_v { + return diag.Errorf("db_password can not be set when creating a VDB.") + } provision_type := d.Get("provision_type").(string) if provision_type == "timestamp" { if _, has_v := d.GetOk("snapshot_id"); has_v { - return diag.Errorf("snapshot_id is not supported for provision_type is 'timestamp'") + return diag.Errorf("snapshot_id is not supported for provision_type = 'timestamp'") } else { return helper_provision_by_timestamp(ctx, d, meta) } } else if provision_type == "snapshot" { if _, has_v := d.GetOk("timestamp"); has_v { - return diag.Errorf("timestamp is not supported for provision_type is 'snapshot'") + return diag.Errorf("timestamp is not supported for provision_type = 'snapshot'") } else { return helper_provision_by_snapshot(ctx, d, meta) } + } else if provision_type == "bookmark" { + if _, has_v := d.GetOk("bookmark_id"); has_v { + return helper_provision_by_bookmark(ctx, d, meta) + } else { + return diag.Errorf("bookmark_id is required for provision_type = 'bookmark'") + } } else { - return diag.Errorf("provision_type must be 'timestamp' or 'snapshot'") + return diag.Errorf("provision_type must be 'timestamp', 'snapshot' or 'bookmark'") } } @@ -905,9 +1218,19 @@ func resourceVdbRead(ctx context.Context, d *schema.ResourceData, meta interface }) if diags != nil { - ErrorLog.Printf("Error reading the VDB, removing from state.") - d.SetId("") - return diag.Errorf("[NOT OK] Error in polling vdb") + _, diags := PollForObjectDeletion(func() (interface{}, *http.Response, error) { + return client.VDBsApi.GetVdbById(ctx, vdbId).Execute() + }) + // This would imply error in poll for deletion so we just log and exit. + if diags != nil { + ErrorLog.Printf("Error in polling of VDB for deletion.") + } else { + // diags will be nill in case of successful poll for deletion logic aka 404 + ErrorLog.Printf("Error reading the VDB %s, removing from state.", vdbId) + d.SetId("") + } + + return nil } result, ok := res.(*dctapi.VDB) @@ -916,7 +1239,7 @@ func resourceVdbRead(ctx context.Context, d *schema.ResourceData, meta interface } d.Set("database_type", result.GetDatabaseType()) - d.Set("vdb_name", result.GetName()) + d.Set("name", result.GetName()) d.Set("database_version", result.GetDatabaseVersion()) d.Set("engine_id", result.GetEngineId()) d.Set("environment_id", result.GetEnvironmentId()) @@ -948,7 +1271,6 @@ func resourceVdbUpdate(ctx context.Context, d *schema.ResourceData, meta interfa "auto_select_repository", "source_data_id", "id", - "job_id", "database_type", "database_version", "status", @@ -982,6 +1304,8 @@ func resourceVdbUpdate(ctx context.Context, d *schema.ResourceData, meta interfa "recovery_model", "online_log_groups", "online_log_size", + "os_username", + "os_password", "archive_log", "custom_env_vars", "custom_env_files", @@ -999,16 +1323,16 @@ func resourceVdbUpdate(ctx context.Context, d *schema.ResourceData, meta interfa } if d.HasChange("template_id") { - updateVDBParam.SetConfigTemplate(d.Get("template_id").(string)) + updateVDBParam.SetTemplateId(d.Get("template_id").(string)) } - if d.HasChange("vdb_name") { - updateVDBParam.SetName(d.Get("vdb_name").(string)) + if d.HasChange("name") { + updateVDBParam.SetName(d.Get("name").(string)) } - if d.HasChange("username") { - updateVDBParam.SetUser(d.Get("username").(string)) + if d.HasChange("db_username") { + updateVDBParam.SetDbUsername(d.Get("db_username").(string)) } - if d.HasChange("password") { - updateVDBParam.SetPassword(d.Get("password").(string)) + if d.HasChange("db_password") { + updateVDBParam.SetDbPassword(d.Get("db_password").(string)) } if d.HasChange("new_dbid") { updateVDBParam.SetNewDbid(d.Get("new_dbid").(bool)) @@ -1017,10 +1341,10 @@ func resourceVdbUpdate(ctx context.Context, d *schema.ResourceData, meta interfa updateVDBParam.SetAutoRestart(d.Get("vdb_restart").(bool)) } if d.HasChange("listener_ids") { - updateVDBParam.SetListeners(toStringArray(d.Get("listener_ids"))) + updateVDBParam.SetListenerIds(toStringArray(d.Get("listener_ids"))) } if d.HasChange("environment_user_id") { - updateVDBParam.SetEnvironmentUser(d.Get("environment_user_id").(string)) + updateVDBParam.SetEnvironmentUserId(d.Get("environment_user_id").(string)) } if d.HasChange("pre_script") { updateVDBParam.SetPreScript(d.Get("pre_script").(string)) @@ -1032,7 +1356,7 @@ func resourceVdbUpdate(ctx context.Context, d *schema.ResourceData, meta interfa updateVDBParam.SetCdcOnProvision(d.Get("cdc_on_provision").(bool)) } - httpRes, err := client.VDBsApi.UpdateVdbById(ctx, d.Get("id").(string)).UpdateVDBParameters(*updateVDBParam).Execute() + res, httpRes, err := client.VDBsApi.UpdateVdbById(ctx, d.Get("id").(string)).UpdateVDBParameters(*updateVDBParam).Execute() if diags := apiErrorResponseHelper(nil, httpRes, err); diags != nil { // revert and set the old value to the changed keys @@ -1043,6 +1367,15 @@ func resourceVdbUpdate(ctx context.Context, d *schema.ResourceData, meta interfa return diags } + job_status, job_err := PollJobStatus(*res.Job.Id, ctx, client) + if job_err != "" { + WarnLog.Printf("VDB Update Job Polling failed but continuing with update. Error :%v", job_err) + } + InfoLog.Printf("Job result is %s", job_status) + if isJobTerminalFailure(job_status) { + return diag.Errorf("[NOT OK] VDB-Update %s. JobId: %s / Error: %s", job_status, *res.Job.Id, job_err) + } + return diags } @@ -1060,13 +1393,13 @@ func resourceVdbDelete(ctx context.Context, d *schema.ResourceData, meta interfa return diags } - job_status, job_err := PollJobStatus(*res.JobId, ctx, client) + job_status, job_err := PollJobStatus(*res.Job.Id, ctx, client) if job_err != "" { WarnLog.Printf("Job Polling failed but continuing with deletion. Error :%v", job_err) } InfoLog.Printf("Job result is %s", job_status) - if job_status == Failed { - return diag.Errorf("[NOT OK] VDB-Delete failed. JobId: %s / Error: %s", *res.JobId, job_err) + if isJobTerminalFailure(job_status) { + return diag.Errorf("[NOT OK] VDB-Delete %s. JobId: %s / Error: %s", job_status, *res.Job.Id, job_err) } _, diags := PollForObjectDeletion(func() (interface{}, *http.Response, error) { diff --git a/internal/provider/resource_vdb_test.go b/internal/provider/resource_vdb_test.go index fb79cc4..4100eb6 100644 --- a/internal/provider/resource_vdb_test.go +++ b/internal/provider/resource_vdb_test.go @@ -2,11 +2,15 @@ package provider import ( "context" + "crypto/tls" "fmt" + "net/http" "os" "regexp" "testing" + dctapi "github.com/delphix/dct-sdk-go" + "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) @@ -28,9 +32,8 @@ func TestAccVdb_provision_positive(t *testing.T) { Config: testAccUpdatePositive("vdbu", true), Check: resource.ComposeTestCheckFunc( testAccCheckDctVdbResourceExists("delphix_vdb.new"), - resource.TestCheckResourceAttr("delphix_vdb.new", "vdb_name", "vdbu"), + resource.TestCheckResourceAttr("delphix_vdb.new", "name", "vdbu"), resource.TestCheckResourceAttr("delphix_vdb.new", "vdb_restart", "true")), - ExpectNonEmptyPlan: true, }, { // negative update test case @@ -41,6 +44,24 @@ func TestAccVdb_provision_positive(t *testing.T) { }) } +var bookmark_id string +var vdb_id string + +func TestAccVdb_bookmark_provision(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccVdbPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckVdbDestroyBookmark, + Steps: []resource.TestStep{ + { + Config: testAccCheckDctVDBBookmarkConfigBasic(), + Check: resource.ComposeTestCheckFunc( + testAccCheckDctVdbBookmarkResourceExists()), + }, + }, + }) +} + func testAccVdbPreCheck(t *testing.T) { testAccPreCheck(t) if err := os.Getenv("DATASOURCE_ID"); err == "" { @@ -58,6 +79,75 @@ func testAccCheckDctVDBConfigBasic() string { `, datasource_id) } +func testAccCheckDctVDBBookmarkConfigBasic() string { + // init client + cfg := dctapi.NewConfiguration() + cfg.Host = os.Getenv("DCT_HOST") + cfg.Scheme = "https" + cfg.HTTPClient = &http.Client{Transport: &http.Transport{ + TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, + }} + cfg.AddDefaultHeader("Authorization", "apk "+os.Getenv("DCT_KEY")) + client := dctapi.NewAPIClient(cfg) + + // create vdb + provisionVDBBySnapshotParameters := dctapi.NewProvisionVDBBySnapshotParameters() + provisionVDBBySnapshotParameters.SetAutoSelectRepository(true) + provisionVDBBySnapshotParameters.SetSourceDataId(os.Getenv("DATASOURCE_ID")) + + vdb_req := client.VDBsApi.ProvisionVdbBySnapshot(context.Background()) + + vdb_res, vdb_http_res, vdb_err := vdb_req.ProvisionVDBBySnapshotParameters(*provisionVDBBySnapshotParameters).Execute() + if diags := apiErrorResponseHelper(vdb_res, vdb_http_res, vdb_err); diags != nil { + println("An error occured during vdb creation: " + vdb_err.Error()) + return "" // return empty config to indicate config error + } + vdb_id = *vdb_res.VdbId + + // poll for vdb + vdb_job_res, vdb_job_err := PollJobStatus(*vdb_res.Job.Id, context.Background(), client) + + if vdb_job_res == Failed || vdb_job_res == Canceled || vdb_job_res == Abandoned { + println("An error occured during vdb job polling " + vdb_job_err) + return "" + } + + //create bookmark + bookmark := dctapi.NewBookmarkWithDefaults() + bookmark.SetVdbIds([]string{vdb_id}) + bookmark.SetName(acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) + + bookmark_req := client.BookmarksApi.CreateBookmark(context.Background()).Bookmark(*bookmark) + bk_res, bk_http_res, bk_err := bookmark_req.Execute() + + if diags := apiErrorResponseHelper(bk_res, bk_http_res, bk_err); diags != nil { + println("An error occured during bookmark creation: " + bk_err.Error()) + return "" + } + bookmark_id = *bk_res.Bookmark.Id + + // poll for bookmark + bk_job_res, bk_job_err := PollJobStatus(*bk_res.Job.Id, context.Background(), client) + + if bk_job_res == Failed || bk_job_res == Canceled || bk_job_res == Abandoned { + println("An error occured during bookmark job polling: " + bk_job_err) + return "" // return empty config to indicate config error + } + + resource := fmt.Sprintf(` + resource "delphix_vdb" "vdb_bookmark" { + provision_type = "bookmark" + auto_select_repository = true + bookmark_id = "%s" + } + `, bookmark_id) + + print(resource) + + return resource + +} + func testAccCheckDctVdbResourceExists(n string) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] @@ -88,6 +178,43 @@ func testAccCheckDctVdbResourceExists(n string) resource.TestCheckFunc { } } +func testAccCheckDctVdbBookmarkResourceExists() resource.TestCheckFunc { + return func(s *terraform.State) error { + rs, ok := s.RootModule().Resources["delphix_vdb.vdb_bookmark"] + + if !ok { + return fmt.Errorf("Not found: delphix_vdb.vdb_bookmark") + } + + vdbId := rs.Primary.ID + if vdbId == "" { + return fmt.Errorf("No VdbID set") + } + + client := testAccProvider.Meta().(*apiClient).client + + get_vdb_response, _, get_vdb_error := client.VDBsApi.GetVdbById(context.Background(), vdbId).Execute() + + if get_vdb_error != nil { + return get_vdb_error + } + + get_bookmark_response, _, get_bookmark_error := client.BookmarksApi.GetBookmarkById(context.Background(), bookmark_id).Execute() + + if get_bookmark_error != nil { + return get_bookmark_error + } + + sourceId := get_bookmark_response.GetVdbIds()[0] + parentId := get_vdb_response.GetParentId() + if parentId != sourceId { + return fmt.Errorf("Single-VDB Bookmark's parentId does not match newly created VDB's sourceId") + } + + return nil + } +} + func testAccCheckVdbDestroy(s *terraform.State) error { client := testAccProvider.Meta().(*apiClient).client @@ -111,6 +238,18 @@ func testAccCheckVdbDestroy(s *terraform.State) error { return nil } + +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() + + return testAccCheckVdbDestroy(s) +} + func testAccUpdateNegative(value bool) string { datasource_id := os.Getenv("DATASOURCE_ID") return fmt.Sprintf(` @@ -127,7 +266,7 @@ func testAccUpdatePositive(name string, vdb_restart bool) string { resource "delphix_vdb" "new" { auto_select_repository = true source_data_id = "%s" - vdb_name = "%s" + name = "%s" vdb_restart = "%t" } `, datasource_id, name, vdb_restart) diff --git a/internal/provider/utility.go b/internal/provider/utility.go index 1205cde..046c957 100644 --- a/internal/provider/utility.go +++ b/internal/provider/utility.go @@ -28,10 +28,13 @@ func PollJobStatus(job_id string, ctx context.Context, client *dctapi.APIClient) } var i = 0 - for res.GetStatus() == Running { + for res.GetStatus() == Pending || res.GetStatus() == Started { time.Sleep(time.Duration(JOB_STATUS_SLEEP_TIME) * time.Second) res, httpRes, err = client.JobsApi.GetJobById(ctx, job_id).Execute() if err != nil { + if httpRes == nil { + return "", "Received nil response for Job ID " + job_id + } resBody, err := ResponseBodyToString(httpRes.Body) if err != nil { return "", err.Error() @@ -127,3 +130,7 @@ func apiErrorResponseHelper(res interface{}, httpRes *http.Response, err error) } return nil } + +func isJobTerminalFailure(job_status string) bool { + return job_status == Failed || job_status == Canceled || job_status == Abandoned +}