Let route resource accept "description" attribute (#1088)

This commit is contained in:
Julien Phalip 2018-02-15 13:03:28 -08:00 committed by Nathan McKinley
parent c607b466f6
commit 7477c7482c
2 changed files with 11 additions and 0 deletions

View File

@ -83,6 +83,12 @@ func resourceComputeRoute() *schema.Resource {
ForceNew: true,
},
"description": &schema.Schema{
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"tags": &schema.Schema{
Type: schema.TypeSet,
Optional: true,
@ -162,6 +168,7 @@ func resourceComputeRouteCreate(d *schema.ResourceData, meta interface{}) error
// Build the route parameter
route := &compute.Route{
Name: d.Get("name").(string),
Description: d.Get("description").(string),
DestRange: d.Get("dest_range").(string),
Network: network.RelativeLink(),
NextHopInstance: nextHopInstance,
@ -209,6 +216,7 @@ func resourceComputeRouteRead(d *schema.ResourceData, meta interface{}) error {
}
d.Set("name", route.Name)
d.Set("description", route.Description)
d.Set("dest_range", route.DestRange)
d.Set("network", route.Network)
d.Set("priority", route.Priority)

View File

@ -26,6 +26,8 @@ func TestAccComputeRoute_basic(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckComputeRouteExists(
"google_compute_route.foobar", &route),
resource.TestMatchResourceAttr(
"google_compute_route.foobar", "description", regexp.MustCompile("This is a route")),
),
},
resource.TestStep{
@ -150,6 +152,7 @@ resource "google_compute_network" "foobar" {
resource "google_compute_route" "foobar" {
name = "route-test-%s"
description = "This is a route"
dest_range = "15.0.0.0/24"
network = "${google_compute_network.foobar.name}"
next_hop_ip = "10.0.1.5"