# Cloud VPN Dynamic Module ## Example This example shows how to configure a single VPN tunnel using a couple of extra features - custom advertisement on the tunnel's BGP session; if custom advertisement is not needed, simply set the `bgp_peer_options` attribute to `null` - internally generated shared secret, which can be fetched from the module's `random_secret` output for reuse; a predefined secret can be used instead by assigning it to the `shared_secret` attribute ```hcl module "vpn-dynamic" { source = "./modules/net-vpn-dynamic" project_id = "my-project" region = "europe-west1" network = "my-vpc" name = "gateway-1" tunnels = { remote-1 = { bgp_peer = { address = "169.254.139.134" asn = 64513 } bgp_session_range = "169.254.139.133/30" ike_version = 2 peer_ip = "1.1.1.1" router = null shared_secret = null bgp_peer_options = { advertise_groups = ["ALL_SUBNETS"] advertise_ip_ranges = { "192.168.0.0/24" = "Advertised range description" } advertise_mode = "CUSTOM" route_priority = 1000 } } } } # tftest modules=1 resources=10 ``` ## Variables | name | description | type | required | default | |---|---|:---:|:---:|:---:| | [name](variables.tf#L29) | VPN gateway name, and prefix used for dependent resources. | string | ✓ | | | [network](variables.tf#L34) | VPC used for the gateway and routes. | string | ✓ | | | [project_id](variables.tf#L39) | Project where resources will be created. | string | ✓ | | | [region](variables.tf#L44) | Region used for resources. | string | ✓ | | | [gateway_address](variables.tf#L17) | Optional address assigned to the VPN gateway. Ignored unless gateway_address_create is set to false. | string | | "" | | [gateway_address_create](variables.tf#L23) | Create external address assigned to the VPN gateway. Needs to be explicitly set to false to use address in gateway_address variable. | bool | | true | | [route_priority](variables.tf#L49) | Route priority, defaults to 1000. | number | | 1000 | | [router_advertise_config](variables.tf#L55) | Router custom advertisement configuration, ip_ranges is a map of address ranges and descriptions. | object({…}) | | null | | [router_asn](variables.tf#L65) | Router ASN used for auto-created router. | number | | 64514 | | [router_create](variables.tf#L71) | Create router. | bool | | true | | [router_name](variables.tf#L77) | Router name used for auto created router, or to specify existing router to use. Leave blank to use VPN name for auto created router. | string | | "" | | [tunnels](variables.tf#L83) | VPN tunnel configurations, bgp_peer_options is usually null. | map(object({…})) | | {} | ## Outputs | name | description | sensitive | |---|---|:---:| | [address](outputs.tf#L17) | VPN gateway address. | | | [gateway](outputs.tf#L22) | VPN gateway resource. | | | [name](outputs.tf#L27) | VPN gateway name. | | | [random_secret](outputs.tf#L32) | Generated secret. | | | [router](outputs.tf#L38) | Router resource (only if auto-created). | | | [router_name](outputs.tf#L43) | Router name. | | | [self_link](outputs.tf#L48) | VPN gateway self link. | | | [tunnel_names](outputs.tf#L53) | VPN tunnel names. | | | [tunnel_self_links](outputs.tf#L61) | VPN tunnel self links. | | | [tunnels](outputs.tf#L69) | VPN tunnel resources. | |