diff --git a/examples/c8000v-ha/main.tf b/examples/c8000v-ha/main.tf index 3911f53..117bedb 100644 --- a/examples/c8000v-ha/main.tf +++ b/examples/c8000v-ha/main.tf @@ -26,7 +26,7 @@ module "c8000v_ha" { enabled = true metro_code = var.metro_code_secondary hostname = "c8000v-sec" - account_number = "664566" + account_number = "123456" additional_bandwidth = 50 acl_template_id = equinix_network_acl_template.c8000v_sec.id } diff --git a/examples/vmware-sdwan-ha/README.md b/examples/vmware-sdwan-ha/README.md new file mode 100644 index 0000000..3336b63 --- /dev/null +++ b/examples/vmware-sdwan-ha/README.md @@ -0,0 +1,65 @@ +# Network Edge VMWare Velocloud SDWAN HA Device Example + +This example demonstrates creation of Network Edge VMWare Velocloud SDWAN HA device. It will: + +- Create a ACL template +- Provision VMWare Velocloud SDWAN HA device + +## Usage + +To provision this example, you should clone the github repository and run terraform from within this directory: + +```bash +git clone https://github.com/equinix/terraform-equinix-network-edge.git +cd terraform-equinix-network-edge/examples/vmware-sdwan-ha +terraform init +terraform apply +``` + +Note that this example may create resources which cost money. Run 'terraform destroy' when you don't need these +resources. + + + + +## Requirements + +| Name | Version | +|---------------------------------------------------------------------------|---------| +| [terraform](#requirement\_terraform) | >= 1.3 | +| [equinix](#requirement\_equinix) | >= 1.34 | + +## Providers + +| Name | Version | +|---------------------------------------------------------------|---------| +| [equinix](#provider\_equinix) | >= 1.34 | + +## Modules + +| Name | Source | Version | +|-----------------------------------------------------------------------------------|----------------------------------|---------| +| [velocloud-sdwan](#module\_velocloud-sdwan) | ../../../modules/velocloud-sdwan | n/a | + +## Resources + +| Name | Type | +|----------------------------------------------------------------------------------------------------------------------------------------------------------------|----------| +| [equinix_network_acl_template.velocloud_sdwan_pri](https://registry.terraform.io/providers/equinix/equinix/latest/docs/resources/equinix_network_acl_template) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|-------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------|---------|:--------:| +| [equinix\_client\_id](#input\_equinix\_client\_id) | API Consumer Key available under 'My Apps' in developer portal. This argument can also be specified with the EQUINIX\_API\_CLIENTID shell environment variable. | `string` | n/a | yes | +| [equinix\_client\_secret](#input\_equinix\_client\_secret) | API Consumer secret available under 'My Apps' in developer portal. This argument can also be specified with the EQUINIX\_API\_CLIENTSECRET shell environment variable. | `string` | n/a | yes | +| [metro\_code\_primary](#input\_metro\_code\_primary) | Device location metro code for primary | `string` | n/a | yes | +| [metro\_code\_primary](#input\_metro\_code\_secondary) | Device location metro code for secondary | `string` | n/a | yes | + +## Outputs + +| Name | Description | +|----------------------------------------------------------------------------------|------------------------| +| [device\_details](#output\_device\_details) | Virtual device details | + + diff --git a/examples/vmware-sdwan-ha/main.tf b/examples/vmware-sdwan-ha/main.tf new file mode 100644 index 0000000..199d6b3 --- /dev/null +++ b/examples/vmware-sdwan-ha/main.tf @@ -0,0 +1,60 @@ +provider "equinix" { + client_id = var.equinix_client_id + client_secret = var.equinix_client_secret +} + +module "vmware_sdwan_ha" { + source = "../../modules/velocloud-sdwan" + name = "tf-vmware-sdwan" + metro_code = var.metro_code_primary + platform = "small" + account_number = "123456" + project_id = "e6be59d9-62c0-4140-aad6-150f0700203c" + software_package = "VMware-2" + version_number = "4.3.0" + term_length = 1 + notifications = ["test@test.com"] + additional_bandwidth = 100 + acl_template_id = equinix_network_acl_template.velocloud_sdwan_pri.id + vendor_configuration = { + activationKey = "xxxx-xxxx-xxxx-xxxx" + controllerFqdn = "test.test.test" + rootPassword = "xxxxxxxxxxx" + } + secondary = { + enabled = true + metro_code = var.metro_code_secondary + account_number = "123456" + name = "custom-secondary-name" + additional_bandwidth = 100 + acl_template_id = equinix_network_acl_template.velocloud_sdwan_sec.id + vendor_configuration = { + activationKey = "xxxx-xxxx-xxxx-xxxx" + controllerFqdn = "test.test.test" + rootPassword = "xxxxxxxxxxxx" + } + } +} + +resource "equinix_network_acl_template" "velocloud_sdwan_pri" { + name = "tf-velocloud-sdwan-pri" + description = "Primary velocloud sdwan ACL template" + project_id = "e6be59d9-62c0-4140-aad6-150f0700203c" + inbound_rule { + subnet = "12.16.103.0/24" + protocol = "TCP" + src_port = "any" + dst_port = "22" + } +} + +resource "equinix_network_acl_template" "velocloud_sdwan_sec" { + name = "tf-velocloud-sdwan-sec" + description = "Secondary VMWare SD-WAN ACL template" + inbound_rule { + subnet = "193.39.0.0/16" + protocol = "TCP" + src_port = "any" + dst_port = "22" + } +} diff --git a/examples/vmware-sdwan-ha/outputs.tf b/examples/vmware-sdwan-ha/outputs.tf new file mode 100644 index 0000000..ad61604 --- /dev/null +++ b/examples/vmware-sdwan-ha/outputs.tf @@ -0,0 +1,4 @@ +output "device_details" { + description = "Virtual device details" + value = module.vmware_sdwan_ha +} diff --git a/examples/vmware-sdwan-ha/variables.tf b/examples/vmware-sdwan-ha/variables.tf new file mode 100644 index 0000000..0acbd2f --- /dev/null +++ b/examples/vmware-sdwan-ha/variables.tf @@ -0,0 +1,19 @@ +variable "equinix_client_id" { + type = string + description = "API Consumer Key available under 'My Apps' in developer portal. This argument can also be specified with the EQUINIX_API_CLIENTID shell environment variable." +} + +variable "equinix_client_secret" { + type = string + description = "API Consumer secret available under 'My Apps' in developer portal. This argument can also be specified with the EQUINIX_API_CLIENTSECRET shell environment variable." +} + +variable "metro_code_primary" { + description = "Device location metro code" + type = string +} + +variable "metro_code_secondary" { + description = "Device location metro code" + type = string +} diff --git a/examples/vmware-sdwan-ha/versions.tf b/examples/vmware-sdwan-ha/versions.tf new file mode 100644 index 0000000..3fbce00 --- /dev/null +++ b/examples/vmware-sdwan-ha/versions.tf @@ -0,0 +1,9 @@ +terraform { + required_version = ">= 1.3" + required_providers { + equinix = { + source = "equinix/equinix" + version = ">= 1.34" + } + } +} diff --git a/examples/vmware-sdwan-single/README.md b/examples/vmware-sdwan-single/README.md new file mode 100644 index 0000000..98e90c5 --- /dev/null +++ b/examples/vmware-sdwan-single/README.md @@ -0,0 +1,64 @@ +# Network Edge VMWare Velocloud SDWAN Single Device Example + +This example demonstrates creation of Network Edge VMWare Velocloud SDWAN Single device. It will: + +- Create a ACL template +- Provision VMWare Velocloud SDWAN Single device + +## Usage + +To provision this example, you should clone the github repository and run terraform from within this directory: + +```bash +git clone https://github.com/equinix/terraform-equinix-network-edge.git +cd terraform-equinix-network-edge/examples/vmware-sdwan-single +terraform init +terraform apply +``` + +Note that this example may create resources which cost money. Run 'terraform destroy' when you don't need these +resources. + + + + +## Requirements + +| Name | Version | +|---------------------------------------------------------------------------|---------| +| [terraform](#requirement\_terraform) | >= 1.3 | +| [equinix](#requirement\_equinix) | >= 1.34 | + +## Providers + +| Name | Version | +|---------------------------------------------------------------|---------| +| [equinix](#provider\_equinix) | >= 1.34 | + +## Modules + +| Name | Source | Version | +|-----------------------------------------------------------------------------------|----------------------------------|---------| +| [velocloud-sdwan](#module\_velocloud-sdwan) | ../../../modules/velocloud-sdwan | n/a | + +## Resources + +| Name | Type | +|----------------------------------------------------------------------------------------------------------------------------------------------------------------|----------| +| [equinix_network_acl_template.velocloud_sdwan_pri](https://registry.terraform.io/providers/equinix/equinix/latest/docs/resources/equinix_network_acl_template) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|-------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------|---------|:--------:| +| [equinix\_client\_id](#input\_equinix\_client\_id) | API Consumer Key available under 'My Apps' in developer portal. This argument can also be specified with the EQUINIX\_API\_CLIENTID shell environment variable. | `string` | n/a | yes | +| [equinix\_client\_secret](#input\_equinix\_client\_secret) | API Consumer secret available under 'My Apps' in developer portal. This argument can also be specified with the EQUINIX\_API\_CLIENTSECRET shell environment variable. | `string` | n/a | yes | +| [metro\_code\_primary](#input\_metro\_code\_primary) | Device location metro code | `string` | n/a | yes | + +## Outputs + +| Name | Description | +|----------------------------------------------------------------------------------|------------------------| +| [device\_details](#output\_device\_details) | Virtual device details | + + diff --git a/examples/vmware-sdwan-single/main.tf b/examples/vmware-sdwan-single/main.tf new file mode 100644 index 0000000..aaa6b31 --- /dev/null +++ b/examples/vmware-sdwan-single/main.tf @@ -0,0 +1,36 @@ +provider "equinix" { + client_id = var.equinix_client_id + client_secret = var.equinix_client_secret +} + +module "vmware_sdwan_single" { + source = "../../modules/velocloud-sdwan" + name = "tf-vmware-sdwan" + account_number = "123456" + project_id = "e6be59d9-62c0-4140-aad6-150f0700203c" + metro_code = var.metro_code_primary + platform = "small" + version_number = "4.3.0" + software_package = "VMware-2" + term_length = 1 + notifications = ["test@test.com"] + additional_bandwidth = 100 + acl_template_id = equinix_network_acl_template.velocloud_sdwan_pri.id + vendor_configuration = { + activationKey = "xxxxx-xxxx-xxxx-xxxx" + controllerFqdn = "test.test.test" + rootPassword = "xxxxxxxxxxxx" + } +} + +resource "equinix_network_acl_template" "velocloud_sdwan_pri" { + name = "tf-velocloud-sdwan-pri" + description = "Primary velocloud sdwan ACL template" + project_id = "e6be59d9-62c0-4140-aad6-150f0700203c" + inbound_rule { + subnet = "12.16.103.0/24" + protocol = "TCP" + src_port = "any" + dst_port = "22" + } +} diff --git a/examples/vmware-sdwan-single/outputs.tf b/examples/vmware-sdwan-single/outputs.tf new file mode 100644 index 0000000..6b31d26 --- /dev/null +++ b/examples/vmware-sdwan-single/outputs.tf @@ -0,0 +1,4 @@ +output "device_details" { + description = "Virtual device details" + value = module.vmware_sdwan_single +} diff --git a/examples/vmware-sdwan-single/variables.tf b/examples/vmware-sdwan-single/variables.tf new file mode 100644 index 0000000..03464eb --- /dev/null +++ b/examples/vmware-sdwan-single/variables.tf @@ -0,0 +1,14 @@ +variable "equinix_client_id" { + type = string + description = "API Consumer Key available under 'My Apps' in developer portal. This argument can also be specified with the EQUINIX_API_CLIENTID shell environment variable." +} + +variable "equinix_client_secret" { + type = string + description = "API Consumer secret available under 'My Apps' in developer portal. This argument can also be specified with the EQUINIX_API_CLIENTSECRET shell environment variable." +} + +variable "metro_code_primary" { + description = "Device location metro code" + type = string +} diff --git a/examples/vmware-sdwan-single/versions.tf b/examples/vmware-sdwan-single/versions.tf new file mode 100644 index 0000000..3fbce00 --- /dev/null +++ b/examples/vmware-sdwan-single/versions.tf @@ -0,0 +1,9 @@ +terraform { + required_version = ">= 1.3" + required_providers { + equinix = { + source = "equinix/equinix" + version = ">= 1.34" + } + } +} diff --git a/modules/c8000v/variables.tf b/modules/c8000v/variables.tf index d19918a..766789b 100644 --- a/modules/c8000v/variables.tf +++ b/modules/c8000v/variables.tf @@ -145,7 +145,7 @@ variable "secondary" { error_message = "Key 'additional_bandwidth' has to be between 25 and 5001 Mbps." } validation { - condition = !try(var.secondary.enabled, false) || try(var.secondary.acl_template_id != null, true) + condition = !try(var.secondary.enabled, false) || try(var.secondary.acl_template_id != null, false) error_message = "Secondary Acl template is required." } } diff --git a/modules/velocloud-sdwan/README.md b/modules/velocloud-sdwan/README.md new file mode 100644 index 0000000..425c0a7 --- /dev/null +++ b/modules/velocloud-sdwan/README.md @@ -0,0 +1,92 @@ +# Network Edge Virtual Device VMWare Velocloud SDWAN SubModule + +The Network Edge Virtual Device VMWare Velocloud SDWAN Module will create VMWare Velocloud SDWAN devices on the Equinix +Network edge platform. + +1. Single or Non HA device +2. HA devices + +Please refer to the vmware-sdwan-* examples in this module's registry for more details on how to leverage the +submodule. + + + +## Equinix Network Edge Developer Documentation + +To see the documentation for the APIs that the Network Edge Terraform Provider is built on +and to learn how to procure your own Client_Id and Client_Secret follow the link below: +[Equinix Network Edge Developer Portal](https://developer.equinix.com/catalog/network-edgev1) + + + + +## Requirements + +| Name | Version | +|---------------------------------------------------------------------------|-----------| +| [terraform](#requirement\_terraform) | >= 1.3 | +| [equinix](#requirement\_equinix) | >= 1.34.0 | + +## Providers + +| Name | Version | +|---------------------------------------------------------------|-----------| +| [equinix](#provider\_equinix) | >= 1.34.0 | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|----------------------------------------------------------------------------------------------------------------------------------------------------------|-------------| +| [equinix_network_device.non_cluster](https://registry.terraform.io/providers/equinix/equinix/latest/docs/resources/equinix_network_device) | resource | +| [equinix_network_device_platform.this](https://registry.terraform.io/providers/equinix/equinix/latest/docs/data-sources/equinix_network_device_platform) | data source | +| [equinix_network_device_software.this](https://registry.terraform.io/providers/equinix/equinix/latest/docs/data-sources/equinix_network_device_software) | data source | +| [equinix_network_device_type.this](https://registry.terraform.io/providers/equinix/equinix/latest/docs/data-sources/equinix_network_device_type) | data source | + +## Inputs + +| Name | Description | Type | Default | Required | +|--------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------|-----------------------------------------|:--------:| +| [metro\_code](#input\_metro\_code) | Device location metro code. Please refer to [available metros](https://docs.equinix.com/en-us/Content/Interconnection/NE/user-guide/NE-metros.htm) | `string` | n/a | yes | +| [name](#input\_name) | Device name | `string` | n/a | yes | +| [version_number](#input\_version_number) | VNF image version. Please refer to [certified VNF versions](https://docs.equinix.com/en-us/Content/Interconnection/NE/user-guide/NE-certified-VNFs.htm) document for the supported versions. If this value is not passed most recent and stable version will be used by invoking [equinix_network_device_software](https://registry.terraform.io/providers/equinix/equinix/latest/docs/data-sources/equinix_network_device_software) data source | `string` | n/a | yes | +| [activationKey](#input\_activationKey) | Activation Key | `string` | n/a | yes | +| [controllerFqdn](#input\_controllerFqdn) | Controller FQDN | `string` | n/a | yes | +| [rootPassword](#input\_rootPassword) | root password | `string` | n/a | no | +| [notifications](#input\_notifications) | List of email addresses that will receive device status notifications | `list(string)` | n/a | yes | +| [platform](#input\_platform) | Device platform flavor that determines number of CPU cores and memory | `string` | n/a | yes | +| [project\_id](#input\_project\_id) | project\_id | `string` | n/a | yes | +| [software\_package](#input\_software_\package) | Device software package [equinix_network_device_software](https://registry.terraform.io/providers/equinix/equinix/latest/docs/data-sources/equinix_network_device_software) | `string` | n/a | yes | +| [ssh\_key](#input\_ssh\_key) | SSH public key for a device |
object({
userName = string
keyName = string
})
| n/a | yes | +| [term\_length](#input\_term\_length) | Term length in months | `number` | n/a | yes | +| [account\_number](#input\_account\_number) | Billing account number for a device | `string` | `0` | no | +| [acl\_template\_id](#input\_acl\_template\_id) | Identifier of an management ACL template that will be applied on a device | `string` | `""` | no | +| [additional\_bandwidth](#input\_additional\_bandwidth) | Additional internet bandwidth for a device | `number` | `0` | no | +| [connectivity](#input\_connectivity) | Parameter to identify internet access for device. Supported Values: INTERNET-ACCESS(default) or PRIVATE or INTERNET-ACCESS-WITH-PRVT-MGMT | `string` | `"INTERNET-ACCESS"` | no | +| [hostname](#input\_hostname) | Device hostname | `string` | `""` | no | +| [interface\_count](#input\_interface\_count) | Number of network interfaces on a device. If not specified, default number for a given device type will be used. | `number` | `10` | no | +| [acl\_template\_uuid](#input\_acl\_template\_uuid) | Identifier of an ACL template that will be applied on a device | `string` | `""` | no | +| [secondary](#input\_secondary) | Secondary device attributes | `map(any)` |
{
"enabled": false
}
| no | + +## Outputs + +| Name | Description | +|----------------------------------------------------------------------------------------|---------------------------------| +| [account\_number](#output\_account\_number) | Device billing account number | +| [cpu\_count](#output\_cpu\_count) | Device CPU cores count | +| [ibx](#output\_ibx) | Device IBX center | +| [id](#output\_id) | Device identifier | +| [interfaces](#output\_interfaces) | Device interfaces | +| [license\_status](#output\_license\_status) | Device license status | +| [memory](#output\_memory) | Device memory amount | +| [region](#output\_region) | Device region | +| [secondary](#output\_secondary) | Secondary device attributes | +| [software\_version](#output\_software\_version) | Device software version | +| [ssh\_ip\_address](#output\_ssh\_ip\_address) | Device SSH interface IP address | +| [ssh\_ip\_fqdn](#output\_ssh\_ip\_fqdn) | Device SSH interface FQDN | +| [status](#output\_status) | Device provisioning status | + + diff --git a/modules/velocloud-sdwan/main.tf b/modules/velocloud-sdwan/main.tf new file mode 100644 index 0000000..a51d618 --- /dev/null +++ b/modules/velocloud-sdwan/main.tf @@ -0,0 +1,58 @@ +data "equinix_network_device_type" "this" { + category = "SDWAN" + vendor = "VMware" +} + +data "equinix_network_device_platform" "this" { + device_type = data.equinix_network_device_type.this.code + flavor = var.platform +} + +data "equinix_network_device_software" "this" { + device_type = data.equinix_network_device_type.this.code + packages = [var.software_package] + stable = true + most_recent = true +} + +resource "equinix_network_device" "non_cluster" { + self_managed = true + byol = true + name = var.name + project_id = var.project_id + type_code = data.equinix_network_device_type.this.code + package_code = var.software_package + version = var.version_number != "" ? var.version_number : data.equinix_network_device_software.this.version + core_count = data.equinix_network_device_platform.this.core_count + metro_code = var.metro_code + connectivity = var.connectivity + account_number = var.account_number + term_length = var.term_length + interface_count = var.interface_count + notifications = var.notifications + acl_template_id = var.acl_template_id + additional_bandwidth = var.additional_bandwidth > 0 ? var.additional_bandwidth : null + vendor_configuration = { + activationKey = var.vendor_configuration.activationKey + controllerFqdn = var.vendor_configuration.controllerFqdn + rootPassword = var.vendor_configuration.rootPassword + } + + dynamic "secondary_device" { + for_each = var.secondary.enabled ? [1] : [] + content { + name = var.secondary.name + license_token = try(var.secondary.license_token, null) + metro_code = var.secondary.metro_code + account_number = var.secondary.account_number + notifications = var.notifications + acl_template_id = try(var.secondary.acl_template_id, null) + additional_bandwidth = var.additional_bandwidth > 0 ? var.additional_bandwidth : null + vendor_configuration = { + activationKey = var.secondary.vendor_configuration.activationKey + controllerFqdn = var.secondary.vendor_configuration.controllerFqdn + rootPassword = var.secondary.vendor_configuration.rootPassword + } + } + } +} diff --git a/modules/velocloud-sdwan/outputs.tf b/modules/velocloud-sdwan/outputs.tf new file mode 100644 index 0000000..0b6e747 --- /dev/null +++ b/modules/velocloud-sdwan/outputs.tf @@ -0,0 +1,76 @@ +output "id" { + description = "Device identifier" + value = equinix_network_device.non_cluster.uuid +} + +output "status" { + description = "Device provisioning status" + value = equinix_network_device.non_cluster.status +} + +output "license_status" { + description = "Device license status" + value = equinix_network_device.non_cluster.license_status +} + +output "account_number" { + description = "Device billing account number" + value = equinix_network_device.non_cluster.account_number +} + +output "cpu_count" { + description = "Device CPU cores count" + value = data.equinix_network_device_platform.this.core_count +} + +output "memory" { + description = "Device memory amount" + value = join(" ", [ + data.equinix_network_device_platform.this.memory, data.equinix_network_device_platform.this.memory_unit + ]) +} + +output "software_version" { + description = "Device software version" + value = data.equinix_network_device_software.this.version +} + +output "region" { + description = "Device region" + value = equinix_network_device.non_cluster.region +} + +output "ibx" { + description = "Device IBX center" + value = equinix_network_device.non_cluster.ibx +} + +output "ssh_ip_address" { + description = "Device SSH interface IP address" + value = equinix_network_device.non_cluster.ssh_ip_address +} + +output "ssh_ip_fqdn" { + description = "Device SSH interface FQDN" + value = equinix_network_device.non_cluster.ssh_ip_fqdn +} + +output "interfaces" { + description = "Device interfaces" + value = equinix_network_device.non_cluster.interface +} + +output "secondary" { + description = "Secondary device attributes" + value = var.secondary.enabled ? { + id = equinix_network_device.non_cluster.secondary_device[0].uuid + status = equinix_network_device.non_cluster.secondary_device[0].status + license_status = equinix_network_device.non_cluster.secondary_device[0].license_status + account_number = equinix_network_device.non_cluster.secondary_device[0].account_number + region = equinix_network_device.non_cluster.secondary_device[0].region + ibx = equinix_network_device.non_cluster.secondary_device[0].ibx + ssh_ip_address = equinix_network_device.non_cluster.secondary_device[0].ssh_ip_address + ssh_ip_fqdn = equinix_network_device.non_cluster.secondary_device[0].ssh_ip_fqdn + interfaces = equinix_network_device.non_cluster.secondary_device[0].interface + } : null +} diff --git a/modules/velocloud-sdwan/variables.tf b/modules/velocloud-sdwan/variables.tf new file mode 100644 index 0000000..20b57d3 --- /dev/null +++ b/modules/velocloud-sdwan/variables.tf @@ -0,0 +1,208 @@ +variable "metro_code" { + description = "Device location metro code" + type = string + validation { + condition = can(regex("^[A-Z]{2}$", var.metro_code)) + error_message = "Valid metro code consists of two capital letters, i.e. SV, DC." + } +} + +variable "project_id" { + description = "Unique identifier for the project resource where the device is scoped to" + type = string + default = null +} + +variable "version_number" { + description = "version number" + type = string + default = "" +} + +variable "account_number" { + description = "Billing account number for a device" + type = string + validation { + condition = var.account_number != null && length(var.account_number) > 0 + error_message = "Account number must not be blank or null." + } +} + +variable "platform" { + description = "Device platform flavor that determines number of CPU cores and memory" + type = string + validation { + condition = can(regex("^(small|medium|large)$", var.platform)) + error_message = "One of following platform flavors are supported: small, medium, large." + } +} + +variable "vendor_configuration" { + description = "Device specific vendor configurations." + type = object({ + activationKey = string + controllerFqdn = string + rootPassword = string + }) + + validation { + condition = try(length(var.vendor_configuration.activationKey) > 0, false) + error_message = "Activation Key has to be a non empty string." + } + + validation { + condition = can(regex("^[a-zA-Z_.+-]+.[a-zA-Z-]+.[a-zA-Z-.]$", var.vendor_configuration.controllerFqdn)) + error_message = "Controller FQDN has to be valid string. Example: www.equinix.com" + } + + validation { + condition = length(var.vendor_configuration.rootPassword) == 0 || (length(var.vendor_configuration.rootPassword) >= 8 && length(var.vendor_configuration.rootPassword) <= 128) + error_message = "Device root password has to be from 8 to 128 characters long." + } +} + +variable "software_package" { + description = "Device software package" + type = string + validation { + condition = can(regex("^(VMware-2|VMware-4|VMware-8)$", var.software_package)) + error_message = "One of following software packages are supported: VMware-2, VMware-4, VMware-8." + } +} + + +variable "name" { + description = "Device name" + type = string + validation { + condition = length(var.name) >= 3 && length(var.name) <= 50 + error_message = "Device name should consist of 3 to 50 characters." + } +} + +variable "term_length" { + description = "Term length in months" + type = number + validation { + condition = can(regex("^(1|12|24|36)$", var.term_length)) + error_message = "One of following term lengths are available: 1, 12, 24, 36 months." + } +} + +variable "notifications" { + description = "List of email addresses that will receive device status notifications" + type = list(string) + validation { + condition = length(var.notifications) > 0 + error_message = "Notification list cannot be empty." + } +} + +variable "acl_template_id" { + description = "Identifier of an ACL template that will be applied on a device" + type = string + validation { + condition = try(length(var.acl_template_id) > 0, false) + error_message = "Acl template is required." + } +} + +variable "connectivity" { + description = "Parameter to identify internet access for device. Supported Values: INTERNET-ACCESS(default) or PRIVATE or INTERNET-ACCESS-WITH-PRVT-MGMT" + type = string + default = "INTERNET-ACCESS" + validation { + condition = can(regex("^(INTERNET-ACCESS|PRIVATE|INTERNET-ACCESS-WITH-PRVT-MGMT)$", var.connectivity)) + error_message = "One of following values are supported: INTERNET-ACCESS, PRIVATE, INTERNET-ACCESS-WITH-PRVT-MGMT." + } +} + +variable "additional_bandwidth" { + description = "Additional internet bandwidth for a device" + type = number + default = 0 + validation { + condition = var.additional_bandwidth == 0 || (var.additional_bandwidth >= 25 && var.additional_bandwidth <= 5001) + error_message = "Additional internet bandwidth should be between 25 and 5001 Mbps." + } +} + +variable "interface_count" { + description = "Number of network interfaces on a device. If not specified, default number for a given device type will be used." + type = number + default = 8 + validation { + condition = can(regex("^(8)$", var.interface_count)) + error_message = "One of following values are supported: 8." + } +} + +variable "secondary" { + description = "Secondary device attributes" + type = object({ + enabled = bool + metro_code = string + name = string + acl_template_id = string + account_number = string + vendor_configuration = object({ + activationKey = string + controllerFqdn = string + rootPassword = string + }) + additional_bandwidth = optional(number) + }) + default = { + enabled = false + metro_code = null + name = null + acl_template_id = null + account_number = null + vendor_configuration = { + activationKey = null + controllerFqdn = null + rootPassword = null + } + additional_bandwidth = null + } + + validation { + condition = var.secondary.enabled ? can(regex("^[A-Z]{2}$", var.secondary.metro_code)) : true + error_message = "Key 'metro_code' has to be defined for secondary device. Valid metro code consists of two capital letters, i.e. SV, DC." + } + + validation { + condition = !try(var.secondary.enabled, false) || try(length(var.secondary.name) >= 3 && length(var.secondary.name) <= 50, false) + error_message = "Key 'name' has to be defined and should consist of 3 to 50 characters." + } + + validation { + condition = try(var.secondary.additional_bandwidth >= 25 && var.secondary.additional_bandwidth <= 5001, true) + error_message = "Key 'additional_bandwidth' has to be between 25 and 5001 Mbps." + } + + validation { + condition = !try(var.secondary.enabled, false) || try(length(var.secondary.account_number) > 0, false) + error_message = "Key 'account_number' is required for secondary device." + } + + validation { + condition = !try(var.secondary.enabled, false) || try(length(var.secondary.acl_template_id) > 0, false) + error_message = "Key 'acl_template_id' is required for secondary device." + } + + validation { + condition = var.secondary.enabled ? can(length(var.secondary.vendor_configuration.activationKey)) && length(var.secondary.vendor_configuration.activationKey) > 0 : true + error_message = "Secondary Activation Key has to be a non empty string." + } + + validation { + condition = var.secondary.enabled ? can(regex("^[a-zA-Z_.+-]+.[a-zA-Z-]+.[a-zA-Z-.]$", var.secondary.vendor_configuration.controllerFqdn)) : true + error_message = "Controller FQDN has to be valid string. Example: www.equinix.com" + } + + validation { + condition = var.secondary.enabled ? can(length(var.secondary.vendor_configuration.rootPassword)) && length(var.secondary.vendor_configuration.rootPassword) >= 8 && length(var.secondary.vendor_configuration.rootPassword) <= 128 : true + error_message = "Secondary Device root password has to be from 8 to 128 characters long." + } +} diff --git a/modules/velocloud-sdwan/versions.tf b/modules/velocloud-sdwan/versions.tf new file mode 100644 index 0000000..9cd09c8 --- /dev/null +++ b/modules/velocloud-sdwan/versions.tf @@ -0,0 +1,9 @@ +terraform { + required_version = ">= 1.3" + required_providers { + equinix = { + source = "equinix/equinix" + version = ">= 1.34.0" + } + } +}