Skip to content

Instantly share code, notes, and snippets.

resource "google_compute_router" "google_compute_router6" {
depends_on = [
google_compute_network.vpc_network
]
project = var.project
name = "cr-east-${google_compute_network.vpc_network["vpc006"].name}"
network = google_compute_network.vpc_network["vpc006"].name
bgp {
asn = 64514
advertise_mode = "DEFAULT"
resource "google_compute_subnetwork" "gke-network" {
project = var.project
name = "network010"
ip_cidr_range = "100.64.0.0/21"
region = data.google_compute_zones.available.region
network = google_compute_network.vpc_network["vpc001"].name
secondary_ip_range {
range_name = "network010-pods"
ip_cidr_range = "100.64.8.0/21"
}
resource "azurerm_resource_group" "east-app-vm1-rg" {
name = "east-app-vm1-rg"
location = var.region-b
}
resource "azurerm_public_ip" "east-app-vm1-pip" {
name = "east-app-vm1-pip"
resource_group_name = azurerm_resource_group.east-app-vm1-rg.name
location = var.region-b
allocation_method = "Static"
resource "azurerm_resource_group" "central-app-vm1-rg" {
name = "central-app-vm1-rg"
location = var.region-a
}
resource "azurerm_public_ip" "central-app-vm1-pip" {
name = "central-app-vm1-pip"
resource_group_name = azurerm_resource_group.central-app-vm1-rg.name
location = var.region-a
allocation_method = "Static"
resource "aviatrix_transit_gateway_peering" "central-east-peering" {
transit_gateway_name1 = module.east-transit.transit_gateway.id
transit_gateway_name2 = module.central-transit.transit_gateway.id
}
module "central-transit" {
source = "terraform-aviatrix-modules/mc-transit/aviatrix"
version = "v2.2.0"
cloud = var.cloud
cidr = var.cidr-region-a
region = var.region-a
account = var.account
enable_transit_firenet = true
enable_bgp_over_lan = true
insane_mode = false
module "ingress-spoke-central" {
source = "terraform-aviatrix-modules/mc-spoke/aviatrix"
version = "1.3.0"
account = var.account
cloud = var.cloud
name = "avx-${var.region-a}-ingress"
region = var.region-a
cidr = cidrsubnet("${trimsuffix(var.cidr-region-a, "23")}16", 8, 2)
inspection = true
transit_gw = module.central-transit.transit_gateway.gw_name
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "3.19.1"
}
aviatrix = {
source = "aviatrixsystems/aviatrix"
version = "~> 2.23.0"
}
variable "controller_ip" {
type = string
}
variable "username" {
type = string
}
variable "password" {
type = string
}
resource "aviatrix_gateway_dnat" "ingress-gw-east-dnat" {
gw_name = "ingress-gw-east"
dnat_policy {
dst_cidr = "${azurerm_public_ip.ingress-east-us-lb-pip.ip_address}/32"
dst_port = "80"
protocol = "tcp"
interface = "eth0"
connection = "None"
mark = "65535"
dnat_ips = azurerm_lb.east-us-lb.private_ip_address