From 4e27c7aec9ce842f783fc93c78d06f98ab647b70 Mon Sep 17 00:00:00 2001 From: Tim Hogarty Date: Wed, 7 Aug 2024 14:45:35 -0700 Subject: [PATCH 1/2] Add examples for ntp and ptp precision time configurations --- .gitignore | 8 + examples/port-2-precision-time-npt/README.md | 11 ++ examples/port-2-precision-time-npt/main.tf | 54 +++++++ examples/port-2-precision-time-npt/outputs.tf | 7 + .../terraform.tfvars.example | 22 +++ .../port-2-precision-time-npt/variables.tf | 102 +++++++++++++ .../port-2-precision-time-npt/versions.tf | 9 ++ examples/port-2-precision-time-ptp/README.md | 12 ++ examples/port-2-precision-time-ptp/main.tf | 70 +++++++++ examples/port-2-precision-time-ptp/outputs.tf | 7 + .../terraform.tfvars.example | 22 +++ .../port-2-precision-time-ptp/variables.tf | 138 ++++++++++++++++++ .../port-2-precision-time-ptp/versions.tf | 9 ++ 13 files changed, 471 insertions(+) create mode 100644 examples/port-2-precision-time-npt/README.md create mode 100644 examples/port-2-precision-time-npt/main.tf create mode 100644 examples/port-2-precision-time-npt/outputs.tf create mode 100644 examples/port-2-precision-time-npt/terraform.tfvars.example create mode 100644 examples/port-2-precision-time-npt/variables.tf create mode 100644 examples/port-2-precision-time-npt/versions.tf create mode 100644 examples/port-2-precision-time-ptp/README.md create mode 100644 examples/port-2-precision-time-ptp/main.tf create mode 100644 examples/port-2-precision-time-ptp/outputs.tf create mode 100644 examples/port-2-precision-time-ptp/terraform.tfvars.example create mode 100644 examples/port-2-precision-time-ptp/variables.tf create mode 100644 examples/port-2-precision-time-ptp/versions.tf diff --git a/.gitignore b/.gitignore index 112b0b2c..b00d970d 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,11 @@ terraform.rc # Ignore IDE Files .idea* + +# Ignore Testing Output +*.xml +*.html +*.log + +# Ignore OSX Generated Files +.DS_Store diff --git a/examples/port-2-precision-time-npt/README.md b/examples/port-2-precision-time-npt/README.md new file mode 100644 index 00000000..c39b6701 --- /dev/null +++ b/examples/port-2-precision-time-npt/README.md @@ -0,0 +1,11 @@ +# Fabric Port to Equinix Precision Time Connection + NTP Time Service Configuration + +This example shows how to leverage the [Fabric Port Connection Module](https://registry.terraform.io/modules/equinix/fabric/equinix/latest/submodules/port-connection) +to create a Fabric Connection from a Fabric Port to Fabric Equinix Precision Time NTP Service Profile. +It also creates an NTP Configured Time Service on top of the created connection. + +It leverages the Equinix Terraform Provider, equinix_fabric_precision_time Terraform resource, and the Fabric Port Connection +Module to setup the connection based on the parameters you have provided to this example; or based on the pattern +you see used in this example it will allow you to create a more specific use case for your own needs. + +See example usage below for details on how to use this example. diff --git a/examples/port-2-precision-time-npt/main.tf b/examples/port-2-precision-time-npt/main.tf new file mode 100644 index 00000000..0cb484f6 --- /dev/null +++ b/examples/port-2-precision-time-npt/main.tf @@ -0,0 +1,54 @@ +provider "equinix" { + client_id = var.equinix_client_id + client_secret = var.equinix_client_secret +} + +module "create_port_2_precision_time_ntp_service_profile" { + source = "../../modules/port-connection" + + connection_name = var.connection_name + connection_type = var.connection_type + notifications_type = var.notifications_type + notifications_emails = var.notifications_emails + bandwidth = var.bandwidth + purchase_order_number = var.purchase_order_number + + # A-side + aside_port_name = var.aside_port_name + aside_vlan_tag = var.aside_vlan_tag + + # Z-side + zside_ap_type = var.zside_ap_type + zside_ap_profile_type = var.zside_ap_profile_type + zside_location = var.zside_location + zside_sp_name = var.zside_sp_name +} + +resource "equinix_fabric_precision_time" "ntp" { + type = "NTP" + name = var.precision_time_ntp_name + description = var.precision_time_ntp_description + package { + code = var.precision_time_ntp_package_code + } + connections { + uuid = module.create_port_2_precision_time_ntp_service_profile.primary_connection_id + } + ipv4 { + primary = var.precision_time_ntp_ipv4_primary + secondary = var.precision_time_ntp_ipv4_secondary + network_mask = var.precision_time_ntp_ipv4_network_mask + default_gateway = var.precision_time_ntp_ipv4_default_gateway + } + dynamic "advance_configuration" { + for_each = var.precision_time_ntp_advance_configuration + + content { + ntp { + type = advance_configuration.value.type + id = advance_configuration.value.id + password = advance_configuration.value.password + } + } + } +} diff --git a/examples/port-2-precision-time-npt/outputs.tf b/examples/port-2-precision-time-npt/outputs.tf new file mode 100644 index 00000000..cef605de --- /dev/null +++ b/examples/port-2-precision-time-npt/outputs.tf @@ -0,0 +1,7 @@ +output "port_2_npt_connection_id" { + value = module.create_port_2_precision_time_ntp_service_profile.primary_connection_id +} + +output "ntp_ept_resource_id" { + value = equinix_fabric_precision_time.ntp.id +} diff --git a/examples/port-2-precision-time-npt/terraform.tfvars.example b/examples/port-2-precision-time-npt/terraform.tfvars.example new file mode 100644 index 00000000..8f765b49 --- /dev/null +++ b/examples/port-2-precision-time-npt/terraform.tfvars.example @@ -0,0 +1,22 @@ +equinix_client_id = "MyEquinixClientId" +equinix_client_secret = "MyEquinixSecret" + +connection_name = "Port2PublicSP" +connection_type = "EVPL_VC" +notifications_type = "ALL" +notifications_emails = ["example@equinix.com"] +bandwidth = 1 +purchase_order_number = "1-323292" +aside_port_name = "sit-001-CX-SV1-NL-Dot1q-BO-10G-PRI-JP-34" +aside_vlan_tag = "1222" +zside_ap_type = "SP" +zside_ap_profile_type = "L2_PROFILE" +zside_location = "SV" +zside_sp_name = "Equinix Precision Time NTP UAT Global" +precision_time_ntp_name = "NTP_EPT" +precision_time_ntp_description = "NTP Configured Precision Time Service" +precision_time_ntp_package_code = "NTP_STANDARD" +precision_time_ntp_ipv4_primary = "192.168.254.241" +precision_time_ntp_ipv4_secondary = "192.168.254.242" +precision_time_ntp_ipv4_network_mask = "255.255.255.240" +precision_time_ntp_ipv4_default_gateway = "192.168.254.254" diff --git a/examples/port-2-precision-time-npt/variables.tf b/examples/port-2-precision-time-npt/variables.tf new file mode 100644 index 00000000..97f5a377 --- /dev/null +++ b/examples/port-2-precision-time-npt/variables.tf @@ -0,0 +1,102 @@ +variable "equinix_client_id" { + description = "Equinix client ID (consumer key), obtained after registering app in the developer platform" + type = string + sensitive = true +} +variable "equinix_client_secret" { + description = "Equinix client secret ID (consumer secret), obtained after registering app in the developer platform" + type = string + sensitive = true +} +variable "connection_name" { + description = "Connection name. An alpha-numeric 24 characters string which can include only hyphens and underscores" + type = string +} +variable "connection_type" { + description = "Defines the connection type like VG_VC, EVPL_VC, EPL_VC, EC_VC, IP_VC, ACCESS_EPL_VC" + type = string +} +variable "notifications_type" { + description = "Notification Type - ALL is the only type currently supported" + type = string + default = "ALL" +} +variable "notifications_emails" { + description = "Array of contact emails" + type = list(string) +} +variable "bandwidth" { + description = "Connection bandwidth in Mbps" + type = number +} +variable "purchase_order_number" { + description = "Purchase order number" + type = string + default = "" +} +variable "aside_port_name" { + description = "Equinix A-Side Port Name" + type = string +} +variable "aside_vlan_tag" { + description = "Vlan Tag information, outer vlanSTag for QINQ connections" + type = string +} +variable "aside_vlan_inner_tag" { + description = "Vlan Inner Tag information, inner vlanCTag for QINQ connections" + type = string + default = "" +} +variable "zside_ap_type" { + description = "Access point type - COLO, VD, VG, SP, IGW, SUBNET, GW" + type = string +} +variable "zside_ap_profile_type" { + description = "Service profile type - L2_PROFILE, L3_PROFILE, ECIA_PROFILE, ECMC_PROFILE" + type = string +} +variable "zside_location" { + description = "Access point metro code" + type = string +} +variable "zside_sp_name" { + description = "Equinix Service Profile Name" + type = string +} +variable "precision_time_ntp_name" { + description = "Precision Time Service Name" + type = string +} +variable "precision_time_ntp_description" { + description = "Precision Time Service Description" + type = string +} +variable "precision_time_ntp_package_code" { + description = "Precision Time Service Package Code" + type = string +} +variable "precision_time_ntp_ipv4_primary" { + description = "Precision Time Service Primary Ipv4 value" + type = string +} +variable "precision_time_ntp_ipv4_secondary" { + description = "Precision Time Service Secondary Ipv4 value" + type = string +} +variable "precision_time_ntp_ipv4_network_mask" { + description = "Precision Time Service Ipv4 Network Mask value" + type = string +} +variable "precision_time_ntp_ipv4_default_gateway" { + description = "Precision Time Service Ipv4 Default Gateway value" + type = string +} +variable "precision_time_ntp_advance_configuration" { + description = "Precision Time Service NTP Advance Configuration MD5 Details" + type = list(object({ + type = string + id = string + password = string + })) + default = [] +} diff --git a/examples/port-2-precision-time-npt/versions.tf b/examples/port-2-precision-time-npt/versions.tf new file mode 100644 index 00000000..0d5c9c01 --- /dev/null +++ b/examples/port-2-precision-time-npt/versions.tf @@ -0,0 +1,9 @@ +terraform { + required_version = ">= 1.5.4" + required_providers { + equinix = { + source = "equinix/equinix" + version = ">= 2.3.1" + } + } +} diff --git a/examples/port-2-precision-time-ptp/README.md b/examples/port-2-precision-time-ptp/README.md new file mode 100644 index 00000000..b54ccaac --- /dev/null +++ b/examples/port-2-precision-time-ptp/README.md @@ -0,0 +1,12 @@ +# Fabric Port to Equinix Precision Time Connection + PTP Time Service Configuration + +This example shows how to leverage the [Fabric Port Connection Module](https://registry.terraform.io/modules/equinix/fabric/equinix/latest/submodules/port-connection) +to create a Fabric Connection from a Fabric Port to Fabric Equinix Precision Time PTP Service Profile. +It also creates an PTP Configured Time Service on top of the created connection. + +It leverages the Equinix Terraform Provider, equinix_fabric_precision_time Terraform resource, and the Fabric Port Connection +Module to setup the connection based on the parameters you have provided to this example; or based on the pattern +you see used in this example it will allow you to create a more specific use case for your own needs. + +See example usage below for details on how to use this example. + diff --git a/examples/port-2-precision-time-ptp/main.tf b/examples/port-2-precision-time-ptp/main.tf new file mode 100644 index 00000000..56077045 --- /dev/null +++ b/examples/port-2-precision-time-ptp/main.tf @@ -0,0 +1,70 @@ +provider "equinix" { + client_id = var.equinix_client_id + client_secret = var.equinix_client_secret +} + +module "create_port_2_precision_time_ptp_service_profile" { + source = "../../modules/port-connection" + + connection_name = var.connection_name + connection_type = var.connection_type + notifications_type = var.notifications_type + notifications_emails = var.notifications_emails + bandwidth = var.bandwidth + purchase_order_number = var.purchase_order_number + + # A-side + aside_port_name = var.aside_port_name + aside_vlan_tag = var.aside_vlan_tag + + # Z-side + zside_ap_type = var.zside_ap_type + zside_ap_profile_type = var.zside_ap_profile_type + zside_location = var.zside_location + zside_sp_name = var.zside_sp_name +} + +resource "equinix_fabric_precision_time" "ptp" { + type = "PTP" + name = var.precision_time_ptp_name + description = var.precision_time_ptp_description + package { + code = var.precision_time_ptp_package_code + } + connections { + uuid = module.create_port_2_precision_time_ptp_service_profile.primary_connection_id + } + ipv4 { + primary = var.precision_time_ptp_ipv4_primary + secondary = var.precision_time_ptp_ipv4_secondary + network_mask = var.precision_time_ptp_ipv4_network_mask + default_gateway = var.precision_time_ptp_ipv4_default_gateway + } + dynamic "advance_configuration" { + for_each = ( + var.precision_time_advance_configuration_ptp_timescale != null || + var.precision_time_advance_configuration_ptp_domain != null || + var.precision_time_advance_configuration_ptp_priority_1 != null || + var.precision_time_advance_configuration_ptp_priority_2 != null || + var.precision_time_advance_configuration_ptp_log_announce_interval != null || + var.precision_time_advance_configuration_ptp_log_sync_interval != null || + var.precision_time_advance_configuration_ptp_log_delay_req_interval != null || + var.precision_time_advance_configuration_ptp_transport_mode != null || + var.precision_time_advance_configuration_ptp_grant_time != null ? + [1] : [] + ) + content { + ptp { + time_scale = var.precision_time_advance_configuration_ptp_timescale + domain = var.precision_time_advance_configuration_ptp_domain + priority_1 = var.precision_time_advance_configuration_ptp_priority_1 + priority_2 = var.precision_time_advance_configuration_ptp_priority_2 + log_announce_interval = var.precision_time_advance_configuration_ptp_log_announce_interval + log_sync_interval = var.precision_time_advance_configuration_ptp_log_sync_interval + log_delay_req_interval = var.precision_time_advance_configuration_ptp_log_delay_req_interval + transport_mode = var.precision_time_advance_configuration_ptp_transport_mode + grant_time = var.precision_time_advance_configuration_ptp_grant_time + } + } + } +} diff --git a/examples/port-2-precision-time-ptp/outputs.tf b/examples/port-2-precision-time-ptp/outputs.tf new file mode 100644 index 00000000..404b2091 --- /dev/null +++ b/examples/port-2-precision-time-ptp/outputs.tf @@ -0,0 +1,7 @@ +output "port_2_ept_connection_id" { + value = module.create_port_2_precision_time_ptp_service_profile.primary_connection_id +} + +output "ptp_ept_resource_id" { + value = equinix_fabric_precision_time.ptp.id +} diff --git a/examples/port-2-precision-time-ptp/terraform.tfvars.example b/examples/port-2-precision-time-ptp/terraform.tfvars.example new file mode 100644 index 00000000..79a6af9e --- /dev/null +++ b/examples/port-2-precision-time-ptp/terraform.tfvars.example @@ -0,0 +1,22 @@ +equinix_client_id = "MyEquinixClientId" +equinix_client_secret = "MyEquinixSecret" + +connection_name = "Port2PublicSP" +connection_type = "EVPL_VC" +notifications_type = "ALL" +notifications_emails = ["example@equinix.com"] +bandwidth = 50 +purchase_order_number = "1-323292" +aside_port_name = "sit-001-CX-SV1-NL-Dot1q-BO-10G-PRI-JP-34" +aside_vlan_tag = "1333" +zside_ap_type = "SP" +zside_ap_profile_type = "L2_PROFILE" +zside_location = "SV" +zside_sp_name = "Equinix Precision Time PTP Global UAT" +precision_time_ptp_name = "PTP_EPT" +precision_time_ptp_description = "PTP Configured Precision Time Service" +precision_time_ptp_package_code = "PTP_STANDARD" +precision_time_ptp_ipv4_primary = "192.168.254.241" +precision_time_ptp_ipv4_secondary = "192.168.254.242" +precision_time_ptp_ipv4_network_mask = "255.255.255.240" +precision_time_ptp_ipv4_default_gateway = "192.168.254.254" diff --git a/examples/port-2-precision-time-ptp/variables.tf b/examples/port-2-precision-time-ptp/variables.tf new file mode 100644 index 00000000..092249f7 --- /dev/null +++ b/examples/port-2-precision-time-ptp/variables.tf @@ -0,0 +1,138 @@ +variable "equinix_client_id" { + description = "Equinix client ID (consumer key), obtained after registering app in the developer platform" + type = string + sensitive = true +} +variable "equinix_client_secret" { + description = "Equinix client secret ID (consumer secret), obtained after registering app in the developer platform" + type = string + sensitive = true +} +variable "connection_name" { + description = "Connection name. An alpha-numeric 24 characters string which can include only hyphens and underscores" + type = string +} +variable "connection_type" { + description = "Defines the connection type like VG_VC, EVPL_VC, EPL_VC, EC_VC, IP_VC, ACCESS_EPL_VC" + type = string +} +variable "notifications_type" { + description = "Notification Type - ALL is the only type currently supported" + type = string + default = "ALL" +} +variable "notifications_emails" { + description = "Array of contact emails" + type = list(string) +} +variable "bandwidth" { + description = "Connection bandwidth in Mbps" + type = number +} +variable "purchase_order_number" { + description = "Purchase order number" + type = string + default = "" +} +variable "aside_port_name" { + description = "Equinix A-Side Port Name" + type = string +} +variable "aside_vlan_tag" { + description = "Vlan Tag information, outer vlanSTag for QINQ connections" + type = string +} +variable "aside_vlan_inner_tag" { + description = "Vlan Inner Tag information, inner vlanCTag for QINQ connections" + type = string + default = "" +} +variable "zside_ap_type" { + description = "Access point type - COLO, VD, VG, SP, IGW, SUBNET, GW" + type = string +} +variable "zside_ap_profile_type" { + description = "Service profile type - L2_PROFILE, L3_PROFILE, ECIA_PROFILE, ECMC_PROFILE" + type = string +} +variable "zside_location" { + description = "Access point metro code" + type = string +} +variable "zside_sp_name" { + description = "Equinix Service Profile Name" + type = string +} +variable "precision_time_ptp_name" { + description = "Precision Time Service Name" + type = string +} +variable "precision_time_ptp_description" { + description = "Precision Time Service Description" + type = string +} +variable "precision_time_ptp_package_code" { + description = "Precision Time Service Package Code" + type = string +} +variable "precision_time_ptp_ipv4_primary" { + description = "Precision Time Service Primary Ipv4 value" + type = string +} +variable "precision_time_ptp_ipv4_secondary" { + description = "Precision Time Service Secondary Ipv4 value" + type = string +} +variable "precision_time_ptp_ipv4_network_mask" { + description = "Precision Time Service Ipv4 Network Mask value" + type = string +} +variable "precision_time_ptp_ipv4_default_gateway" { + description = "Precision Time Service Ipv4 Default Gateway value" + type = string +} +variable "precision_time_advance_configuration_ptp_timescale" { + description = "Precision Time Service PTP Advance Configuration Time Scale" + type = string + default = null +} +variable "precision_time_advance_configuration_ptp_domain" { + description = "Precision Time Service PTP Advance Configuration Domain" + type = number + default = null +} +variable "precision_time_advance_configuration_ptp_priority_1" { + description = "Precision Time Service PTP Advance Configuration Priority 1" + type = number + default = null +} +variable "precision_time_advance_configuration_ptp_priority_2" { + description = "Precision Time Service PTP Advance Configuration Priority 2" + type = number + default = null +} +variable "precision_time_advance_configuration_ptp_log_announce_interval" { + description = "Precision Time Service PTP Advance Configuration log_announce_interval" + type = number + default = null +} +variable "precision_time_advance_configuration_ptp_log_sync_interval" { + description = "Precision Time Service PTP Advance Configuration log_sync_interval" + type = number + default = null +} +variable "precision_time_advance_configuration_ptp_log_delay_req_interval" { + description = "Precision Time Service PTP Advance Configuration log_delay_req_interval" + type = number + default = null +} +variable "precision_time_advance_configuration_ptp_transport_mode" { + description = "Precision Time Service PTP Advance Configuration transport_mode" + type = string + default = null +} +variable "precision_time_advance_configuration_ptp_grant_time" { + description = "Precision Time Service PTP Advance Configuration grant_time" + type = number + default = null +} diff --git a/examples/port-2-precision-time-ptp/versions.tf b/examples/port-2-precision-time-ptp/versions.tf new file mode 100644 index 00000000..0d5c9c01 --- /dev/null +++ b/examples/port-2-precision-time-ptp/versions.tf @@ -0,0 +1,9 @@ +terraform { + required_version = ">= 1.5.4" + required_providers { + equinix = { + source = "equinix/equinix" + version = ">= 2.3.1" + } + } +} From a8b5aba74641e579cf91cba0f18fd71f0c758550 Mon Sep 17 00:00:00 2001 From: Tim Hogarty Date: Wed, 7 Aug 2024 14:47:05 -0700 Subject: [PATCH 2/2] Update example bandwidth for ptp config example --- examples/port-2-precision-time-ptp/terraform.tfvars.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/port-2-precision-time-ptp/terraform.tfvars.example b/examples/port-2-precision-time-ptp/terraform.tfvars.example index 79a6af9e..aa74ecd8 100644 --- a/examples/port-2-precision-time-ptp/terraform.tfvars.example +++ b/examples/port-2-precision-time-ptp/terraform.tfvars.example @@ -5,7 +5,7 @@ connection_name = "Port2PublicSP" connection_type = "EVPL_VC" notifications_type = "ALL" notifications_emails = ["example@equinix.com"] -bandwidth = 50 +bandwidth = 5 purchase_order_number = "1-323292" aside_port_name = "sit-001-CX-SV1-NL-Dot1q-BO-10G-PRI-JP-34" aside_vlan_tag = "1333"