diff --git a/examples/multi_external_vpn_gateways/prod.tf b/examples/multi_external_vpn_gateways/prod.tf new file mode 100644 index 0000000..bd47c19 --- /dev/null +++ b/examples/multi_external_vpn_gateways/prod.tf @@ -0,0 +1,87 @@ +/** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +# Creating an external VPN gateway IP for DC1 +resource "google_compute_external_vpn_gateway" "external_gateway1" { + provider = google-beta + name = "vpn-peering-gw1" + project = var.prod_project_id + redundancy_type = "SINGLE_IP_INTERNALLY_REDUNDANT" + description = "My VPN peering gateway1" + + interface { + id = 0 + ip_address = "8.8.8.8" + } +} + +# Creating an external VPN gateway IP for DC2 +resource "google_compute_external_vpn_gateway" "external_gateway2" { + provider = google-beta + name = "vpn-peering-gw2" + project = var.prod_project_id + redundancy_type = "SINGLE_IP_INTERNALLY_REDUNDANT" + description = "My VPN peering gateway2" + + interface { + id = 0 + ip_address = "8.4.4.8" + } +} + +# In order to have successful setup, you need to configure the On-Premise +# VPN by this below tunnels configuration. + +module "vpn-ha-to-onprem" { + source = "../../modules/vpn_ha" + project_id = var.prod_project_id + region = var.region + network = var.prod_network_self_link + name = "prod-to-onprem" + router_asn = 64512 + + tunnels = { + # DC1 remote tunnel with specific external VPN gateway + remote-0 = { + bgp_peer = { + address = "169.254.1.2" + asn = 64515 + } + bgp_peer_options = null + bgp_session_range = "169.254.1.1/30" + ike_version = 2 + vpn_gateway_interface = 0 + peer_external_gateway_self_link = google_compute_external_vpn_gateway.external_gateway1.self_link + peer_external_gateway_interface = 0 + shared_secret = "Secret1" + } + + # DC2 remote tunnel with specific external VPN gateway + remote-1 = { + bgp_peer = { + address = "169.254.2.2" + asn = 64516 + } + bgp_peer_options = null + bgp_session_range = "169.254.2.1/30" + ike_version = 2 + vpn_gateway_interface = 1 + peer_external_gateway_self_link = google_compute_external_vpn_gateway.external_gateway2.self_link + peer_external_gateway_interface = 0 + shared_secret = "Secret2" + } + } +} diff --git a/examples/multi_external_vpn_gateways/variables.tf b/examples/multi_external_vpn_gateways/variables.tf new file mode 100644 index 0000000..c5542d7 --- /dev/null +++ b/examples/multi_external_vpn_gateways/variables.tf @@ -0,0 +1,31 @@ +/** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +variable "prod_project_id" { + description = "Production Project ID." + type = string +} + +variable "prod_network_self_link" { + description = "Production Network Self Link." + type = string +} + +variable "region" { + description = "Region." + type = string + default = "europe-west4" +} diff --git a/examples/multi_external_vpn_gateways/versions.tf b/examples/multi_external_vpn_gateways/versions.tf new file mode 100644 index 0000000..08b9215 --- /dev/null +++ b/examples/multi_external_vpn_gateways/versions.tf @@ -0,0 +1,19 @@ +/** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +terraform { + required_version = ">= 1.3" +}