### Example Usage of numspot_keypairs Data Source
Source: https://github.com/numspot/terraform-provider-numspot/blob/main/docs/data-sources/keypairs.md
This example demonstrates how to use the numspot_keypairs data source to retrieve keypair information. It first creates a keypair using the numspot_keypair resource and then queries it using the data source. Finally, it shows how to access the ID of the retrieved keypair.
```terraform
resource "numspot_keypair" "keypair" {
name = "key-pair-name"
}
data "numspot_keypairs" "datasource-kaypair" {
keypair_names = [numspot_keypair.keypair.name]
}
# How to use the datasource in another field
resource "null_resource" "print-datasource-id" {
provisioner "local-exec" {
command = "echo data.numspot_keypairs.datasource-kaypair.items.0.id"
}
}
```
--------------------------------
### Example Usage of numspot_dhcp_options Data Source
Source: https://github.com/numspot/terraform-provider-numspot/blob/main/docs/data-sources/dhcp_options.md
This example demonstrates how to create a DHCP options set using the numspot_dhcp_options resource and then query it using the numspot_dhcp_options data source. It also shows how to print the ID of a queried DHCP options set using a null_resource.
```terraform
resource "numspot_dhcp_options" "dhcp" {
domain_name = "the_domain_name"
}
data "numspot_dhcp_options" "datasource-dhcp-options" {
domain_names = [numspot_dhcp_options.dhcp.domain_name]
}
resource "null_resource" "print-datasource-id" {
provisioner "local-exec" {
command = "echo data.numspot_dhcp_options.testdata.items.0.id"
}
}
```
--------------------------------
### Create a Public Load Balancer
Source: https://github.com/numspot/terraform-provider-numspot/blob/main/docs/resources/load_balancer.md
This example shows how to configure a public-facing load balancer. It includes setup for VPC, internet gateway, subnet with public IP mapping, security group, route table, and the load balancer itself with multiple listeners and health checks.
```terraform
resource "numspot_vpc" "vpc" {
ip_range = "10.101.0.0/16"
}
resource "numspot_internet_gateway" "internet-gateway" {
vpc_id = numspot_vpc.vpc.id
}
resource "numspot_subnet" "subnet" {
vpc_id = numspot_vpc.vpc.id
ip_range = "10.101.1.0/24"
map_public_ip_on_launch = true
}
resource "numspot_security_group" "security-group" {
vpc_id = numspot_vpc.vpc.id
name = "group name"
description = "this is a security group"
inbound_rules = [
{
from_port_range = 80
to_port_range = 80
ip_protocol = "tcp"
}
]
outbound_rules = [
{
from_port_range = 80
to_port_range = 80
ip_protocol = "tcp"
}
]
}
resource "numspot_route_table" "route_table" {
vpc_id = numspot_vpc.vpc.id
subnet_id = numspot_subnet.subnet.id
routes = [
{
destination_ip_range = "0.0.0.0/0"
gateway_id = numspot_internet_gateway.internet-gateway.id
}
]
}
resource "numspot_vm" "vm" {
image_id = "ami-8ef5b47e"
type = "ns-cus6-4c8r"
subnet_id = numspot_subnet.subnet.id
}
resource "numspot_load_balancer" "load-balancer" {
name = "elb-terraform-test-updated"
listeners = [
{
backend_port = 443
load_balancer_port = 443
load_balancer_protocol = "TCP"
},
{
backend_port = 8080
load_balancer_port = 8080
load_balancer_protocol = "TCP"
}
]
subnets = [numspot_subnet.subnet.id]
security_groups = [numspot_security_group.security-group.id]
backend_vm_ids = [numspot_vm.vm.id]
type = "internet-facing"
health_check = {
healthy_threshold = 10
check_interval = 30
path = "/index.html"
port = 8080
protocol = "HTTPS"
timeout = 5
unhealthy_threshold = 5
}
depends_on = [numspot_internet_gateway.internet-gateway]
}
```
--------------------------------
### Example Usage of numspot_vpn_connections Data Source
Source: https://github.com/numspot/terraform-provider-numspot/blob/main/docs/data-sources/vpn_connections.md
This example demonstrates how to configure a VPN connection using numspot resources and then query its details using the numspot_vpn_connections data source. It also includes a null_resource to print the ID of the first VPN connection found by the data source.
```terraform
resource "numspot_client_gateway" "client-gateway" {
connection_type = "ipsec.1"
public_ip = "192.0.0.0"
bgp_asn = 123456
}
resource "numspot_virtual_gateway" "virtual-gateway" {
connection_type = "ipsec.1"
}
resource "numspot_vpn_connection" "vpn-connection" {
client_gateway_id = numspot_client_gateway.client-gateway.id
connection_type = "ipsec.1"
virtual_gateway_id = numspot_virtual_gateway.virtual-gateway.id
static_routes_only = false
}
data "numspot_vpn_connections" "datasource-vpn-connection" {
depends_on = [numspot_vpn_connection.vpn-connection]
}
resource "null_resource" "print-datasource-id" {
provisioner "local-exec" {
command = "echo data.numspot_vpn_connections.datasource-vpn-connection.items.0.id"
}
}
```
--------------------------------
### Example Usage
Source: https://github.com/numspot/terraform-provider-numspot/blob/main/docs/data-sources/client_gateways.md
Creates a client gateway and then retrieves a list of all client gateways.
```terraform
resource "numspot_client_gateway" "client-gateway" {
connection_type = "ipsec.1"
public_ip = "192.0.2.0"
bgp_asn = 65000
}
data "numspot_client_gateways" "datasource-client-gateway" {
depends_on = [numspot_client_gateway.client-gateway]
}
resource "null_resource" "print-datasource-id" {
provisioner "local-exec" {
command = "echo data.numspot_client_gateways.datasource-client-gateway.items.0.id"
}
}
```
--------------------------------
### Example Usage of numspot_vms Data Source
Source: https://github.com/numspot/terraform-provider-numspot/blob/main/docs/data-sources/vms.md
This example demonstrates how to use the numspot_vms data source to retrieve information about a specific VM by its ID. It first defines a VM resource and then uses the data source to query it. The output shows how to access the ID of the retrieved VM.
```terraform
resource "numspot_vpc" "vpc" {
ip_range = "10.101.0.0/16"
}
resource "numspot_subnet" "subnet" {
vpc_id = numspot_vpc.vpc.id
ip_range = "10.101.1.0/24"
availability_zone_name = "eu-west-2a"
}
resource "numspot_vm" "vm" {
image_id = "ami-0b7df82c"
type = "ns-cus6-2c4r"
subnet_id = numspot_subnet.subnet.id
}
data "numspot_vms" "datasource-vm" {
ids = [numspot_vm.vm.id]
}
# How to use the datasource in another field
resource "null_resource" "print-datasource-id" {
provisioner "local-exec" {
command = "echo data.numspot_vms.datasource-vm.items.0.id"
}
}
```
--------------------------------
### Example Usage of numspot_route_tables Data Source
Source: https://github.com/numspot/terraform-provider-numspot/blob/main/docs/data-sources/route_tables.md
This example demonstrates how to create a VPC, subnet, internet gateway, and a route table, and then use the `numspot_route_tables` data source to retrieve information about the created route table. It also shows how to access the ID of the retrieved route table using a `null_resource`.
```terraform
resource "numspot_vpc" "vpc" {
ip_range = "10.101.0.0/16"
}
resource "numspot_subnet" "subnet" {
vpc_id = numspot_vpc.vpc.id
ip_range = "10.101.1.0/24"
}
resource "numspot_internet_gateway" "internet-gateway" {
vpc_id = numspot_vpc.vpc.id
}
resource "numspot_route_table" "route-table" {
vpc_id = numspot_vpc.vpc.id
subnet_id = numspot_subnet.subnet.id
routes = [
{
destination_ip_range = "0.0.0.0/0"
gateway_id = numspot_internet_gateway.internet-gateway.id
}
]
}
data "numspot_route_tables" "datasource-route-table" {
ids = [numspot_route_table.route-table.id]
}
# How to use the datasource in another field
resource "null_resource" "print-datasource-id" {
provisioner "local-exec" {
command = "echo data.numspot_route_tables.datasource-route-table.items.0.id"
}
}
```
--------------------------------
### Example Usage of numspot_compute_bridges Data Source
Source: https://github.com/numspot/terraform-provider-numspot/blob/main/docs/data-sources/compute_bridges.md
This example demonstrates how to create two VPCs, establish a compute bridge between them, and then use the numspot_compute_bridges data source to query for the created bridge. The data source depends on the compute bridge resource to ensure it's available before querying.
```terraform
resource "numspot_vpc" "vpc_source" {
ip_range = "10.101.1.0/24"
tags = [{
key = "name"
value = "vpc a"
}]
}
resource "numspot_vpc" "vpc_dest" {
ip_range = "10.101.2.0/24"
tags = [{
key = "name"
value = "vpc b"
}]
}
resource "numspot_compute_bridge" "compute-bridge" {
destination_vpc_id = numspot_vpc.vpc_dest.id
source_vpc_id = numspot_vpc.vpc_source.id
}
data "numspot_compute_bridges" "datasource-compute-bridge" {
depends_on = [numspot_compute_bridge.compute-bridge]
}
```
--------------------------------
### Example Usage of numspot_nics Data Source
Source: https://github.com/numspot/terraform-provider-numspot/blob/main/docs/data-sources/nics.md
This example demonstrates how to use the numspot_nics data source to retrieve NIC information. It first creates a VPC and a subnet, then a NIC, and finally uses the data source to query the created NIC by its ID. The output shows how to access the ID of the retrieved NIC.
```terraform
resource "numspot_vpc" "vpc" {
ip_range = "10.101.0.0/16"
}
resource "numspot_subnet" "subnet" {
vpc_id = numspot_vpc.vpc.id
ip_range = "10.101.1.0/24"
}
resource "numspot_nic" "nic" {
subnet_id = numspot_subnet.subnet.id
}
data "numspot_nics" "datasource-nic" {
ids = [numspot_nic.nic.id]
}
# How to use the datasource in another field
resource "null_resource" "print-datasource-id" {
provisioner "local-exec" {
command = "echo data.numspot_nics.datasource-nic.items.0.id"
}
}
```
--------------------------------
### Example Usage of numspot_subnets Data Source
Source: https://github.com/numspot/terraform-provider-numspot/blob/main/docs/data-sources/subnets.md
This example demonstrates how to use the numspot_subnets data source to retrieve subnet information. It first creates a VPC and a subnet, then uses the data source to query subnets within that VPC, and finally prints the ID of the first retrieved subnet.
```terraform
resource "numspot_vpc" "vpc" {
ip_range = "10.101.0.0/16"
}
resource "numspot_subnet" "subnet" {
vpc_id = numspot_vpc.vpc.id
ip_range = "10.101.1.0/24"
}
data "numspot_subnets" "datasource-subnet" {
vpc_ids = [numspot_vpc.vpc.id]
depends_on = [numspot_subnet.subnet]
}
resource "null_resource" "print-datasource-id" {
provisioner "local-exec" {
command = "echo data.numspot_subnet.datasource-subnet.items.0.id"
}
}
```
--------------------------------
### Example Usage of numspot_internet_gateways Data Source
Source: https://github.com/numspot/terraform-provider-numspot/blob/main/docs/data-sources/internet_gateways.md
This example demonstrates how to use the numspot_internet_gateways data source to retrieve a specific internet gateway by its ID. It first creates a VPC and an internet gateway, then uses the data source to query for that specific gateway. Finally, it shows how to access the ID of the retrieved gateway.
```terraform
resource "numspot_vpc" "vpc" {
ip_range = "10.101.1.0/24"
tags = [{
key = "name"
value = "vpc"
}]
}
resource "numspot_internet_gateway" "internet-gateway" {
vpc_id = numspot_vpc.vpc.id
}
data "numspot_internet_gateways" "datasource-internet-gateway" {
ids = [numspot_internet_gateway.internet-gateway.id]
}
# How to use the datasource in another field
resource "null_resource" "print-datasource-id" {
provisioner "local-exec" {
command = "echo data.numspot_internet_gateways.datasource-internet-gateway.items.0.id"
}
}
```
--------------------------------
### Example Usage of numspot_snapshots Data Source
Source: https://github.com/numspot/terraform-provider-numspot/blob/main/docs/data-sources/snapshots.md
This example demonstrates how to use the numspot_snapshots data source to retrieve snapshot information. It first creates a volume and a snapshot, then uses the data source to filter snapshots by ID. Finally, it shows how to access the retrieved data.
```terraform
resource "numspot_volume" "volume" {
type = "standard"
size = 11
availability_zone_name = "eu-west-2a"
}
resource "numspot_snapshot" "snapshot" {
volume_id = numspot_volume.volume.id
}
data "numspot_snapshots" "datasource-snapshot" {
ids = [numspot_snapshot.snapshot.id]
}
# How to use the datasource in another field
resource "null_resource" "print-datasource-id" {
provisioner "local-exec" {
command = "echo data.numspot_snapshots.datasource-snapshots.items.0.id"
}
}
```
--------------------------------
### Create a Flexible GPU
Source: https://github.com/numspot/terraform-provider-numspot/blob/main/docs/resources/flexible_gpu.md
This example demonstrates how to create a flexible GPU and attach it to a virtual machine. Ensure that the VPC and Subnet are created first, as they are prerequisites for the VM.
```terraform
resource "numspot_vpc" "vpc" {
ip_range = "10.101.0.0/16"
}
resource "numspot_subnet" "subnet" {
vpc_id = numspot_vpc.vpc.id
ip_range = "10.101.1.0/24"
}
resource "numspot_vm" "vm" {
image_id = "ami-0b7df82c"
type = "ns-cus6-4c8r"
subnet_id = numspot_subnet.subnet.id
}
resource "numspot_flexible_gpu" "gpu" {
model_name = "nvidia-a100-80"
generation = "v6"
availability_zone_name = "eu-west-2a"
vm_id = numspot_vm.vm.id
}
```
--------------------------------
### Create a numspot snapshot
Source: https://github.com/numspot/terraform-provider-numspot/blob/main/docs/resources/snapshot.md
This example shows how to create a snapshot from an existing volume. Ensure the volume resource is defined and available.
```terraform
resource "numspot_volume" "volume" {
type = "standard"
size = 11
availability_zone_name = "eu-west-2a"
}
resource "numspot_snapshot" "snapshot" {
volume_id = numspot_volume.volume.id
description = "A beautiful snapshot"
tags = [
{
key = "name"
value = "My Snapshot"
}
]
}
```
--------------------------------
### Create a VPC with DHCP Options
Source: https://github.com/numspot/terraform-provider-numspot/blob/main/docs/resources/vpc.md
This example shows how to create a VPC resource and associate it with a DHCP options set. Ensure the numspot_dhcp_options resource is defined prior to this.
```terraform
resource "numspot_dhcp_options" "options" {
domain_name = "domain"
}
resource "numspot_vpc" "example" {
ip_range = "10.0.0.0/16"
dhcp_options_set_id = numspot_dhcp_options.options.id
tenancy = "default"
tags = [
{
key = "name"
value = "My VPC"
}
]
}
```
--------------------------------
### Example Usage of numspot_virtual_gateways Data Source
Source: https://github.com/numspot/terraform-provider-numspot/blob/main/docs/data-sources/virtual_gateways.md
This example demonstrates how to use the numspot_virtual_gateways data source to retrieve information about virtual gateways. It first creates a VPC and a virtual gateway, then uses the data source to fetch details about the created virtual gateway, and finally prints the ID of the first virtual gateway found.
```terraform
resource "numspot_vpc" "vpc" {
ip_range = "10.101.0.0/16"
}
resource "numspot_virtual_gateway" "virtual-gateway" {
connection_type = "ipsec.1"
vpc_id = numspot_vpc.vpc.id
}
data "numspot_virtual_gateways" "datasource-virtual-gateway" {
depends_on = [numspot_virtual_gateway.virtual-gateway]
}
resource "null_resource" "print-datasource-id" {
provisioner "local-exec" {
command = "echo data.numspot_virtual_gateways.datasource-virtual-gateway.items.0.id"
}
}
```
--------------------------------
### Example Usage of numspot_volumes Data Source
Source: https://github.com/numspot/terraform-provider-numspot/blob/main/docs/data-sources/volumes.md
This example demonstrates how to use the numspot_volumes data source to retrieve information about volumes. It first creates a volume using the numspot_volume resource and then queries for it using its ID with the numspot_volumes data source. Finally, it prints the ID of the retrieved volume.
```terraform
resource "numspot_volume" "volume" {
type = "standard"
size = 11
availability_zone_name = "eu-west-2a"
}
data "numspot_volumes" "datasource_volume" {
ids = [numspot_volume.volume.id]
}
resource "null_resource" "print-datasource-id" {
provisioner "local-exec" {
command = "echo data.numspot_volumes.datasource-volume.items.0.id"
}
}
```
--------------------------------
### Example Usage of numspot_hybrid_bridges Data Source
Source: https://github.com/numspot/terraform-provider-numspot/blob/main/docs/data-sources/hybrid_bridges.md
This example demonstrates how to use the numspot_hybrid_bridges data source to retrieve information about hybrid bridges. It first creates a VPC and a hybrid bridge, then uses the data source to fetch the bridge details. Finally, it prints the ID of the first bridge found.
```terraform
resource "numspot_vpc" "vpc" {
ip_range = "10.101.1.0/24"
tags = [{
key = "name"
value = "vpc a"
}]
}
resource "numspot_hybrid_bridge" "hybrid-bridge" {
managed_service_id = "" // Managed service ID
vpc_id = numspot_vpc.vpc.id
}
data "numspot_hybrid_bridges" "datasource-hybrid-bridge" {
depends_on = [numspot_hybrid_bridge.hybrid-bridge]
}
resource "null_resource" "print-datasource-id" {
provisioner "local-exec" {
command = "echo data.numspot_hybrid_bridges.datasource-hybrid-bridge.items.0.id"
}
}
```
--------------------------------
### Example Usage of numspot_load_balancers Data Source
Source: https://github.com/numspot/terraform-provider-numspot/blob/main/docs/data-sources/load_balancers.md
This example demonstrates how to use the numspot_load_balancers data source to retrieve information about a specific load balancer by its name. It first defines a VPC, a subnet, and a load balancer resource, then queries the load balancer using the data source, and finally prints the ID of the retrieved load balancer.
```terraform
resource "numspot_vpc" "vpc" {
ip_range = "10.101.0.0/16"
}
resource "numspot_subnet" "subnet" {
vpc_id = numspot_vpc.vpc.id
ip_range = "10.101.1.0/24"
}
resource "numspot_load_balancer" "load-balancer" {
name = "elb"
listeners = [
{
backend_port = 80
load_balancer_port = 80
backend_protocol = "TCP"
load_balancer_protocol = "TCP"
}
]
subnets = [numspot_subnet.subnet.id]
type = "internal"
}
data "numspot_load_balancers" "datasource-load-balancer" {
load_balancer_names = [numspot_load_balancer.load-balancer.name]
}
resource "null_resource" "print-datasource-id" {
provisioner "local-exec" {
command = "echo data.numspot_load_balancers.datasource-load-balancer.items.0.id"
}
}
```
--------------------------------
### Example Usage of numspot_vpcs Data Source
Source: https://github.com/numspot/terraform-provider-numspot/blob/main/docs/data-sources/vpcs.md
This example demonstrates how to use the numspot_vpcs data source to retrieve VPC information. It first creates a VPC using the numspot_vpc resource and then uses the data source to fetch details about it, referencing the created VPC's ID. Finally, it shows how to access the ID of the retrieved VPC from the data source's output.
```terraform
resource "numspot_vpc" "vpc" {
ip_range = "10.101.0.0/16"
}
data "numspot_vpcs" "datasource-vpc" {
ids = [numspot_vpc.vpc.id]
}
# How to use the datasource in another field
resource "null_resource" "print-datasource-id" {
provisioner "local-exec" {
command = "echo data.numspot_vpcs.datasource-vpc.items.0.id"
}
}
```
--------------------------------
### Build NumSpot Terraform Provider
Source: https://github.com/numspot/terraform-provider-numspot/blob/main/README.md
Build the provider using the Go install command. Run 'go generate' to update documentation.
```shell
go install
```
--------------------------------
### Example Usage of numspot_security_groups Data Source
Source: https://github.com/numspot/terraform-provider-numspot/blob/main/docs/data-sources/security_groups.md
This example demonstrates how to use the numspot_security_groups data source to retrieve security group information. It first defines a VPC and a security group, then uses the data source to query for the created security group by its ID. Finally, it shows how to access the retrieved data, specifically the ID of the first item found.
```terraform
resource "numspot_vpc" "vpc" {
ip_range = "10.101.0.0/16"
}
resource "numspot_security_group" "security-group" {
net_id = numspot_vpc.vpc.id
name = "group name"
description = "this is a security group"
outbound_rules = [
{
from_port_range = 80
to_port_range = 80
ip_protocol = "tcp"
},
{
from_port_range = 443
to_port_range = 443
ip_protocol = "tcp"
}
]
}
data "numspot_security_groups" "datasource-security-group" {
security_group_ids = [numspot_security_group.security-group.id]
}
# How to use the datasource in another field
resource "null_resource" "print-datasource-id" {
provisioner "local-exec" {
command = "echo data.numspot_security_groups.datasource-security-group.items.0.id"
}
}
```
--------------------------------
### Example Usage of numspot_public_ips Data Source
Source: https://github.com/numspot/terraform-provider-numspot/blob/main/docs/data-sources/public_ips.md
This example demonstrates how to use the numspot_public_ips data source to retrieve information about a specific public IP address by its ID. It first defines resources for VPC, Internet Gateway, Subnet, NIC, and Public IP, then uses the data source to query the created public IP.
```terraform
resource "numspot_vpc" "vpc" {
ip_range = "10.101.0.0/16"
}
resource "numspot_internet_gateway" "internet-gateway" {
vpc_id = numspot_vpc.vpc.id
depends_on = [numspot_nic.nic]
}
resource "numspot_subnet" "subnet" {
vpc_id = numspot_vpc.vpc.id
ip_range = "10.101.1.0/24"
}
resource "numspot_nic" "nic" {
subnet_id = numspot_subnet.subnet.id
}
resource "numspot_public_ip" "public-ip" {
nic_id = numspot_nic.nic.id
depends_on = [numspot_internet_gateway.internet-gateway]
}
data "numspot_public_ips" "datasource-public-ip" {
ids = [numspot_public_ip.public-ip.id]
}
```
--------------------------------
### Create a Virtual Gateway
Source: https://github.com/numspot/terraform-provider-numspot/blob/main/docs/resources/virtual_gateway.md
This example shows how to create a virtual gateway with an IPsec connection type and attach it to a VPC. The `numspot_vpc` resource must be created first.
```terraform
resource "numspot_vpc" "vpc" {
ip_range = "10.101.0.0/16"
}
resource "numspot_virtual_gateway" "virtual-gateway" {
connection_type = "ipsec.1"
vpc_id = numspot_vpc.vpc.id
}
data "numspot_virtual_gateways" "datasource-virtual-gateways-acctest" {
depends_on = [numspot_virtual_gateway.virtual-gateway]
}
```
--------------------------------
### numspot_flexible_gpus Data Source Usage
Source: https://github.com/numspot/terraform-provider-numspot/blob/main/docs/data-sources/flexible_gpus.md
Example of how to use the numspot_flexible_gpus data source to fetch GPU information and then reference it in other resources.
```APIDOC
## numspot_flexible_gpus (Data Source)
### Description
This data source can be used to query information about flexible GPUs.
### Schema
#### Optional Parameters
- `availability_zone_names` (List of String) - The Subregions where the fGPUs are located.
- `delete_on_vm_deletion` (Boolean) - Indicates whether the fGPU is deleted when terminating the VM.
- `generations` (List of String) - The processor generations that the fGPUs are compatible with.
- `ids` (List of String) - One or more IDs of fGPUs.
- `model_names` (List of String) - One or more models of fGPUs.
- `states` (List of String) - The states of the fGPUs (`allocated` | `attaching` | `attached` | `detaching`).
- `vm_ids` (List of String) - One or more IDs of VMs.
#### Read-Only Parameters
- `items` (Attributes List) - Information about one or more fGPUs. (see [below for nested schema](#nestedatt--items))
### Nested Schema for `items`
Read-Only:
- `availability_zone_name` (String) - The Subregion where the fGPU is located.
- `delete_on_vm_deletion` (Boolean) - If true, the fGPU is deleted when the VM is terminated.
- `generation` (String) - The compatible processor generation.
- `id` (String) - The ID of the fGPU.
- `model_name` (String) - The model of fGPU.
- `state` (String) - The state of the fGPU (`allocated` | `attaching` | `attached` | `detaching`).
- `vm_id` (String) - The ID of the VM the fGPU is attached to, if any.
### Example Usage
```terraform
resource "numspot_flexible_gpu" "gpu" {
model_name = "nvidia-p100"
generation = "v5"
availability_zone_name = "eu-west-2a"
}
data "numspot_flexible_gpus" "datasource-gpu" {
ids = [numspot_flexible_gpu.gpu.id]
}
# How to use the datasource in another field
resource "null_resource" "print-datasource-id" {
provisioner "local-exec" {
command = "echo data.numspot_flexible_gpus.datasource-gpu.items.0.id"
}
}
```
```
--------------------------------
### Example Usage of numspot_nat_gateways Data Source
Source: https://github.com/numspot/terraform-provider-numspot/blob/main/docs/data-sources/nat_gateways.md
This example demonstrates how to use the numspot_nat_gateways data source to retrieve information about NAT gateways. It first defines resources for VPC, Internet Gateway, Subnet, Public IP, Route Table, and NAT Gateway, then uses the data source to query NAT gateways associated with a specific subnet. Finally, it shows how to access the ID of the retrieved NAT gateway information.
```terraform
resource "numspot_vpc" "vpc" {
ip_range = "10.101.0.0/16"
}
resource "numspot_internet_gateway" "internet-gateway" {
vpc_id = numspot_vpc.vpc.id
}
resource "numspot_subnet" "subnet" {
vpc_id = numspot_vpc.vpc.id
map_public_ip_on_launch = true
ip_range = "10.101.1.0/24"
}
resource "numspot_public_ip" "public-ip" {}
resource "numspot_route_table" "route-table" {
vpc_id = numspot_vpc.vpc.id
subnet_id = numspot_subnet.subnet.id
routes = [
{
destination_ip_range = "0.0.0.0/0"
gateway_id = numspot_internet_gateway.internet-gateway.id
}
]
}
resource "numspot_nat_gateway" "nat-gateway" {
subnet_id = numspot_subnet.subnet.id
public_ip_id = numspot_public_ip.public-ip.id
depends_on = [numspot_route_table.route-table]
}
data "numspot_nat_gateways" "datasource-nat-gateway" {
subnet_ids = [numspot_subnet.subnet.id]
depends_on = [numspot_nat_gateway.nat-gateway]
}
# How to use the datasource in another field
resource "null_resource" "print-datasource-id" {
provisioner "local-exec" {
command = "echo data.numspot_nat_gateways.datasource-nat-gateway.items.0.id"
}
}
```
--------------------------------
### numspot_public_ip Resource Configuration
Source: https://github.com/numspot/terraform-provider-numspot/blob/main/docs/resources/public_ip.md
Example of how to configure a numspot_public_ip resource, associating it with a VM and adding tags. It also demonstrates the necessary dependencies.
```APIDOC
## numspot_public_ip Resource
### Description
Manages a public IP address resource.
### Schema
#### Optional
- `nic_id` (String) The ID of the NIC the public IP is associated with (if any).
**Note:** Exactly one of `nic_id` or `vm_id` must be set.
- `tags` (Attributes Set) One or more tags associated with the Vpc. (see [below for nested schema](#nestedatt--tags))
- `vm_id` (String) The ID of the VM the public IP is associated with (if any).
**Note:** Exactly one of `nic_id` or `vm_id` must be set.
#### Read-Only
- `id` (String) The allocation ID of the public IP.
- `link_public_ip_id` (String) (Required in a Vpc) The ID representing the association of the public IP with the VM or the NIC.
- `private_ip` (String) The private IP associated with the public IP.
- `public_ip` (String) The public IP.
### Nested Schema for `tags`
Required:
- `key` (String) The key of the tag, with a minimum of 1 character.
- `value` (String) The value of the tag, between 0 and 255 characters.
```
--------------------------------
### Create a NIC Resource
Source: https://github.com/numspot/terraform-provider-numspot/blob/main/docs/resources/nic.md
Example of creating a NIC resource, associating it with a subnet and applying tags. Ensure the subnet is created first.
```terraform
resource "numspot_vpc" "vpc" {
ip_range = "10.101.0.0/16"
}
resource "numspot_subnet" "subnet" {
vpc_id = numspot_vpc.vpc.id
ip_range = "10.101.1.0/24"
}
resource "numspot_nic" "nic" {
subnet_id = numspot_subnet.subnet.id
tags = [
{
key = "name"
value = "My Nic"
}
]
}
```
--------------------------------
### Create a numspot VM
Source: https://github.com/numspot/terraform-provider-numspot/blob/main/docs/resources/vm.md
This example demonstrates how to create a basic virtual machine with specified image, type, and network configurations. It includes setting up dependent resources like VPC, subnet, and security group.
```terraform
resource "numspot_vpc" "vpc" {
ip_range = "10.101.0.0/16"
}
resource "numspot_subnet" "subnet" {
vpc_id = numspot_vpc.vpc.id
ip_range = "10.101.1.0/24"
availability_zone_name = "eu-west-2a"
}
resource "numspot_security_group" "security-group" {
vpc_id = numspot_vpc.vpc.id
name = "terraform-vm-tests-sg-name"
description = "terraform-vm-tests-sg-description"
inbound_rules = [
{
from_port_range = 80
to_port_range = 80
ip_protocol = "tcp"
}
]
}
resource "numspot_internet_gateway" "internet-gateway" {
vpc_id = numspot_vpc.vpc.id
}
resource "numspot_route_table" "route-table" {
vpc_id = numspot_vpc.vpc.id
subnet_id = numspot_subnet.subnet.id
routes = [
{
destination_ip_range = "0.0.0.0/0"
gateway_id = numspot_internet_gateway.internet-gateway.id
}
]
}
resource "numspot_public_ip" "public_ip" {
vm_id = numspot_vm.vm.id
depends_on = [numspot_route_table.route-table]
}
resource "numspot_vm" "vm" {
image_id = "image-id"
type = "ns-eco6-2c8r"
initiated_shutdown_behavior = "stop"
placement = {
tenancy = "default"
availability_zone_name = "eu-west-2a"
}
subnet_id = numspot_subnet.subnet.id
security_group_ids = [numspot_security_group.security-group.id]
tags = [
{
key = "name"
value = "Terraform-Test-VM"
}
]
}
```
--------------------------------
### numspot_client_gateway Resource Example
Source: https://github.com/numspot/terraform-provider-numspot/blob/main/docs/resources/client_gateway.md
Example of how to define a `numspot_client_gateway` resource in Terraform.
```APIDOC
## numspot_client_gateway (Resource)
### Description
This resource allows the creation and management of a client gateway.
### Schema
#### Required
- `bgp_asn` (Number) - The Autonomous System Number (ASN) used by the Border Gateway Protocol (BGP) to find the path to your client gateway through the Internet. This number must be between `1` and `4294967295`. If you do not have an ASN, you can choose one between 64512 and 65534, or between 4200000000 and 4294967294.
- `connection_type` (String) - The communication protocol used to establish tunnel with your client gateway (only `ipsec.1` is supported).
- `public_ip` (String) - The public fixed IPv4 address of your client gateway.
### Read-Only
- `id` (String) - The ID of the client gateway.
- `state` (String) - The state of the client gateway (`pending` | `available` | `deleting` | `deleted`).
### Example Usage
```terraform
resource "numspot_client_gateway" "client-gateway" {
connection_type = "ipsec.1"
public_ip = "192.0.0.1"
bgp_asn = 65000
}
```
```
--------------------------------
### Create a standard volume and link it to a VM
Source: https://github.com/numspot/terraform-provider-numspot/blob/main/docs/resources/volume.md
This example demonstrates how to create a standard volume with a specified size and tags, and then link it to a virtual machine using its ID and a device name. Ensure the VM and subnet are created prior to the volume.
```terraform
resource "numspot_vpc" "vpc" {
ip_range = "10.101.0.0/16"
}
resource "numspot_subnet" "subnet" {
vpc_id = numspot_vpc.vpc.id
ip_range = "10.101.1.0/24"
availability_zone_name = "eu-west-2a"
}
resource "numspot_vm" "vm" {
image_id = "ami-0b7df82c"
type = "ns-cus6-2c4r"
subnet_id = numspot_subnet.subnet.id
tags = [
{
key = "name"
value = "terraform-volume-acctest"
}
]
}
resource "numspot_volume" "volume" {
type = "standard"
size = 11
availability_zone_name = "eu-west-2a"
tags = [
{
key = "name"
value = "My Volume"
}
]
link_vm = {
vm_id = numspot_vm.vm.id
device_name = "/dev/sdb"
}
}
```
--------------------------------
### numspot_security_groups Data Source Example
Source: https://github.com/numspot/terraform-provider-numspot/blob/main/docs/data-sources/security_groups.md
Example of how to use the numspot_security_groups data source to retrieve security group information.
```APIDOC
## numspot_security_groups
### Description
This data source can be used to query security groups within Numspot. It allows filtering by various attributes and retrieving details about matching security groups.
### Schema
#### Optional Parameters
- `descriptions` (List of String) - The descriptions of the security groups.
- `inbound_rule_from_port_ranges` (List of Number) - The beginnings of the port ranges for the TCP and UDP protocols, or the ICMP type numbers.
- `inbound_rule_ip_ranges` (List of String) - The IP ranges that have been granted permissions, in CIDR notation (for example, `10.0.0.0/24`).
- `inbound_rule_protocols` (List of String) - The IP protocols for the permissions (`tcp` | `udp` | `icmp`, or a protocol number, or `-1` for all protocols).
- `inbound_rule_security_group_ids` (List of String) - The IDs of the security groups that have been granted permissions.
- `inbound_rule_to_port_ranges` (List of Number) - The ends of the port ranges for the TCP and UDP protocols, or the ICMP code numbers.
- `outbound_rule_from_port_ranges` (List of Number) - The beginnings of the port ranges for the TCP and UDP protocols, or the ICMP type numbers.
- `outbound_rule_ip_ranges` (List of String) - The IP ranges that have been granted permissions, in CIDR notation (for example, `10.0.0.0/24`).
- `outbound_rule_protocols` (List of String) - The IP protocols for the permissions (`tcp` | `udp` | `icmp`, or a protocol number, or `-1` for all protocols).
- `outbound_rule_security_group_ids` (List of String) - The IDs of the security groups that have been granted permissions.
- `outbound_rule_to_port_ranges` (List of Number) - The ends of the port ranges for the TCP and UDP protocols, or the ICMP code numbers.
- `security_group_ids` (List of String) - The IDs of the security groups.
- `security_group_names` (List of String) - The names of the security groups.
- `tag_keys` (List of String) - The keys of the tags associated with the security groups.
- `tag_values` (List of String) - The values of the tags associated with the security groups.
- `tags` (List of String) - The key/value combination of the tags associated with the security groups, in the following format: "Filters":{"Tags":["TAGKEY=TAGVALUE"]}.
- `vpc_ids` (List of String) - The IDs of the Vpcs specified when the security groups were created.
#### Read-Only Attributes
- `items` (Attributes List) - Information about one or more security groups. (see [below for nested schema](#nestedatt--items))
### Nested Schema for `items`
Read-Only:
- `description` (String) - The description of the security group.
- `id` (String) - The ID of the security group.
- `inbound_rules` (Attributes List) - The inbound rules associated with the security group. (see [below for nested schema](#nestedatt--items--inbound_rules))
- `name` (String) - The name of the security group.
- `outbound_rules` (Attributes List) - The outbound rules associated with the security group. (see [below for nested schema](#nestedatt--items--outbound_rules))
- `tags` (Attributes List) - One or more tags associated with the security group. (see [below for nested schema](#nestedatt--items--tags))
- `vpc_id` (String) - The ID of the Vpc for the security group.
### Example Usage
```terraform
data "numspot_security_groups" "datasource-security-group" {
security_group_ids = [numspot_security_group.security-group.id]
}
```
```
--------------------------------
### numspot_dhcp_options Data Source Usage
Source: https://github.com/numspot/terraform-provider-numspot/blob/main/docs/data-sources/dhcp_options.md
Example of how to use the numspot_dhcp_options data source to retrieve DHCP options information. This example demonstrates fetching DHCP options based on a domain name and then using the retrieved ID in a null_resource for demonstration purposes.
```APIDOC
## numspot_dhcp_options Data Source
### Description
This data source allows you to query and retrieve information about DHCP options sets. You can filter the results by domain names, domain name servers, log servers, NTP servers, and tags.
### Parameters
#### Optional Query Parameters
- `default` (Boolean) - Optional - If true, lists all default DHCP options set. If false, lists all non-default DHCP options set.
- `domain_name_servers` (List of String) - Optional - The IPs of the domain name servers used for the DHCP options sets.
- `domain_names` (List of String) - Optional - The domain names used for the DHCP options sets.
- `ids` (List of String) - Optional - The IDs of the DHCP options sets.
- `log_servers` (List of String) - Optional - The IPs of the log servers used for the DHCP options sets.
- `ntp_servers` (List of String) - Optional - The IPs of the Network Time Protocol (NTP) servers used for the DHCP options sets.
- `tag_keys` (List of String) - Optional - The keys of the tags associated with the DHCP options sets.
- `tag_values` (List of String) - Optional - The values of the tags associated with the DHCP options sets.
- `tags` (List of String) - Optional - The key/value combination of the tags associated with the DHCP options sets, in the following format: "Filters":{"Tags":["TAGKEY=TAGVALUE"]}.
### Read-Only Attributes
- `items` (Attributes List) - Information about one or more DHCP options sets.
- `default` (Boolean) - If true, the DHCP options set is a default one. If false, it is not.
- `domain_name` (String) - The domain name.
- `domain_name_servers` (List of String) - One or more IPs for the domain name servers.
- `id` (String) - The ID of the DHCP options set.
- `log_servers` (List of String) - One or more IPs for the log servers.
- `ntp_servers` (List of String) - One or more IPs for the NTP servers.
- `tags` (Attributes List) - One or more tags associated with the DHCP options set.
- `key` (String) - The key of the tag, with a minimum of 1 character.
- `value` (String) - The value of the tag, between 0 and 255 characters.
### Example Usage
```terraform
resource "numspot_dhcp_options" "dhcp" {
domain_name = "the_domain_name"
}
data "numspot_dhcp_options" "datasource-dhcp-options" {
domain_names = [numspot_dhcp_options.dhcp.domain_name]
}
resource "null_resource" "print-datasource-id" {
provisioner "local-exec" {
command = "echo data.numspot_dhcp_options.testdata.items.0.id"
}
}
```
```
--------------------------------
### Create and Read Server Certificate
Source: https://github.com/numspot/terraform-provider-numspot/blob/main/docs/data-sources/server_certificate.md
This example shows how to create a server certificate using the `numspot_server_certificate` resource and then read its details using the `numspot_server_certificate` data source. The `null_resource` is used to print the name of the certificate after it has been created and is available via the data source.
```terraform
resource "numspot_server_certificate" "crt-terraform-tst-01" {
name = "crt-terraform-tst-01"
body = file("/path")
private_key = file("/path")
}
data "numspot_server_certificate" "datasource-server-certificate" {
depends_on = [numspot_server_certificate.crt-terraform-tst-01]
}
resource "null_resource" "print-datasource-id" {
provisioner "local-exec" {
command = "echo data.numspot_server_certificate.datasource-server-certificate.items.0.name"
}
}
```