Skip to content

Commit

Permalink
feat: generate templates from existing docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ctreatma committed Apr 12, 2024
1 parent 912e9f9 commit 32786f4
Show file tree
Hide file tree
Showing 201 changed files with 10,001 additions and 0 deletions.
7 changes: 7 additions & 0 deletions examples/data-sources/ecx_l2_sellerprofile/example_1.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
data "equinix_ecx_l2_sellerprofile" "aws" {
name = "AWS Direct Connect"
}

output "id" {
value = data.equinix_ecx_l2_sellerprofile.aws.id
}
5 changes: 5 additions & 0 deletions examples/data-sources/ecx_l2_sellerprofiles/example_1.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
data "equinix_ecx_l2_sellerprofiles" "aws" {
organization_global_name = "AWS"
metro_codes = ["SV", "DC"]
speed_bands = ["1GB", "500MB"]
}
7 changes: 7 additions & 0 deletions examples/data-sources/ecx_port/example_1.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
data "equinix_ecx_port" "tf-pri-dot1q" {
name = "sit-001-CX-NY5-NL-Dot1q-BO-10G-PRI-JP-157"
}

output "id" {
value = data.equinix_ecx_port.tf-pri-dot1q.id
}
3 changes: 3 additions & 0 deletions examples/data-sources/fabric_cloud_router/example_1.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "equinix_fabric_cloud_router" "cloud_router_data_name" {
uuid = "<uuid_of_cloud_router>"
}
3 changes: 3 additions & 0 deletions examples/data-sources/fabric_connection/example_1.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "equinix_fabric_connection" "connection_data_name" {
uuid = "<uuid_of_connection>"
}
3 changes: 3 additions & 0 deletions examples/data-sources/fabric_network/example_1.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "equinix_fabric_network" "network_data_name" {
uuid = "<uuid_of_network>"
}
3 changes: 3 additions & 0 deletions examples/data-sources/fabric_port/example_1.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "equinix_fabric_port" "port_data_name" {
uuid = "<uuid_of_port>"
}
5 changes: 5 additions & 0 deletions examples/data-sources/fabric_ports/example_1.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
data "equinix_fabric_ports" "ports_data_name" {
filters {
name = "<name_of_port||port_prefix>"
}
}
4 changes: 4 additions & 0 deletions examples/data-sources/fabric_routing_protocol/example_1.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
data "equinix_fabric_routing_protocol" "routing_protocol_data_name" {
connection_uuid = "<uuid_of_connection_routing_protocol_is_applied_to>"
uuid = "<uuid_of_routing_protocol>"
}
3 changes: 3 additions & 0 deletions examples/data-sources/fabric_service_profile/example_1.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "equinix_fabric_service_profile" "service_profile_data_name" {
uuid = "<uuid_of_service_profile>"
}
7 changes: 7 additions & 0 deletions examples/data-sources/fabric_service_profiles/example_1.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
data "equinix_fabric_service_profiles" "service_profiles_data_name" {
filter {
property = "/name"
operator = "="
values = ["<list_of_profiles_to_return>"]
}
}
3 changes: 3 additions & 0 deletions examples/data-sources/metal_connection/example_1.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "equinix_metal_connection" "example" {
connection_id = "4347e805-eb46-4699-9eb9-5c116e6a017d"
}
10 changes: 10 additions & 0 deletions examples/data-sources/metal_device/example_1.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Fetch a device data by hostname and show it's ID

data "equinix_metal_device" "test" {
project_id = local.project_id
hostname = "mydevice"
}

output "id" {
value = data.equinix_metal_device.test.id
}
8 changes: 8 additions & 0 deletions examples/data-sources/metal_device/example_2.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Fetch a device data by ID and show its public IPv4
data "equinix_metal_device" "test" {
device_id = "4c641195-25e5-4c3c-b2b7-4cd7a42c7b40"
}

output "ipv4" {
value = data.equinix_metal_device.test.access_public_ipv4
}
9 changes: 9 additions & 0 deletions examples/data-sources/metal_device_bgp_neighbors/example_1.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Get Project by name and print UUIDs of its users

data "equinix_metal_device_bgp_neighbors" "test" {
device_id = "4c641195-25e5-4c3c-b2b7-4cd7a42c7b40"
}

output "bgp_neighbors_listing" {
value = data.equinix_metal_device_bgp_neighbors.test.bgp_neighbors
}
18 changes: 18 additions & 0 deletions examples/data-sources/metal_devices/example_1.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Following example will select c3.small.x86 devices which are deplyed in metro 'da' (Dallas)
# OR 'sv' (Sillicon Valley).
data "equinix_metal_devices" "example" {
project_id = local.project_id
filter {
attribute = "plan"
values = ["c3.small.x86"]
}
filter {
attribute = "metro"
values = ["da", "sv"]
}
}

output "devices" {
organization_id = local.org_id
value = data.equinix_metal_devices.example.devices
}
9 changes: 9 additions & 0 deletions examples/data-sources/metal_devices/example_2.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Following example takes advantage of the `search` field in the API request, and will select devices with
# string "database" in one of the searched attributes. See `search` in argument reference.
data "equinix_metal_devices" "example" {
search = "database"
}

output "devices" {
value = data.equinix_metal_devices.example.devices
}
9 changes: 9 additions & 0 deletions examples/data-sources/metal_facility/example_1.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Fetch a facility by code and show its ID

data "equinix_metal_facility" "ny5" {
code = "ny5"
}

output "id" {
value = data.equinix_metal_facility.ny5.id
}
18 changes: 18 additions & 0 deletions examples/data-sources/metal_facility/example_2.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Verify that facility "dc13" has capacity for provisioning 2 c3.small.x86
devices and 1 c3.medium.x86 device and has specified features

data "equinix_metal_facility" "test" {
code = "dc13"

features_required = ["backend_transfer", "global_ipv4"]

capacity {
plan = "c3.small.x86"
quantity = 2
}

capacity {
plan = "c3.medium.x86"
quantity = 1
}
}
11 changes: 11 additions & 0 deletions examples/data-sources/metal_gateway/example_1.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Create Metal Gateway for a VLAN with a private IPv4 block with 8 IP addresses

resource "equinix_metal_vlan" "test" {
description = "test VLAN in SV"
metro = "sv"
project_id = local.project_id
}

data "equinix_metal_gateway" "test" {
gateway_id = local.gateway_id
}
9 changes: 9 additions & 0 deletions examples/data-sources/metal_hardware_reservation/example_1.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// lookup by ID
data "equinix_metal_hardware_reservation" "example" {
id = "4347e805-eb46-4699-9eb9-5c116e6a0172"
}

// lookup by device ID
data "equinix_metal_hardware_reservation" "example_by_device_id" {
device_id = "ff85aa58-c106-4624-8f1c-7c64554047ea"
}
14 changes: 14 additions & 0 deletions examples/data-sources/metal_ip_block_ranges/example_1.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# List CIDR expressions of all the allocated IP block in you project.

# Declare your project ID
locals {
project_id = "<UUID_of_your_project>"
}

data "equinix_metal_ip_block_ranges" "test" {
project_id = local.project_id
}

output "out" {
value = data.equinix_metal_ip_block_ranges.test
}
9 changes: 9 additions & 0 deletions examples/data-sources/metal_metro/example_1.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Fetch a metro by code and show its ID

data "equinix_metal_metro" "sv" {
code = "sv"
}

output "id" {
value = data.equinix_metal_metro.sv.id
}
16 changes: 16 additions & 0 deletions examples/data-sources/metal_metro/example_2.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Verify that metro "sv" has capacity for provisioning 2 c3.small.x86
devices and 1 c3.medium.x86 device

data "equinix_metal_metro" "test" {
code = "sv"

capacity {
plan = "c3.small.x86"
quantity = 2
}

capacity {
plan = "c3.medium.x86"
quantity = 1
}
}
14 changes: 14 additions & 0 deletions examples/data-sources/metal_operating_system/example_1.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
data "equinix_metal_operating_system" "example" {
distro = "ubuntu"
version = "20.04"
provisionable_on = "c3.medium.x86"
}

resource "equinix_metal_device" "server" {
hostname = "tf.ubuntu"
plan = "c3.medium.x86"
metro = "ny"
operating_system = data.equinix_metal_operating_system.example.id
billing_cycle = "hourly"
project_id = local.project_id
}
8 changes: 8 additions & 0 deletions examples/data-sources/metal_organization/example_1.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Fetch a organization data and show projects which belong to it
data "equinix_metal_organization" "test" {
organization_id = local.org_id
}

output "projects_in_the_org" {
value = data.equinix_metal_organization.test.project_ids
}
21 changes: 21 additions & 0 deletions examples/data-sources/metal_plans/example_1.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Following example will select device plans which are under 2.5$ per hour, are available in metro 'da' (Dallas)
# OR 'sv' (Sillicon Valley) and sort it by the hourly price ascending.
data "equinix_metal_plans" "example" {
sort {
attribute = "pricing_hour"
direction = "asc"
}
filter {
attribute = "pricing_hour"
values = [2.5]
match_by = "less_than"
}
filter {
attribute = "available_in_metros"
values = ["da", "sv"]
}
}

output "plans" {
value = data.equinix_metal_plans.example.plans
}
22 changes: 22 additions & 0 deletions examples/data-sources/metal_plans/example_2.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Following example will select device plans with class containing string 'large', are available in metro 'da' (Dallas)
# AND 'sv' (Sillicon Valley), are elegible for spot_market deployments.
data "equinix_metal_plans" "example" {
filter {
attribute = "class"
values = ["large"]
match_by = "substring"
}
filter {
attribute = "deployment_types"
values = ["spot_market"]
}
filter {
attribute = "available_in_metros"
values = ["da", "sv"]
all = true
}
}

output "plans" {
value = data.equinix_metal_plans.example.plans
}
33 changes: 33 additions & 0 deletions examples/data-sources/metal_plans/example_3.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Following example will use equinix_metal_plans to select the cheapest plan available in metro 'sv' (Sillicon Valley)
data "equinix_metal_plans" "example" {
sort {
attribute = "pricing_hour"
direction = "asc"
}
filter {
attribute = "name"
values = ["c3.small.x86", "c3.medium.x86", "m3.large.x86"]
}
filter {
attribute = "available_in_metros"
values = ["sv"]
}
}

# This equinix_metal_device will use the first returned plan and the first metro in which that plan is available
# It will ignore future changes on plan and metro
resource "equinix_metal_device" "example" {
hostname = "example"
plan = data.equinix_metal_plans.example.plans[0].name
metro = data.equinix_metal_plans.example.plans[0].available_in_metros[0]
operating_system = "ubuntu_20_04"
billing_cycle = "hourly"
project_id = var.project_id

lifecycle {
ignore_changes = [
plan,
metro,
]
}
}
21 changes: 21 additions & 0 deletions examples/data-sources/metal_plans/example_4.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Following example uses a boolean variable that may eventually be set to you false when you update your equinix_metal_plans filter criteria because you need a device plan with a new feature.
variable "ignore_plans_metros_changes" {
type = bool
description = "If set to true, it will ignore plans or metros changes"
default = false
}

data "equinix_metal_plans" "example" {
// new search criteria
}

resource "equinix_metal_device" "example" {
// required device arguments

lifecycle {
ignore_changes = var.ignore_plans_metros_changes ? [
plan,
metro,
] : []
}
}
17 changes: 17 additions & 0 deletions examples/data-sources/metal_port/example_1.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
locals {
project_id = "<UUID_of_your_project>"
}

resource "equinix_metal_device" "test" {
hostname = "tfacc-test-device-port"
plan = "c3.medium.x86"
metro = "sv"
operating_system = "ubuntu_20_04"
billing_cycle = "hourly"
project_id = local.project_id
}

data "equinix_metal_port" "test" {
device_id = equinix_metal_device.test.id
name = "eth0"
}
32 changes: 32 additions & 0 deletions examples/data-sources/metal_precreated_ip_block/example_1.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Create device in your project and then assign /64 subnet from precreated block
# to the new device

# Declare your project ID
locals {
project_id = "<UUID_of_your_project>"
}

resource "equinix_metal_device" "web1" {
hostname = "web1"
plan = "c3.small.x86"
metro = "sv"
operating_system = "ubuntu_20_04"
billing_cycle = "hourly"
project_id = local.project_id

}

data "equinix_metal_precreated_ip_block" "test" {
metro = "sv"
project_id = local.project_id
address_family = 6
public = true
}

# The precreated IPv6 blocks are /56, so to get /64, we specify 8 more bits for network.
# The cirdsubnet interpolation will pick second /64 subnet from the precreated block.

resource "equinix_metal_ip_attachment" "from_ipv6_block" {
device_id = equinix_metal_device.web1.id
cidr_notation = cidrsubnet(data.equinix_metal_precreated_ip_block.test.cidr_notation, 8, 2)
}
Loading

0 comments on commit 32786f4

Please sign in to comment.