Skip to content

vast-data/terraform-provider-vastdata

Repository files navigation

Terraform Provider Vastdata

CI Release License: Apache2 Go Report Card Coverage Status Go Reference Terraform Registry Latest Release

The VastData Terraform provider is a provider to manage VastData clusters resources.

Table of Contents

Configuring Provider to be downloaded from Terraform Registry

In order to configure the provider to be used directly from Terraform registry, use the following provider defenition.

terraform {
  required_providers {
    vastdata = {
      source = "vast-data/vastdata"
    }
  }
}

Now when running terraform init it will download the VastData provider from the Terraform Registry

Building The Provider Directly From Github

In order to build the provider you can simpy use go install

$ go install github.com/vast-data/terraform-provider-vastdata

To install a specfic tag/branch version use the following syntax

$ go install github.com/vast-data/terraform-provider-vastdata@<branch/tag>

Check you go GOBIN path for the compiled file named terraform-provider-vastdata

Building The Provider Locally

In order to build the provider locally you will need to first clone the repo.

Cloning The Source Code

$ git clone https://github.com/vast-data/terraform-provider-vastdata.git
$ cd terraform-provider-vastdata

If you wish to checkout a specific tag check out the tag.

$ git checkout <tag name>

Building The Code Locally

In order to build the code locally you need to have GNU Make installed

To build the code ru the following command

make build

This will build the provider binary with the name terraform-provider-vastdata directly into the build directory.

Building Into A Differant directory

In order to build to a differant directory other than build , specify BUILD_DEST=<build directory>

	make build BUILD_DEST=some/other/directory

Using Local Copy Using dev_overrides

dev_overrides is a terraform configuration that will allow to overrides any other method of obtaining the terrafrom plugin binary and forces terrafrom to obtain the provider binary from a specific path locally.

Edit ~/.terraformrc file

This file is being scanned every time you run terrafrom if you dont want to create/edit it you can specify the environment vasriable TF_CLI_CONFIG_FILE=path/to/configuration/file

add the following configurations to the configuration file.

provider_installation {
  dev_overrides {
    "vastdata/vastdata" = "/some/directory/where/the/binary/is/stored"
  }
  direct {}
} 

When creating a terrafrom configration specify the following at the file

terraform {
  required_providers {
    vastdata = {
      source  = "vastdata/vastdata"
    }
  }
}

Now you can define providers.

provider vastdata {
username = "<username>"
port = <port>
password = "<password>"
host = "<address>"
skip_ssl_verify = true
version_validation_mode = "warn"
}

Importing Existing Resources

The VastData provider supports importing existing resources using various ID formats, including composite keys for resources that require multiple identifiers.

Import Formats

1. Simple ID Import

For resources that use a single identifier:

terraform import vastdata_example.my_resource "12345"

2. Key-Value Pairs Import (Recommended)

For resources requiring multiple fields, use key=value format with comma or semicolon separators:

# Using comma separator
terraform import vastdata_example.my_resource "gid=1001,tenant_id=22,context=ad"

# Using semicolon separator  
terraform import vastdata_example.my_resource "gid=1001;tenant_id=22;context=ad"

This is the recommended import format as it is explicit, order-independent, and allows you to specify only the required fields without needing to know a specific field order.

Import Field Types

The provider automatically handles type conversion for imported values:

  • String fields: Values are imported as-is
  • Integer fields: Numeric strings are converted to integers
  • Boolean fields: Accepts true, false, 1, or 0

Legacy Import Format (Pipe-separated)

This section is for backward compatibility with provider version 1.7 only.

A limited set of resources still support the legacy pipe-separated import format for backward compatibility. This format requires all values to be provided in a specific order and is not recommended for new configurations.

Supported Resources with Legacy Format

Only the following resources support pipe-separated imports:

  • vastdata_nonlocal_user: username|context|tenant_id
  • vastdata_nonlocal_group: groupname|context|tenant_id
  • vastdata_view_policy: name|tenant_name
  • vastdata_view: path|tenant_name

Legacy Format Usage

# Example: Import a nonlocal user (not recommended - use key=value instead)
terraform import vastdata_nonlocal_user.example "admin|ldap|1"

# Example: Import a view (not recommended - use key=value instead)  
terraform import vastdata_view.example "/data/project|tenant1"

Examples

Import a User with Multiple Identifiers

terraform import vastdata_user.admin "username=admin,tenant_id=1,domain=local"

Import a Quota with Composite Key

terraform import vastdata_quota.project_quota "name=project1,path=/data/project1,tenant_id=5"

Import a Network Interface

terraform import vastdata_network_interface.eth0 "name=eth0,node_id=1"

Troubleshooting Import

Error: "field 'x' is not present in the resource schema"

  • Ensure the field name matches exactly what's defined in the resource schema
  • Check the resource documentation for correct field names

Error: "expected X values for fields [...], got Y"

  • When using pipe-separated format, ensure the number of values matches the expected import fields
  • Use key=value format instead if you need to specify only some fields

Error: "invalid int64 for field 'x'"

  • Ensure numeric fields contain valid integer values
  • Check for extra spaces or non-numeric characters

Finding Import Fields

To determine which fields are required for importing a specific resource:

  1. Check the resource documentation
  2. Look at the resource's required attributes
  3. Use terraform plan after creating a minimal resource configuration to see required fields
  4. Refer to the VastData API documentation for the underlying resource identifiers

Submitting Bugs/Feature Requests

While it is common to submit Bugs/Feature Requests using github issues, we would rather if you open a Bug/Feature Request to Vast Data support at [email protected]

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •