github.com/koding/terraform@v0.6.4-0.20170608090606-5d7e0339779d/website/source/docs/providers/google/r/compute_router.html.markdown (about) 1 --- 2 layout: "google" 3 page_title: "Google: google_compute_router" 4 sidebar_current: "docs-google-compute-router" 5 description: |- 6 Manages a Cloud Router resource. 7 --- 8 9 # google\_compute\_router 10 11 Manages a Cloud Router resource. For more info, read the 12 [documentation](https://cloud.google.com/compute/docs/cloudrouter). 13 14 ## Example Usage 15 16 ```hcl 17 resource "google_compute_network" "foobar" { 18 name = "network-1" 19 } 20 21 resource "google_compute_subnetwork" "foobar" { 22 name = "subnet-1" 23 network = "${google_compute_network.foobar.self_link}" 24 ip_cidr_range = "10.0.0.0/16" 25 region = "us-central1" 26 } 27 28 resource "google_compute_address" "foobar" { 29 name = "vpn-gateway-1-address" 30 region = "${google_compute_subnetwork.foobar.region}" 31 } 32 33 resource "google_compute_vpn_gateway" "foobar" { 34 name = "vpn-gateway-1" 35 network = "${google_compute_network.foobar.self_link}" 36 region = "${google_compute_subnetwork.foobar.region}" 37 } 38 39 resource "google_compute_forwarding_rule" "foobar_esp" { 40 name = "vpn-gw-1-esp" 41 region = "${google_compute_vpn_gateway.foobar.region}" 42 ip_protocol = "ESP" 43 ip_address = "${google_compute_address.foobar.address}" 44 target = "${google_compute_vpn_gateway.foobar.self_link}" 45 } 46 47 resource "google_compute_forwarding_rule" "foobar_udp500" { 48 name = "vpn-gw-1-udp-500" 49 region = "${google_compute_forwarding_rule.foobar_esp.region}" 50 ip_protocol = "UDP" 51 port_range = "500-500" 52 ip_address = "${google_compute_address.foobar.address}" 53 target = "${google_compute_vpn_gateway.foobar.self_link}" 54 } 55 56 resource "google_compute_forwarding_rule" "foobar_udp4500" { 57 name = "vpn-gw-1-udp-4500" 58 region = "${google_compute_forwarding_rule.foobar_udp500.region}" 59 ip_protocol = "UDP" 60 port_range = "4500-4500" 61 ip_address = "${google_compute_address.foobar.address}" 62 target = "${google_compute_vpn_gateway.foobar.self_link}" 63 } 64 65 resource "google_compute_router" "foobar" { 66 name = "router-1" 67 region = "${google_compute_forwarding_rule.foobar_udp500.region}" 68 network = "${google_compute_network.foobar.self_link}" 69 70 bgp { 71 asn = 64512 72 } 73 } 74 75 resource "google_compute_vpn_tunnel" "foobar" { 76 name = "vpn-tunnel-1" 77 region = "${google_compute_forwarding_rule.foobar_udp4500.region}" 78 target_vpn_gateway = "${google_compute_vpn_gateway.foobar.self_link}" 79 shared_secret = "unguessable" 80 peer_ip = "8.8.8.8" 81 router = "${google_compute_router.foobar.name}" 82 } 83 84 resource "google_compute_router_interface" "foobar" { 85 name = "interface-1" 86 router = "${google_compute_router.foobar.name}" 87 region = "${google_compute_router.foobar.region}" 88 ip_range = "169.254.1.1/30" 89 vpn_tunnel = "${google_compute_vpn_tunnel.foobar.name}" 90 } 91 92 resource "google_compute_router_peer" "foobar" { 93 name = "peer-1" 94 router = "${google_compute_router.foobar.name}" 95 region = "${google_compute_router.foobar.region}" 96 peer_ip_address = "169.254.1.2" 97 peer_asn = 65513 98 advertised_route_priority = 100 99 interface = "${google_compute_router_interface.foobar.name}" 100 } 101 ``` 102 103 ## Argument Reference 104 105 The following arguments are supported: 106 107 * `name` - (Required) A unique name for the router, required by GCE. Changing 108 this forces a new router to be created. 109 110 * `network` - (Required) The name or resource link to the network this Cloud Router 111 will use to learn and announce routes. Changing this forces a new router to be created. 112 113 * `bgp` - (Required) BGP information specific to this router. 114 Changing this forces a new router to be created. 115 Structure is documented below. 116 117 - - - 118 119 * `description` - (Optional) A description of the resource. 120 Changing this forces a new router to be created. 121 122 * `project` - (Optional) The project in which the resource belongs. If it 123 is not provided, the provider project is used. 124 Changing this forces a new router to be created. 125 126 * `region` - (Optional) The region this router should sit in. If not specified, 127 the project region will be used. Changing this forces a new router to be 128 created. 129 130 - - - 131 132 The `bgp` block supports: 133 134 * `asn` - (Required) Local BGP Autonomous System Number (ASN). Must be an 135 RFC6996 private ASN. 136 137 ## Attributes Reference 138 139 In addition to the arguments listed above, the following computed attributes are 140 exported: 141 142 * `self_link` - The URI of the created resource. 143 144 ## Import 145 146 Routers can be imported using the `region` and `name`, e.g. 147 148 ``` 149 $ terraform import google_compute_router.router-1 us-central1/router-1 150 ``` 151