Skip to content

Commit

Permalink
Merge pull request #3 from vasubabu/vk_module_name
Browse files Browse the repository at this point in the history
Add provider equinix and module_name in Equinix Metal TF configs
  • Loading branch information
ocobles authored May 30, 2023
2 parents 7446140 + b2391f2 commit 6dab77a
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 42 deletions.
2 changes: 1 addition & 1 deletion examples/fabric-port-connection-to-sp/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
equinix = {
source = "equinix/equinix"
version = ">= 1.6.1"
version = "~> 1.14"
}
}
}
50 changes: 25 additions & 25 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
data "equinix_ecx_l2_sellerprofile" "seller" {
count = var.seller_profile_name != "" ? 1 : 0
name = var.seller_profile_name
count = var.seller_profile_name != "" ? 1 : 0
name = var.seller_profile_name
}

data "equinix_ecx_port" "primary" {
count = var.port_name != "" ? 1 : 0
name = var.port_name
count = var.port_name != "" ? 1 : 0
name = var.port_name
}

data "equinix_ecx_port" "secondary" {
count = var.secondary_port_name != "" ? 1 : 0
name = var.secondary_port_name
count = var.secondary_port_name != "" ? 1 : 0
name = var.secondary_port_name
}

data "equinix_ecx_port" "zside" {
count = var.zside_port_name != "" ? 1 : 0
name = var.zside_port_name
count = var.zside_port_name != "" ? 1 : 0
name = var.zside_port_name
}

locals {
locals {
primary_speed = ((var.speed == null || var.speed == 0) && var.seller_profile_name != "") ? [
for s in sort(formatlist("%03d", [
for band in data.equinix_ecx_l2_sellerprofile.seller[0].speed_band : band.speed
Expand All @@ -40,7 +40,7 @@ locals {
if metro.code == local.primary_seller_metro_code
][0] : var.seller_region : null

primary_name = var.name != "" ? var.name : upper(format("%s-%s-%s", split(" ", coalesce(
primary_name = var.name != "" ? var.name : upper(format("%s-%s-%s", split(" ", coalesce(
var.seller_profile_name, var.zside_port_name
))[0], local.primary_seller_metro_code, random_string.this.result))

Expand All @@ -49,7 +49,7 @@ locals {
if metro.name == title(var.secondary_seller_metro_name)
][0] : var.secondary_seller_metro_code

secondary_name = var.secondary_name != "" ? var.secondary_name : format("%s-SEC", local.primary_name)
secondary_name = var.secondary_name != "" ? var.secondary_name : format("%s-SEC", local.primary_name)
secondary_port_uuid = var.secondary_port_name != "" ? data.equinix_ecx_port.secondary[0].id : null
}

Expand Down Expand Up @@ -79,31 +79,31 @@ resource "equinix_ecx_l2_connection" "this" {
zside_vlan_stag = var.zside_vlan_stag != 0 ? var.zside_vlan_stag : null
zside_vlan_ctag = var.zside_vlan_ctag != 0 ? var.zside_vlan_ctag : null
zside_service_token = var.zside_service_token_id != "" ? var.zside_service_token_id : null

dynamic "additional_info" {
for_each = var.additional_info

content {
name = additional_info.value.name
name = additional_info.value.name
value = additional_info.value.value
}
}

dynamic "secondary_connection" {
for_each = var.redundancy_type == "REDUNDANT" ? [1] : []
content {
name = local.secondary_name
speed = var.secondary_speed != 0 ? var.secondary_speed : null
speed_unit = var.secondary_speed_unit != "" ? var.secondary_speed_unit : null
port_uuid = var.port_name != "" ? coalesce(local.secondary_port_uuid, data.equinix_ecx_port.primary[0].id) : null
vlan_stag = var.secondary_vlan_stag != 0 ? var.secondary_vlan_stag : null
vlan_ctag = var.secondary_vlan_ctag != 0 ? var.secondary_vlan_ctag : null
device_uuid = var.network_edge_id != "" ? coalesce(var.network_edge_secondary_id, var.network_edge_id) : null
device_interface_id = var.network_edge_secondary_interface_id != 0 ? var.network_edge_secondary_interface_id : null
service_token = var.service_token_id != "" && var.secondary_service_token_id != "" ? var.secondary_service_token_id : null
seller_metro_code = local.secondary_seller_metro_code != "" ? local.secondary_seller_metro_code : null
seller_region = var.secondary_seller_region != "" ? var.secondary_seller_region : null
authorization_key = var.secondary_seller_authorization_key != "" ? var.secondary_seller_authorization_key : null
name = local.secondary_name
speed = var.secondary_speed != 0 ? var.secondary_speed : null
speed_unit = var.secondary_speed_unit != "" ? var.secondary_speed_unit : null
port_uuid = var.port_name != "" ? coalesce(local.secondary_port_uuid, data.equinix_ecx_port.primary[0].id) : null
vlan_stag = var.secondary_vlan_stag != 0 ? var.secondary_vlan_stag : null
vlan_ctag = var.secondary_vlan_ctag != 0 ? var.secondary_vlan_ctag : null
device_uuid = var.network_edge_id != "" ? coalesce(var.network_edge_secondary_id, var.network_edge_id) : null
device_interface_id = var.network_edge_secondary_interface_id != 0 ? var.network_edge_secondary_interface_id : null
service_token = var.service_token_id != "" && var.secondary_service_token_id != "" ? var.secondary_service_token_id : null
seller_metro_code = local.secondary_seller_metro_code != "" ? local.secondary_seller_metro_code : null
seller_region = var.secondary_seller_region != "" ? var.secondary_seller_region : null
authorization_key = var.secondary_seller_authorization_key != "" ? var.secondary_seller_authorization_key : null
}
}
}
2 changes: 1 addition & 1 deletion outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ output "primary_connection" {

output "secondary_connection" {
description = "Secondary connection data."
value = try(equinix_ecx_l2_connection.this.secondary_connection[0], null)
value = try(equinix_ecx_l2_connection.this.secondary_connection[0], null)
}
26 changes: 13 additions & 13 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ variable "speed_unit" {
var.speed_unit == "" ? true : contains(["GB", "MB"], var.speed_unit)
)
error_message = "Valid values are (MB, GB)."
}
}
}

variable "seller_authorization_key" {
type = string
type = string
description = <<EOF
Text field used to authorize connection on the provider side. Value depends on a provider service
profile used for connection.
EOF
default = ""
default = ""
}

variable "seller_metro_code" {
Expand All @@ -65,7 +65,7 @@ variable "seller_metro_code" {
default = ""

validation {
condition = (
condition = (
var.seller_metro_code == "" ? true : can(regex("^[A-Z]{2}$", var.seller_metro_code))
)
error_message = "Valid metro code consits of two capital leters, i.e. 'FR', 'SV', 'DC'."
Expand Down Expand Up @@ -165,9 +165,9 @@ variable "named_tag" {
}

variable "additional_info" {
type = list(object({
name = string,
value = string
type = list(object({
name = string,
value = string
})
)
description = <<EOF
Expand Down Expand Up @@ -222,9 +222,9 @@ variable "redundancy_type" {
default = "SINGLE"

validation {
condition = (contains(["SINGLE", "REDUNDANT"], var.redundancy_type))
condition = (contains(["SINGLE", "REDUNDANT"], var.redundancy_type))
error_message = "Valid values for 'redundancy_type' are (SINGLE, REDUNDANT)."
}
}
}

variable "secondary_name" {
Expand Down Expand Up @@ -268,7 +268,7 @@ variable "secondary_speed_unit" {
var.secondary_speed_unit == "" ? true : contains(["GB", "MB"], var.secondary_speed_unit)
)
error_message = "Valid values are (MB, GB)."
}
}
}

variable "secondary_vlan_stag" {
Expand All @@ -290,12 +290,12 @@ variable "secondary_vlan_ctag" {
}

variable "secondary_seller_authorization_key" {
type = string
type = string
description = <<EOF
Text field used to authorize secondary connection on the provider side. Value depends on a
provider service profile used for connection.
EOF
default = ""
default = ""
}

variable "secondary_seller_metro_code" {
Expand All @@ -307,7 +307,7 @@ variable "secondary_seller_metro_code" {
default = ""

validation {
condition = (
condition = (
var.secondary_seller_metro_code == "" ? true : can(regex("^[A-Z]{2}$", var.secondary_seller_metro_code))
)
error_message = "Valid metro code consits of two capital leters, i.e. 'FR', 'SV', 'DC'."
Expand Down
7 changes: 5 additions & 2 deletions versions.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
terraform {
terraform {
required_version = ">= 0.13"

required_providers {
equinix = {
source = "equinix/equinix"
version = ">= 1.7.0"
version = "~> 1.14"
}
}
provider_meta "equinix" {
module_name = "equinix-fabric-connection"
}
}

0 comments on commit 6dab77a

Please sign in to comment.