### Install Vastdata Provider using Go Install Source: https://github.com/vast-data/terraform-provider-vastdata/blob/v2.1/README.md These bash commands demonstrate how to install the Vastdata Terraform provider directly from GitHub using `go install`. It shows the basic installation command and how to specify a particular branch or tag for installation. ```bash $ go install github.com/vast-data/terraform-provider-vastdata ``` ```bash $ go install github.com/vast-data/terraform-provider-vastdata@ ``` -------------------------------- ### Example Usage of vastdata_bgp_config Data Source Source: https://github.com/vast-data/terraform-provider-vastdata/blob/v2.1/docs/data-sources/bgp_config.md This Terraform code demonstrates how to use the vastdata_bgp_config data source to retrieve BGP configurations. It shows examples of fetching configurations by their unique ID, GUID, and name. ```terraform data "vastdata_bgp_config" "vastdb_bgp_config_by_id" { id = 1 } data "vastdata_bgp_config" "vastdb_bgp_config_by_guid" { guid = "00000000-0000-0000-0000-000000000001" } data "vastdata_bgp_config" "vastdb_bgp_config_by_name" { name = "bgp-config-1" } ``` -------------------------------- ### Terraform Backend Setup and Initialization Source: https://github.com/vast-data/terraform-provider-vastdata/blob/v2.1/migration/tests/vast-terraform/README.md Retrieves the Vault connection string using a setup script and initializes the Terraform backend with the generated configuration file. ```bash ./scripts/setup_backend.sh terraform init -backend-config=backend.conf ``` -------------------------------- ### VastData Terraform Provider 2.0 Configuration Example Source: https://github.com/vast-data/terraform-provider-vastdata/blob/v2.1/migration/README.md Example of a Terraform configuration after migration to VastData provider 2.0, demonstrating updated resource types, attribute names, and schema structures. ```hcl terraform { required_providers { vastdata = { source = "vast-data/vastdata" version = "2.0.0" } } } resource "vastdata_administrator_manager" "admin" { username = "admin1" permissions = ["create_support", "create_settings"] capacity_limits = { soft_limit = 1000 hard_limit = 2000 } } ``` -------------------------------- ### Complete vastdata_global_local_snapshot Example Source: https://github.com/vast-data/terraform-provider-vastdata/blob/v2.1/docs/resources/global_local_snapshot.md A comprehensive Terraform example demonstrating the creation of a global-local snapshot. It includes setting up necessary data sources for views and tenants, creating a view and a snapshot, and finally configuring the global-local snapshot resource with dynamic references. ```terraform data "vastdata_view_policy" "vastdb_policy" { name = "default" } data "vastdata_tenant" "vastdb_tenant" { name = "default" } resource "vastdata_view" "vastdb_view" { path = "/vastdb_view/snapclone" policy_id = data.vastdata_view_policy.vastdb_policy.id tenant_id = data.vastdata_tenant.vastdb_tenant.id create_dir = "true" } resource "vastdata_snapshot" "vastdb_snapshot" { name = "vastdb_snapshot" path = "${vastdata_view.vastdb_view.path}/" } resource "vastdata_global_local_snapshot" "vastdb_local_snapshot" { name = "vastdb_local_snapshot" loanee_root_path = "/vastdb_local_snapshot" enabled = true loanee_snapshot_id = vastdata_snapshot.vastdb_snapshot.id loanee_tenant_id = data.vastdata_tenant.vastdb_tenant.id } ``` -------------------------------- ### Example Usage for vastdata_s3_life_cycle_rule Data Source Source: https://github.com/vast-data/terraform-provider-vastdata/blob/v2.1/docs/data-sources/s3_life_cycle_rule.md Demonstrates how to retrieve S3 lifecycle rule configurations using the vastdata_s3_life_cycle_rule data source. It shows examples of querying by rule ID and by rule GUID, which are common ways to identify specific lifecycle policies. ```terraform data "vastdata_s3_life_cycle_rule" "vastdb_s3_life_cycle_rule_by_id" { id = 1 } data "vastdata_s3_life_cycle_rule" "vastdb_s3_life_cycle_rule_by_guid" { guid = "00000000-0000-0000-0000-000000000001" } ``` -------------------------------- ### Vastdata VMS Data Source Examples (Terraform) Source: https://github.com/vast-data/terraform-provider-vastdata/blob/v2.1/docs/data-sources/vms.md These examples demonstrate how to use the vastdata_vms data source in Terraform to fetch VMS information. You can query VMS by its unique identifier (ID), globally unique identifier (GUID), or its name. The data source retrieves attributes like build version, capacity, network configuration, and state. ```Terraform data "vastdata_vms" "vastdb_vms_by_id" { id = 1 } data "vastdata_vms" "vastdb_vms_by_guid" { guid = "00000000-0000-0000-0000-000000000001" } data "vastdata_vms" "vastdb_vms_by_name" { name = "vastdb-vms" } ``` -------------------------------- ### VastData Terraform Provider 1.x Configuration Example Source: https://github.com/vast-data/terraform-provider-vastdata/blob/v2.1/migration/README.md Example of a Terraform configuration using the VastData provider in version 1.x, showcasing resource type and attribute names that will be changed in version 2.0. ```hcl terraform { required_providers { vastdata = { source = "vast-data/vastdata" version = "1.7.0" } } } resource "vastdata_administators_managers" "admin" { username = "admin1" permissions_list = ["create_support", "create_settings"] capacity_limits { soft_limit = 1000 hard_limit = 2000 } } ``` -------------------------------- ### Example Usage of vastdata_quota Data Source Source: https://github.com/vast-data/terraform-provider-vastdata/blob/v2.1/docs/data-sources/quota.md This snippet demonstrates how to use the vastdata_quota data source to retrieve quota information by ID, GUID, or name. It shows three different ways to query the data source, each using a specific argument to identify the quota. ```terraform data "vastdata_quota" "vastdb_quota_by_id" { id = 1 } data "vastdata_quota" "vastdb_quota_by_guid" { guid = "00000000-0000-0000-0000-000000000001" } data "vastdata_quota" "vastdb_quota_by_name" { name = "vastdb_quota" } ``` -------------------------------- ### Example Usage of vastdata_block_host Data Source Source: https://github.com/vast-data/terraform-provider-vastdata/blob/v2.1/docs/data-sources/block_host.md Demonstrates how to use the vastdata_block_host data source to retrieve block host information. It shows examples of looking up a block host by its ID, name, and NQN. This data source requires the Terraform Vast Data provider to be configured. ```terraform data "vastdata_block_host" "vastdb_block_host_by_id" { id = 1 } data "vastdata_block_host" "vastdb_block_host_by_name" { name = "vastdb-block-host" } data "vastdata_block_host" "vastdb_block_host_by_nqn" { nqn = "nqn.2014-08.org.nvmexpress:uuid:12345678-1234-1234-1234-123456789012" } ``` -------------------------------- ### Example Usage for vastdata_global_snapshot Source: https://github.com/vast-data/terraform-provider-vastdata/blob/v2.1/docs/data-sources/global_snapshot.md Demonstrates how to use the vastdata_global_snapshot data source to retrieve global snapshot information by ID or GUID. This data source is used to query existing global snapshots within the VastData environment. ```terraform data "vastdata_global_snapshot" "vastdb_global_snapshot_by_id" { id = 1 } data "vastdata_global_snapshot" "vastdb_global_snapshot_by_guid" { guid = "00000000-0000-0000-0000-000000000001" } ``` -------------------------------- ### Example Usage for vastdata_administrator_realm Data Source Source: https://github.com/vast-data/terraform-provider-vastdata/blob/v2.1/docs/data-sources/administrator_realm.md Demonstrates how to use the `vastdata_administrator_realm` data source to retrieve realm information using different identifiers: ID, GUID, and name. This allows for flexible querying of realm data within your Terraform configuration. ```terraform data "vastdata_administrator_realm" "vastdb_administrator_realm_by_id" { id = 1 } data "vastdata_administrator_realm" "vastdb_administrator_realm_by_guid" { guid = "00000000-0000-0000-0000-000000000001" } data "vastdata_administrator_realm" "vastdb_administrator_realm_by_name" { name = "vastdb_realm" } ``` -------------------------------- ### Import VastData Network Interface (Bash) Source: https://github.com/vast-data/terraform-provider-vastdata/blob/v2.1/README.md Example of importing a VastData network interface resource using the key-value pair format, specifying name and node ID. ```bash terraform import vastdata_network_interface.eth0 "name=eth0,node_id=1" ``` -------------------------------- ### Complete Example: Attaching S3 Policy to Group and User Source: https://github.com/vast-data/terraform-provider-vastdata/blob/v2.1/docs/resources/s3_policy_attachment.md This comprehensive example illustrates the creation of an S3 policy and its subsequent attachment to both a group and a user. It utilizes data sources to retrieve tenant information and defines user and group resources before establishing the policy attachments. ```terraform # --------------------- # Complete examples # --------------------- data "vastdata_tenant" "vastdb_tenant" { name = "default" } resource "vastdata_s3_policy" "vastdb_s3policy" { name = "vastdb_s3policy" tenant_id = data.vastdata_tenant.vastdb_tenant.id policy = < #### `local_provider` (Attributes) - `id` (Number) - ID of the local provider. - `name` (String) - Name of the local provider. #### `s3_policies` (Attributes Set) - `id` (Number) - Identity Policy ID. - `name` (String) - Identity Policy name. ``` -------------------------------- ### Example Usage: vastdata_encryption_group Data Source Source: https://github.com/vast-data/terraform-provider-vastdata/blob/v2.1/docs/data-sources/encryption_group.md This snippet demonstrates how to retrieve an encryption group using its ID or GUID. It requires the Terraform CLI and the Vast Data Terraform Provider to be configured. ```terraform data "vastdata_encryption_group" "vastdb_encryption_group_by_id" { id = 1 } data "vastdata_encryption_group" "vastdb_encryption_group_by_guid" { guid = "00000000-0000-0000-0000-000000000001" } ``` -------------------------------- ### Import VastData Resources with Key-Value Pairs Source: https://context7.com/vast-data/terraform-provider-vastdata/llms.txt Demonstrates importing existing VastData resources into Terraform state using key-value pairs for identification. This method is recommended for its flexibility and order independence. ```bash # Simple ID import terraform import vastdata_tenant.team_a "id=5" # Key-value import (recommended - order independent) terraform import vastdata_user.analyst "username=analyst,tenant_id=1" terraform import vastdata_quota.project "name=ml-quota,path=/projects/ml,tenant_id=1" terraform import vastdata_view.data "path=/team/data,tenant_name=engineering" # Multiple separators supported (comma or semicolon) terraform import vastdata_group.devs "name=developers;tenant_id=2" terraform import vastdata_s3_policy_attachment.attach "s3_policy_id=1,username=analyst" # Boolean and integer fields handled automatically terraform import vastdata_view.secure "path=/secure,tenant_id=1,create_dir=true" # Legacy pipe format (backward compatibility only - not recommended) terraform import vastdata_nonlocal_user.ldap_user "admin|ldap|1" terraform import vastdata_view_policy.policy "policy-name|tenant-name" ``` -------------------------------- ### Import VastData Quota with Composite Key (Bash) Source: https://github.com/vast-data/terraform-provider-vastdata/blob/v2.1/README.md Example of importing a VastData quota resource using the key-value pair format, specifying name, path, and tenant ID. ```bash terraform import vastdata_quota.project_quota "name=project1,path=/data/project1,tenant_id=5" ``` -------------------------------- ### Run Tests for VastData Terraform Migration Tool Source: https://github.com/vast-data/terraform-provider-vastdata/blob/v2.1/migration/README.md Command to execute tests for the VastData Terraform migration tool to ensure its functionality and stability. ```bash ./run_migration.sh --test ``` -------------------------------- ### Create a VIP pool with multiple IP ranges Source: https://github.com/vast-data/terraform-provider-vastdata/blob/v2.1/docs/resources/vip_pool.md This example shows how to create a VIP pool that includes multiple, distinct IP address ranges. Each inner list within 'ip_ranges' defines a start and end IP address for a range. ```terraform resource "vastdata_vip_pool" "vastdb_vippool" { name = "vastdb_vippool" role = "PROTOCOLS" subnet_cidr = "24" ip_ranges = [ ["11.0.0.6", "11.0.0.10"], ["11.0.0.20", "11.0.0.40"] ] } ``` -------------------------------- ### Build Vastdata Provider Locally with Make Source: https://github.com/vast-data/terraform-provider-vastdata/blob/v2.1/README.md This command uses GNU Make to build the Vastdata Terraform provider locally. The compiled binary will be placed in the `build/` directory by default. Ensure GNU Make is installed prior to running this command. ```bash make build ``` -------------------------------- ### Create a basic vastdata volume Source: https://github.com/vast-data/terraform-provider-vastdata/blob/v2.1/docs/resources/volume.md This example demonstrates how to create a simple vastdata volume with a specified name, size, and view ID. It assumes the view ID already exists. ```terraform resource "vastdata_volume" "vastdb_volume" { name = "vastdb-volume" size = 10737418240 view_id = 1 } ``` -------------------------------- ### Create VastData Nonlocal User Key with User Object and Tenant Data Source: https://github.com/vast-data/terraform-provider-vastdata/blob/v2.1/docs/resources/nonlocal_user_key.md This example shows a more complete setup for creating a nonlocal user key. It dynamically retrieves the user's UID and tenant ID from other VastData resources (`vastdata_user` and `vastdata_tenant`), allowing for more integrated resource management and disabling the key upon creation. ```terraform resource "vastdata_nonlocal_user_key" "vastdb_nonlocal_user_key" { uid = vastdata_user.vastdb_user.uid tenant_id = data.vastdata_tenant.vastdb_tenant.id enabled = false } ``` -------------------------------- ### Create a User QoS Policy with Attached Users Source: https://github.com/vast-data/terraform-provider-vastdata/blob/v2.1/docs/resources/qos_policy.md This example shows how to define a user-specific QoS policy and attach it to specific users. It includes basic static limits for writes and reads. ```terraform resource "vastdata_qos_policy" "vastdb_qos_policy" { name = "vastdb_qos_policy" policy_type = "USER" attached_users = [ { name = "runner" fqdn = "runner.vastdb.local" identifier_type = "username" identifier_value = "runner" } ] static_limits = { max_writes_bw_mbps = 1000 max_reads_iops = 2000 max_writes_iops = 3000 } } ``` -------------------------------- ### Run VastData Terraform Migration Script Source: https://github.com/vast-data/terraform-provider-vastdata/blob/v2.1/migration/README.md Shell command to execute the VastData Terraform provider migration script. It takes the source directory of old configurations and the destination directory for migrated configurations as arguments. ```bash ./run_migration.sh /path/to/old/configs /path/to/migrated/configs ``` -------------------------------- ### Retrieve Active Directory by GUID Source: https://github.com/vast-data/terraform-provider-vastdata/blob/v2.1/docs/data-sources/active_directory.md This Terraform code snippet shows how to fetch Active Directory configuration using its globally unique identifier (GUID). It utilizes the `guid` argument. ```terraform data "vastdata_active_directory" "vastdb_active_directory_by_guid" { guid = "00000000-0000-0000-0000-000000000001" } ``` -------------------------------- ### Configure VastData LDAP with Basic Settings Source: https://github.com/vast-data/terraform-provider-vastdata/blob/v2.1/docs/resources/ldap.md This example demonstrates how to configure the vastdata_ldap resource with essential parameters such as domain name, LDAP server URLs, bind credentials, and search base. It specifies whether to use auto-discovery, LDAPS, and TLS, along with the port and authentication method. ```terraform resource "vastdata_ldap" "vastdb_ldap" { domain_name = "VastEng.lab" urls = ["ldap://10.27.252.30"] binddn = "cn=admin,dc=qa,dc=vastdata,dc=com" searchbase = "dc=qa,dc=vastdata,dc=com" bindpw = "vastdata" use_auto_discovery = "false" use_ldaps = "false" port = "389" method = "simple" query_groups_mode = "COMPATIBLE" use_tls = "false" } ``` -------------------------------- ### Retrieve vastdata_vip_pool by GUID Source: https://github.com/vast-data/terraform-provider-vastdata/blob/v2.1/docs/data-sources/vip_pool.md This Terraform configuration demonstrates how to use the `vastdata_vip_pool` data source to retrieve a VIP pool by its globally unique identifier (GUID). It requires the `guid` attribute to be set. ```terraform data "vastdata_vip_pool" "vastdb_vip_pool_by_guid" { guid = "00000000-0000-0000-0000-000000000001" } ``` -------------------------------- ### Fetch VastData Protected Path by GUID Source: https://github.com/vast-data/terraform-provider-vastdata/blob/v2.1/docs/data-sources/protected_path.md This Terraform code snippet shows how to query a VastData protected path by its Global Unique Identifier (GUID). The `guid` argument must be provided for this lookup. ```Terraform data "vastdata_protected_path" "vastdb_protected_path_by_guid" { guid = "00000000-0000-0000-0000-000000000001" } ``` -------------------------------- ### Clone Vastdata Terraform Provider Repository Source: https://github.com/vast-data/terraform-provider-vastdata/blob/v2.1/README.md These bash commands show how to clone the Vastdata Terraform provider's source code from GitHub and navigate into the repository directory. It also includes a command to checkout a specific Git tag. ```bash $ git clone https://github.com/vast-data/terraform-provider-vastdata.git $ cd terraform-provider-vastdata ``` ```bash $ git checkout ``` -------------------------------- ### Retrieve vastdata tenant by GUID Source: https://github.com/vast-data/terraform-provider-vastdata/blob/v2.1/docs/data-sources/tenant.md This Terraform code snippet shows how to fetch a vastdata tenant by its Globally Unique Identifier (GUID). It uses the `vastdata_tenant` data source and provides the `guid` argument for targeted retrieval. ```terraform data "vastdata_tenant" "vastdb_tenant_by_guid" { guid = "00000000-0000-0000-0000-000000000001" } ``` -------------------------------- ### Retrieve VastData Replication Peer by GUID Source: https://github.com/vast-data/terraform-provider-vastdata/blob/v2.1/docs/data-sources/replication_peer.md This Terraform code snippet shows how to retrieve information about a VastData replication peer using its globally unique identifier (GUID). The `vastdata_replication_peer` data source is used, with the `guid` attribute specifying the target peer. ```terraform data "vastdata_replication_peer" "vastdb_replication_peer_by_guid" { guid = "00000000-0000-0000-0000-000000000001" } ``` -------------------------------- ### Create a Vastdata User Source: https://github.com/vast-data/terraform-provider-vastdata/blob/v2.1/docs/resources/user.md This snippet demonstrates how to create a basic Vastdata user with a specified name and UID. It utilizes the `vastdata_user` resource. ```terraform # Create a user with a specific UID. resource "vastdata_user" "example-user" { name = "example" uid = 9000 } ``` -------------------------------- ### Retrieve Vast Data S3 Replication Peer by GUID - Terraform Source: https://github.com/vast-data/terraform-provider-vastdata/blob/v2.1/docs/data-sources/s3_replication_peer.md This Terraform code snippet shows how to fetch Vast Data S3 replication peer details by providing its globally unique identifier (GUID). The 'guid' attribute is mandatory for this operation. ```terraform data "vastdata_s3_replication_peer" "vastdb_s3_replication_peer_by_guid" { guid = "0c6e9668-c0b6-4d65-a44b-f003e67f8b29" } ``` -------------------------------- ### Terraform Plan and Apply Commands Source: https://github.com/vast-data/terraform-provider-vastdata/blob/v2.1/migration/tests/vast-terraform/README.md Generates an execution plan for Terraform changes and applies those changes to the Vast Data cluster. ```bash terraform plan -out vast.plan terraform apply vast.plan ``` -------------------------------- ### Retrieve vastdata DNS by ID, GUID, or Name Source: https://github.com/vast-data/terraform-provider-vastdata/blob/v2.1/docs/data-sources/dns.md This Terraform configuration demonstrates how to retrieve a `vastdata_dns` data source by its unique identifier (ID), globally unique identifier (GUID), or name. It requires the `vastdata` provider and assumes valid IDs, GUIDs, or names are provided. ```terraform data "vastdata_dns" "vastdb_dns_by_id" { id = 1 } data "vastdata_dns" "vastdb_dns_by_guid" { guid = "00000000-0000-0000-0000-000000000001" } data "vastdata_dns" "vastdb_dns_by_name" { name = "dns-1" } ``` -------------------------------- ### VastData Terraform Migration Tool Version Source: https://github.com/vast-data/terraform-provider-vastdata/blob/v2.1/migration/README.md Command to display the version of the VastData Terraform migration tool. ```bash ./run_migration.sh --version ```