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

Azure Terraform vWAN | Updated routing-intent deployment #344

Closed
wants to merge 2 commits into from
Closed
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
29 changes: 0 additions & 29 deletions terraform/azure/modules/add-routing-intent.py

This file was deleted.

77 changes: 38 additions & 39 deletions terraform/azure/nva-into-existing-hub/README.md

Large diffs are not rendered by default.

30 changes: 17 additions & 13 deletions terraform/azure/nva-into-existing-hub/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ data "http" "image-versions" {
}

locals {
image_versions = tolist([for version in jsondecode(data.http.image-versions.response_body).properties.availableVersions : version if substr(version, 0, 4) == substr(lower(var.os-version), 1, 4)])
routing_intent-internet-policy = {
image_versions = tolist([for version in jsondecode(data.http.image-versions.response_body).properties.availableVersions : version if substr(version, 0, 4) == substr(lower(var.os-version), 1, 4)])
routing_intent-internet-policy = {
"name": "InternetTraffic",
"destinations": [
"Internet"
Expand All @@ -55,9 +55,9 @@ locals {
],
"nextHop": "/subscriptions/${var.subscription_id}/resourcegroups/${var.nva-rg-name}/providers/Microsoft.Network/networkVirtualAppliances/${var.nva-name}"
}
routing-intent-policies = var.routing-intent-internet-traffic == "yes" ? (var.routing-intent-private-traffic == "yes" ? tolist([local.routing_intent-internet-policy, local.routing_intent-private-policy]) : tolist([local.routing_intent-internet-policy])) : (var.routing-intent-private-traffic == "yes" ? tolist([local.routing_intent-private-policy]) : [])
req_body = jsonencode({"properties": {"routingPolicies": local.routing-intent-policies}})
req_url = "https://management.azure.com/subscriptions/${var.subscription_id}/resourceGroups/${var.vwan-hub-resource-group}/providers/Microsoft.Network/virtualHubs/${var.vwan-hub-name}/routingIntent/hubRoutingIntent?api-version=2022-01-01"
routing-intent-policies = var.routing-intent-internet-traffic ? (var.routing-intent-private-traffic ? tolist([local.routing_intent-internet-policy, local.routing_intent-private-policy]) : tolist([local.routing_intent-internet-policy])) : (var.routing-intent-private-traffic ? tolist([local.routing_intent-private-policy]) : [])


}

//********************** Marketplace Terms & Solution Registration **************************//
Expand Down Expand Up @@ -182,14 +182,18 @@ resource "azurerm_managed_application" "nva" {

//********************** Routing Intent **************************//


data "external" "update-routing-intent" {
count = length(local.routing-intent-policies) != 0 ? 1 : 0
resource "azurerm_virtual_hub_routing_intent" "routing-intent" {
count = (var.routing-intent-internet-traffic || var.routing-intent-private-traffic) ? 1 : 0
depends_on = [azurerm_managed_application.nva]
program = ["python", "../modules/add-routing-intent.py", "${local.req_url}", "${local.req_body}", "${local.access_token}"]
}

output "api_request_result" {
value = length(local.routing-intent-policies) != 0 ? data.external.update-routing-intent[0].result : {routing-intent: "not changed"}
name = "hubRoutingIntent"
virtual_hub_id = data.azurerm_virtual_hub.vwan-hub.id
dynamic "routing_policy" {
for_each = local.routing-intent-policies
content {
name = routing_policy.value["name"]
destinations = routing_policy.value["destinations"]
next_hop = routing_policy.value["nextHop"]
}
}
}

4 changes: 2 additions & 2 deletions terraform/azure/nva-into-existing-hub/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ sic-key = "PLEASE ENTER SIC KEY"
ssh-public-key = "PLEASE ENTER SSH PUBLIC KEY" # "ssh-rsa xxxxxxxxxxxxxxxxxxxxxxxx imported-openssh-key"
bgp-asn = "PLEASE ENTER BGP AUTONOMOUS SYSTEM NUMBER" # "64512"
custom-metrics = "PLEASE ENTER yes or no" # "yes"
routing-intent-internet-traffic = "PLEASE ENTER yes or no" # "yes"
routing-intent-private-traffic = "PLEASE ENTER yes or no" # "yes"
routing-intent-internet-traffic = "PLEASE ENTER true or false" # true
routing-intent-private-traffic = "PLEASE ENTER true or false" # true
smart1-cloud-token-a = "PASTE TOKEN FROM SMART-1 CLOUD PORTAL FOR INSTANCE A OR LEAVE EMPTY DOUBLE QUOTES" # "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
smart1-cloud-token-b = "PASTE TOKEN FROM SMART-1 CLOUD PORTAL FOR INSTANCE B OR LEAVE EMPTY DOUBLE QUOTES" # "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
smart1-cloud-token-c = "PASTE TOKEN FROM SMART-1 CLOUD PORTAL FOR INSTANCE C OR LEAVE EMPTY DOUBLE QUOTES" # "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
Expand Down
14 changes: 8 additions & 6 deletions terraform/azure/nva-into-existing-hub/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,20 @@ variable "custom-metrics" {
}

variable "routing-intent-internet-traffic" {
default = "yes"
type = bool
default = true
validation {
condition = contains(["yes", "no"], var.routing-intent-internet-traffic)
error_message = "Valid options are string('yes' or 'no')"
condition = contains([true, false], var.routing-intent-internet-traffic)
error_message = "Valid options are true or false"
}
}

variable "routing-intent-private-traffic" {
default = "yes"
type = bool
default = true
validation {
condition = contains(["yes", "no"], var.routing-intent-private-traffic)
error_message = "Valid options are string('yes' or 'no')"
condition = contains([true, false], var.routing-intent-private-traffic)
error_message = "Valid options are true or false"
}
}

Expand Down
Loading
Loading