Skip to content

Commit 6b933be

Browse files
author
ocobles
committed
fixes #1
1 parent 0b876e8 commit 6b933be

File tree

6 files changed

+33
-35
lines changed

6 files changed

+33
-35
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ Run `terraform init -upgrade` and `terraform apply`.
5858

5959
| Name | Type |
6060
| :-----: | :------: |
61+
| [metal_project.this](https://registry.terraform.io/providers/equinix/metal/latest/docs/data-sources/project) | data source |
6162
| [metal_connection.this](https://registry.terraform.io/providers/equinix/metal/latest/docs/resources/device) | resource |
6263
| [equinix_ecx_l2_connection.this](https://registry.terraform.io/providers/equinix/equinix/latest/docs/resources/ecx_l2_connection) | resource |
6364
| [equinix_ecx_l2_sellerprofile.this](https://registry.terraform.io/providers/equinix/equinix/latest/docs/data-sources/ecx_l2_sellerprofile) | data source |

examples/device-redundant-connection/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Device Redundant Connection Example
22

3-
This example demonstrates usage of the Equinix terraform-metal-shared-connection module to create a redundant Equinix Fabric connection to interconnect your Equinix Metal resources in Silicon Valley to a single Network Edge device located in Dallas
3+
This example demonstrates usage of the Equinix terraform-metal-shared-connection module to create a redundant Equinix Fabric connection to interconnect your Equinix Metal resources in Silicon Valley to a single Network Edge device located in Dallas.
44

55
```
66
┌─────────────────┐
@@ -31,4 +31,3 @@ This example demonstrates usage of the Equinix terraform-metal-shared-connection
3131
terraform init
3232
terraform apply
3333
```
34-

examples/device-redundant-connection/main.tf

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,12 @@ module "connection" {
2525
source = "../../"
2626

2727
# required variables
28-
metal_organization_id = var.metal_organization_id
29-
metal_project_id = var.metal_project_id
30-
metal_connection_name = "example-metal-conn-side"
31-
metal_connection_metro = "SV"
32-
metal_connection_redundancy = "redundant"
33-
fabric_connection_name = "example-ef-conn-side"
34-
fabric_connection_speed = 50
35-
fabric_connection_speed_unit = "MB"
28+
metal_project_name = var.metal_project_name
29+
metal_connection_name = "example-connection"
30+
metal_connection_metro = "FR"
3631
fabric_connection_notification_users = ["example@equinix.com"]
3732

3833
# optional variables
39-
metal_connection_description = "Example description"
40-
metal_connection_tags = ["terraformed"]
34+
metal_connection_redundancy = "redundant"
4135
fabric_connection_device_id = var.fabric_device_id
42-
fabric_secondary_connection_device_id = var.fabric_device_id
4336
}

examples/device-redundant-connection/variables.tf

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,20 @@ variable "auth_token" {
22
type = string
33
description = "This is your Equinix Metal API Auth token."
44
}
5+
56
variable "fabric_client_id" {
67
type = string
78
description = "API Consumer Key available under 'My Apps' in Equinix developer portal."
89
}
10+
911
variable "fabric_client_secret" {
1012
type = string
1113
description = "API Consumer secret available under 'My Apps' in Equinix developer portal."
1214
}
1315

14-
variable "metal_organization_id" {
15-
type = string
16-
description = "ID of the organization responsible for the connection."
17-
}
18-
19-
variable "metal_project_id" {
16+
variable "metal_project_name" {
2017
type = string
21-
description = "ID of the project where the connection is scoped to, must be set for shared connection."
18+
description = "Name of the project where the connection is scoped to, must be set for shared connection."
2219
}
2320

2421
variable "fabric_device_id" {

main.tf

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
2+
data "metal_project" "this" {
3+
name = var.metal_project_name
4+
}
5+
16
resource "metal_connection" "this" {
27
name = var.metal_connection_name
3-
organization_id = var.metal_organization_id
4-
project_id = var.metal_project_id
8+
organization_id = data.metal_project.this.organization_id
9+
project_id = data.metal_project.this.project_id
510
metro = var.metal_connection_metro
611
redundancy = var.metal_connection_redundancy
712
type = "shared"
@@ -23,8 +28,12 @@ data "equinix_ecx_port" "secondary" {
2328
name = var.fabric_secondary_connection_port_name
2429
}
2530

31+
locals {
32+
fabric_connection_name = var.fabric_connection_name != null ? var.fabric_connection_name : var.metal_connection_name
33+
}
34+
2635
resource "equinix_ecx_l2_connection" "this" {
27-
name = var.fabric_connection_name
36+
name = local.fabric_connection_name
2837
profile_uuid = data.equinix_ecx_l2_sellerprofile.this.uuid
2938
speed = var.fabric_connection_speed
3039
speed_unit = var.fabric_connection_speed_unit
@@ -38,10 +47,10 @@ resource "equinix_ecx_l2_connection" "this" {
3847
dynamic "secondary_connection" {
3948
for_each = var.metal_connection_redundancy == "redundant" ? [1] : []
4049
content {
41-
name = "${var.fabric_connection_name}-sec"
50+
name = "${local.fabric_connection_name}-sec"
4251
port_uuid = var.fabric_secondary_connection_port_name != null ? data.equinix_ecx_port.secondary[0].id : null
4352
vlan_stag = var.fabric_secondary_connection_port_name != null ? var.fabric_secondary_connection_vlan_id : null
44-
device_uuid = var.fabric_secondary_connection_device_id
53+
device_uuid = var.fabric_secondary_connection_device_id != null ? var.fabric_secondary_connection_device_id : var.fabric_connection_device_id
4554
}
4655
}
4756
}

variables.tf

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
variable "metal_organization_id" {
1+
variable "metal_project_name" {
22
type = string
3-
description = "ID of the organization responsible for the connection."
4-
}
5-
6-
variable "metal_project_id" {
7-
type = string
8-
description = "ID of the project where the connection is scoped to, must be set for shared connection."
3+
description = "Name of the project where the connection is scoped to."
94
}
105

116
variable "metal_connection_name" {
127
type = string
13-
description = "Name of the connection resource."
8+
description = "Name of the connection resource that will be created."
149
}
1510

1611
variable "metal_connection_metro" {
@@ -25,6 +20,7 @@ variable "metal_connection_metro" {
2520
variable "metal_connection_redundancy" {
2621
type = string
2722
description = "Connection redundancy - redundant or primary."
23+
default = "primary"
2824
validation {
2925
condition = contains(["primary", "redundant"], var.metal_connection_redundancy)
3026
error_message = "Argument 'metal_connection_redundancy' must one of 'primary', or 'redundant'."
@@ -45,17 +41,20 @@ variable "metal_connection_tags" {
4541

4642
variable "fabric_connection_name" {
4743
type = string
48-
description = "Connection name. An alpha-numeric 24 characters string which can include only hyphens and underscores."
44+
description = "Name of the connection resource that will be created in Equinix Fabric side. If it is not defined, it will take the value in 'metal_connection_name' by default."
45+
default = null
4946
}
5047

5148
variable "fabric_connection_speed" {
5249
type = number
5350
description = "Speed/Bandwidth to be allocated to the connection - (MB or GB). "
51+
default = 50
5452
}
5553

5654
variable "fabric_connection_speed_unit" {
5755
type = string
5856
description = " Unit of the speed/bandwidth to be allocated to the connection."
57+
default = "MB"
5958
}
6059

6160
variable "fabric_connection_notification_users" {
@@ -94,7 +93,7 @@ variable "fabric_connection_vlan_id" {
9493

9594
variable "fabric_secondary_connection_device_id" {
9695
type = string
97-
description = "(Required when metal_connection_redundancy is 'redundant' and fabric_secondary_connection_port_name is not set) Unique identifier of the Network Edge virtual device from which the secondary connection would originate."
96+
description = "(Required when metal_connection_redundancy is 'redundant' and fabric_secondary_connection_port_name is not set) Unique identifier of the Network Edge virtual device from which the secondary connection would originate. If it is not defined, it will take the value in 'fabric_connection_device_id' by default."
9897
default = null
9998
}
10099

0 commit comments

Comments
 (0)