Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add examples for ntp and ptp precision time configurations #109

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,11 @@ terraform.rc

# Ignore IDE Files
.idea*

# Ignore Testing Output
*.xml
*.html
*.log

# Ignore OSX Generated Files
.DS_Store
11 changes: 11 additions & 0 deletions examples/port-2-precision-time-npt/README.md
Original file line number Diff line number Diff line change
@@ -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.
54 changes: 54 additions & 0 deletions examples/port-2-precision-time-npt/main.tf
Original file line number Diff line number Diff line change
@@ -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
}
}
}
}
7 changes: 7 additions & 0 deletions examples/port-2-precision-time-npt/outputs.tf
Original file line number Diff line number Diff line change
@@ -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
}
22 changes: 22 additions & 0 deletions examples/port-2-precision-time-npt/terraform.tfvars.example
Original file line number Diff line number Diff line change
@@ -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"
102 changes: 102 additions & 0 deletions examples/port-2-precision-time-npt/variables.tf
Original file line number Diff line number Diff line change
@@ -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 = []
}
9 changes: 9 additions & 0 deletions examples/port-2-precision-time-npt/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
terraform {
required_version = ">= 1.5.4"
required_providers {
equinix = {
source = "equinix/equinix"
version = ">= 2.3.1"
}
}
}
12 changes: 12 additions & 0 deletions examples/port-2-precision-time-ptp/README.md
Original file line number Diff line number Diff line change
@@ -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.

70 changes: 70 additions & 0 deletions examples/port-2-precision-time-ptp/main.tf
Original file line number Diff line number Diff line change
@@ -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
}
}
}
}
7 changes: 7 additions & 0 deletions examples/port-2-precision-time-ptp/outputs.tf
Original file line number Diff line number Diff line change
@@ -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
}
22 changes: 22 additions & 0 deletions examples/port-2-precision-time-ptp/terraform.tfvars.example
Original file line number Diff line number Diff line change
@@ -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 = 5
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"
Loading
Loading