Skip to content

Commit

Permalink
fixed pre-commit errors
Browse files Browse the repository at this point in the history
Signed-off-by: ocobleseqx <[email protected]>
  • Loading branch information
ocobleseqx committed Jan 16, 2024
1 parent f4e6d52 commit b4388ed
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ jobs:
signoff: true
delete-branch: true

# TODO(ocobleseqx): https://github.com/peter-evans/enable-pull-request-automerge
# TODO(ocobles): https://github.com/peter-evans/enable-pull-request-automerge
29 changes: 23 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
# OSX leaves these everywhere on SMB shares
._*

# OSX trash
**/.DS_Store
*.pyc*

# Emacs save files
*~
\#*\#
.\#*

# Vim-related files
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
*.un~
Session.vim
.netrwhist

# Local .terraform directories
**/.terraform/*
**/*/.terraform/*
.terraform*

# .tfstate files
*.tfstate
*.tfstate.*

.terraform.lock.hcl

# Crash log files
crash.log

Expand All @@ -22,14 +44,9 @@ override.tf.json
*_override.tf
*_override.tf.json

# Include override files you do wish to add to version control using negated pattern
#
# !example_override.tf
!.terraform.lock.hcl

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*
terraform.tfvars
**/terraform.tfvars
util/keys

*-kubeconfig
18 changes: 4 additions & 14 deletions examples/fabric-port-connection-to-sp/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ provider "equinix" {
client_secret = "someSecret"
}

module "equinix-fabric-connection" {
source = "equinix-labs/fabric-connection/equinix"
module "equinix_fabric_connection" {
# TEMPLATE: Replace this path with the Git repo path or Terraform Registry path
# source = "equinix-labs/fabric-connection/equinix"
source = "../.."

# required variables
notification_users = ["[email protected]"]
Expand All @@ -15,15 +17,3 @@ module "equinix-fabric-connection" {
seller_authorization_key = "AWS-account-ID"
network_edge_id = "NE-device-Uuid"
}

output "fabric_connection_id" {
value = module.equinix-fabric-connection.primary_connection.id
}

output "fabric_connection_status" {
value = module.equinix-fabric-connection.primary_connection.status
}

output "fabric_connection_provider_status" {
value = module.equinix-fabric-connection.primary_connection.provider_status
}
14 changes: 14 additions & 0 deletions examples/fabric-port-connection-to-sp/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
output "fabric_connection_id" {
description = "Primary connection id."
value = module.equinix_fabric_connection.primary_connection.id
}

output "fabric_connection_status" {
description = "Primary connection equinix status."
value = module.equinix_fabric_connection.primary_connection.status
}

output "fabric_connection_provider_status" {
description = "Primary connection provider status."
value = module.equinix_fabric_connection.primary_connection.provider_status
}
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/fabric-port-connection-to-sp/versions.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
terraform {
terraform {
required_version = ">= 0.13"

required_providers {
Expand Down
24 changes: 12 additions & 12 deletions locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,25 @@ locals {
}
) : var.notification_users_by_type

// TODO (ocobles) consider VG, IGW, SUBNET, GW use cases
// TODO (ocobles) replace aside_ap_type line below to support FCR
# TODO (ocobles) consider VG, IGW, SUBNET, GW use cases
# TODO (ocobles) replace aside_ap_type line below to support FCR
# aside_ap_type = var.network_edge_id != "" ? "VD" : var.cloud_router_id != "" ? "CLOUD_ROUTER" : "COLO"
aside_ap_type = var.network_edge_id != "" ? "VD" : "COLO"
// TODO (ocobles) replace zside_ap_type line below to support Fabric Network
# TODO (ocobles) replace zside_ap_type line below to support Fabric Network
# zside_ap_type = (var.zside_port_name != "" || var.zside_service_token_id != "") ? "COLO" : var.network_id != "" ? "NETWORK" : "SP"
zside_ap_type = (var.zside_port_name != "" || var.zside_service_token_id != "") ? "COLO" : "SP"
zside_ap_type = (var.zside_port_name != "" || var.zside_service_token_id != "") ? "COLO" : "SP"

link_protocol_type = var.port_name != "" ? one(data.equinix_fabric_ports.primary[0].data.0.encapsulation).type : ""
secondary_link_protocol_type = var.redundancy_type == "REDUNDANT" && var.port_name != "" ? one(data.equinix_fabric_ports.secondary[0].data.0.encapsulation).type : ""
zside_link_protocol_type = var.zside_port_name != "" ? one(data.equinix_fabric_ports.zside[0].data.0.encapsulation).type : ""
link_protocol_type = var.port_name != "" ? one(data.equinix_fabric_ports.primary[0].data[0].encapsulation).type : ""
secondary_link_protocol_type = var.redundancy_type == "REDUNDANT" && var.port_name != "" ? one(data.equinix_fabric_ports.secondary[0].data[0].encapsulation).type : ""
zside_link_protocol_type = var.zside_port_name != "" ? one(data.equinix_fabric_ports.zside[0].data[0].encapsulation).type : ""

connection_type = var.connection_type != "" ? var.connection_type : (
local.link_protocol_type == "UNTAGGEDEPL" && local.zside_link_protocol_type == "UNTAGGEDEPL"
local.link_protocol_type == "UNTAGGEDEPL" && local.zside_link_protocol_type == "UNTAGGEDEPL"
) ? "EPL_VC" : (
(local.link_protocol_type == "QINQ" && local.zside_link_protocol_type == "UNTAGGEDEPL") ||
(local.link_protocol_type == "UNTAGGEDEPL" && local.zside_link_protocol_type == "QINQ")
) ? "ACCESS_EPL_VC" : "EVPL_VC" # Default value EVPL_VC should cover use cases: COLO2COLO, COLO2SP, VD2COLO, VD2COLO(TOKEN), COLO(TOKEN)2SP
# // TODO (ocobles) replace last ACCESS_EPL_VC condition with below code to support FCR and Fabric Network
(local.link_protocol_type == "QINQ" && local.zside_link_protocol_type == "UNTAGGEDEPL") ||
(local.link_protocol_type == "UNTAGGEDEPL" && local.zside_link_protocol_type == "QINQ")
) ? "ACCESS_EPL_VC" : "EVPL_VC" # Default value EVPL_VC should cover use cases: COLO2COLO, COLO2SP, VD2COLO, VD2COLO(TOKEN), COLO(TOKEN)2SP
# # TODO (ocobles) replace last ACCESS_EPL_VC condition with below code to support FCR and Fabric Network
# # ) ? "ACCESS_EPL_VC" : (
# # local.aside_ap_type == "CLOUD_ROUTER" && (local.zside_ap_type == "COLO" || local.zside_ap_type == "SP")
# # ) ? "IP_VC" : (
Expand Down
52 changes: 26 additions & 26 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ data "equinix_fabric_service_profiles" "sp" {
filter {
property = "/name"
operator = "="
values = [var.seller_profile_name]
values = [var.seller_profile_name]
}
}

Expand Down Expand Up @@ -37,14 +37,14 @@ resource "random_string" "this" {
special = false
}

resource "equinix_fabric_connection" "primary"{
resource "equinix_fabric_connection" "primary" {
name = var.redundancy_type == "REDUNDANT" && var.secondary_name == "" && var.name == "" ? format("%s-PRI", local.primary_name) : local.primary_name
type = local.connection_type

dynamic "notifications" {
for_each = local.notification_users_by_type
content {
type = notifications.key
type = notifications.key
emails = notifications.value
}
}
Expand All @@ -57,11 +57,11 @@ resource "equinix_fabric_connection" "primary"{
bandwidth = local.bandwidth

redundancy {
priority= "PRIMARY"
priority = "PRIMARY"
}

order {
purchase_order_number= var.purchase_order_number != "" ? var.purchase_order_number : null
purchase_order_number = var.purchase_order_number != "" ? var.purchase_order_number : null
}

a_side {
Expand Down Expand Up @@ -91,15 +91,15 @@ resource "equinix_fabric_connection" "primary"{
for_each = var.port_name != "" ? [1] : []
content {
type = local.link_protocol_type == "UNTAGGEDEPL" ? "UNTAGGED" : local.link_protocol_type
vlan_tag = local.link_protocol_type == "DOT1Q" ? var.vlan_stag : null // vlanTag value specified for DOT1Q connections
vlan_s_tag = local.link_protocol_type == "QINQ" ? var.vlan_stag : null // vlanSTag value specified for QINQ connections
vlan_tag = local.link_protocol_type == "DOT1Q" ? var.vlan_stag : null # vlanTag value specified for DOT1Q connections
vlan_s_tag = local.link_protocol_type == "QINQ" ? var.vlan_stag : null # vlanSTag value specified for QINQ connections

# This is adding ctag for any connection that is QINQ Aside AND not COLO on Zside OR when COLO on Zside is not QINQ Encapsulation Type
vlan_c_tag = local.link_protocol_type == "QINQ" && (local.zside_ap_type != "COLO" || (local.zside_ap_type == "COLO" ? local.zside_link_protocol_type != "QINQ" : false)) ? var.vlan_ctag : null
}
}

// TODO (ocobles) support FCR
# TODO (ocobles) support FCR
# dynamic "router" {
# for_each = var.cloud_router_id != "" ? [var.cloud_router_id] : []
# content {
Expand All @@ -112,12 +112,12 @@ resource "equinix_fabric_connection" "primary"{
content {
type = "EDGE"
uuid = virtual_device.value
// TODO (ocobles) allow use name instead of uuid
// name = var.network_edge_name
# TODO (ocobles) allow use name instead of uuid
# name = var.network_edge_name
}
}

// Virtual device interface
# Virtual device interface
dynamic "interface" {
for_each = var.network_edge_interface_id != 0 ? [var.network_edge_interface_id] : []
content {
Expand All @@ -141,9 +141,9 @@ resource "equinix_fabric_connection" "primary"{
dynamic "access_point" {
for_each = var.zside_service_token_id == "" ? [1] : []
content {
type = local.zside_ap_type
type = local.zside_ap_type
authentication_key = var.seller_authorization_key != "" ? var.seller_authorization_key : null
seller_region = local.primary_region
seller_region = local.primary_region

dynamic "profile" {
for_each = var.seller_profile_name != "" ? [1] : []
Expand All @@ -160,7 +160,7 @@ resource "equinix_fabric_connection" "primary"{
}
}

// TODO (ocobles) support Fabric Network
# TODO (ocobles) support Fabric Network
# dynamic "network" {
# for_each = var.network_id != "" ? [var.network_id] : []
# content {
Expand Down Expand Up @@ -190,7 +190,7 @@ resource "equinix_fabric_connection" "primary"{
}

# SECONDARY CONNECTION
resource "equinix_fabric_connection" "secondary"{
resource "equinix_fabric_connection" "secondary" {
count = var.redundancy_type == "REDUNDANT" ? 1 : 0

name = local.secondary_name
Expand All @@ -199,7 +199,7 @@ resource "equinix_fabric_connection" "secondary"{
dynamic "notifications" {
for_each = local.notification_users_by_type
content {
type = notifications.key
type = notifications.key
emails = notifications.value
}
}
Expand All @@ -217,7 +217,7 @@ resource "equinix_fabric_connection" "secondary"{
}

order {
purchase_order_number= var.purchase_order_number != "" ? var.purchase_order_number : null
purchase_order_number = var.purchase_order_number != "" ? var.purchase_order_number : null
}

a_side {
Expand Down Expand Up @@ -247,15 +247,15 @@ resource "equinix_fabric_connection" "secondary"{
for_each = var.port_name != "" ? [1] : []
content {
type = local.secondary_link_protocol_type == "UNTAGGEDEPL" ? "UNTAGGED" : local.secondary_link_protocol_type
vlan_tag = local.secondary_link_protocol_type == "DOT1Q" ? var.secondary_vlan_stag : null // vlanTag value specified for DOT1Q connections
vlan_s_tag = local.secondary_link_protocol_type == "QINQ" ? var.secondary_vlan_stag : null // vlanSTag value specified for QINQ connections
vlan_tag = local.secondary_link_protocol_type == "DOT1Q" ? var.secondary_vlan_stag : null # vlanTag value specified for DOT1Q connections
vlan_s_tag = local.secondary_link_protocol_type == "QINQ" ? var.secondary_vlan_stag : null # vlanSTag value specified for QINQ connections

# This is adding ctag for any connection that is QINQ Aside AND not COLO on Zside OR when COLO on Zside is not QINQ Encapsulation Type
vlan_c_tag = local.secondary_link_protocol_type == "QINQ" && (local.zside_ap_type != "COLO" || (local.zside_ap_type == "COLO" ? local.zside_link_protocol_type != "QINQ" : false)) ? var.secondary_vlan_ctag : null
}
}

// TODO (ocobles) support FCR
# TODO (ocobles) support FCR
# dynamic "router" {
# for_each = var.cloud_router_id != "" ? [coalesce(var.cloud_router_secondary_id, var.cloud_router_id)] : []
# content {
Expand All @@ -268,12 +268,12 @@ resource "equinix_fabric_connection" "secondary"{
content {
type = "EDGE"
uuid = virtual_device.value
// TODO (ocobles) allow use name instead of uuid
// name = var.network_edge_name
# TODO (ocobles) allow use name instead of uuid
# name = var.network_edge_name
}
}

// Virtual device interface
# Virtual device interface
dynamic "interface" {
for_each = var.network_edge_secondary_interface_id != 0 ? [var.network_edge_secondary_interface_id] : []
content {
Expand All @@ -297,9 +297,9 @@ resource "equinix_fabric_connection" "secondary"{
dynamic "access_point" {
for_each = var.secondary_zside_service_token_id == "" ? [1] : []
content {
type = local.zside_ap_type
type = local.zside_ap_type
authentication_key = var.secondary_seller_authorization_key != "" ? var.secondary_seller_authorization_key : null
seller_region = var.secondary_seller_region != "" ? var.secondary_seller_region : local.primary_region
seller_region = var.secondary_seller_region != "" ? var.secondary_seller_region : local.primary_region

dynamic "profile" {
for_each = var.seller_profile_name != "" ? [1] : []
Expand All @@ -316,7 +316,7 @@ resource "equinix_fabric_connection" "secondary"{
}
}

// TODO (ocobles) support Fabric Network
# TODO (ocobles) support Fabric Network
# dynamic "network" {
# for_each = var.network_id != "" ? [var.network_id] : []
# content {
Expand Down
8 changes: 5 additions & 3 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ variable "speed" {
default = 0
}

# tflint-ignore: terraform_unused_declarations
variable "speed_unit" {
type = string
description = <<EOF
Expand Down Expand Up @@ -134,15 +135,15 @@ variable "notification_users_by_type" {
default = {}

validation {
condition = alltrue([
condition = alltrue([
for k, _ in var.notification_users_by_type :
contains([
"ALL",
"BANDWIDTH_ALERT",
"CONNECTION_APPROVAL",
"PROFILE_LIFECYCLE",
"SALES_REP_NOTIFICATIONS"
], k )
], k)
])
error_message = <<EOF
Valid map keys are (ALL, BANDWIDTH_ALERT, CONNECTION_APPROVAL, PROFILE_LIFECYCLE,
Expand Down Expand Up @@ -302,6 +303,7 @@ variable "secondary_speed" {
default = 0
}

# tflint-ignore: terraform_unused_declarations
variable "secondary_speed_unit" {
type = string
description = <<EOF
Expand Down Expand Up @@ -419,7 +421,7 @@ variable "secondary_zside_service_token_id" {
default = ""
}

// TODO (ocobles) add code below to support Fabric Network and FCR
# TODO (ocobles) add code below to support Fabric Network and FCR

# variable "network_id" {
# type = string
Expand Down
4 changes: 4 additions & 0 deletions versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ terraform {
source = "equinix/equinix"
version = "~> 1.14"
}
random = {
source = "hashicorp/random"
version = "3.6.0"
}
}
provider_meta "equinix" {
module_name = "equinix-fabric-connection"
Expand Down

0 comments on commit b4388ed

Please sign in to comment.