Add support for default-internet-gateway alias for google_compute_route (#9676)
This commit is contained in:
parent
aa63c367da
commit
45f441fdb4
|
@ -118,7 +118,11 @@ func resourceComputeRouteCreate(d *schema.ResourceData, meta interface{}) error
|
||||||
nextHopIp = v.(string)
|
nextHopIp = v.(string)
|
||||||
}
|
}
|
||||||
if v, ok := d.GetOk("next_hop_gateway"); ok {
|
if v, ok := d.GetOk("next_hop_gateway"); ok {
|
||||||
nextHopGateway = v.(string)
|
if v == "default-internet-gateway" {
|
||||||
|
nextHopGateway = fmt.Sprintf("projects/%s/global/gateways/default-internet-gateway", project)
|
||||||
|
} else {
|
||||||
|
nextHopGateway = v.(string)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if v, ok := d.GetOk("next_hop_vpn_tunnel"); ok {
|
if v, ok := d.GetOk("next_hop_vpn_tunnel"); ok {
|
||||||
nextHopVpnTunnel = v.(string)
|
nextHopVpnTunnel = v.(string)
|
||||||
|
|
|
@ -29,6 +29,25 @@ func TestAccComputeRoute_basic(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAccComputeRoute_defaultInternetGateway(t *testing.T) {
|
||||||
|
var route compute.Route
|
||||||
|
|
||||||
|
resource.Test(t, resource.TestCase{
|
||||||
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
Providers: testAccProviders,
|
||||||
|
CheckDestroy: testAccCheckComputeRouteDestroy,
|
||||||
|
Steps: []resource.TestStep{
|
||||||
|
resource.TestStep{
|
||||||
|
Config: testAccComputeRoute_defaultInternetGateway,
|
||||||
|
Check: resource.ComposeTestCheckFunc(
|
||||||
|
testAccCheckComputeRouteExists(
|
||||||
|
"google_compute_route.foobar", &route),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func testAccCheckComputeRouteDestroy(s *terraform.State) error {
|
func testAccCheckComputeRouteDestroy(s *terraform.State) error {
|
||||||
config := testAccProvider.Meta().(*Config)
|
config := testAccProvider.Meta().(*Config)
|
||||||
|
|
||||||
|
@ -89,3 +108,17 @@ resource "google_compute_route" "foobar" {
|
||||||
next_hop_ip = "10.0.1.5"
|
next_hop_ip = "10.0.1.5"
|
||||||
priority = 100
|
priority = 100
|
||||||
}`, acctest.RandString(10), acctest.RandString(10))
|
}`, acctest.RandString(10), acctest.RandString(10))
|
||||||
|
|
||||||
|
var testAccComputeRoute_defaultInternetGateway = fmt.Sprintf(`
|
||||||
|
resource "google_compute_network" "foobar" {
|
||||||
|
name = "route-test-%s"
|
||||||
|
ipv4_range = "10.0.0.0/16"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "google_compute_route" "foobar" {
|
||||||
|
name = "route-test-%s"
|
||||||
|
dest_range = "0.0.0.0/0"
|
||||||
|
network = "${google_compute_network.foobar.name}"
|
||||||
|
next_hop_gateway = "default-internet-gateway"
|
||||||
|
priority = 100
|
||||||
|
}`, acctest.RandString(10), acctest.RandString(10))
|
||||||
|
|
|
@ -43,8 +43,9 @@ The following arguments are supported:
|
||||||
|
|
||||||
- - -
|
- - -
|
||||||
|
|
||||||
* `next_hop_gateway` - (Optional) The name of the internet gateway to route
|
* `next_hop_gateway` - (Optional) The URL of the internet gateway to route
|
||||||
to if this route is matched.
|
to if this route is matched. The alias "default-internet-gateway" can also
|
||||||
|
be used.
|
||||||
|
|
||||||
* `next_hop_instance` - (Optional) The name of the VM instance to route to
|
* `next_hop_instance` - (Optional) The name of the VM instance to route to
|
||||||
if this route is matched.
|
if this route is matched.
|
||||||
|
|
Loading…
Reference in New Issue