Skip to content

Commit

Permalink
use proxy_id and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
enxebre committed Oct 5, 2017
1 parent cc6eaef commit d8e2fcd
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 13 deletions.
14 changes: 6 additions & 8 deletions google/resource_compute_target_tcp_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func resourceComputeTargetTcpProxy() *schema.Resource {
ForceNew: true,
},

"id": &schema.Schema{
"proxy_id": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
Expand Down Expand Up @@ -66,12 +66,10 @@ func resourceComputeTargetTcpProxyCreate(d *schema.ResourceData, meta interface{
}

proxy := &compute.TargetTcpProxy{
Name: d.Get("name").(string),
Service: d.Get("backend_service").(string),
}

if v, ok := d.GetOk("description"); ok {
proxy.Description = v.(string)
Name: d.Get("name").(string),
Service: d.Get("backend_service").(string),
ProxyHeader: d.Get("proxy_header").(string),
Description: d.Get("description").(string),
}

log.Printf("[DEBUG] TargetTcpProxy insert request: %#v", proxy)
Expand Down Expand Up @@ -140,7 +138,7 @@ func resourceComputeTargetTcpProxyRead(d *schema.ResourceData, meta interface{})
}

d.Set("self_link", proxy.SelfLink)
d.Set("id", strconv.FormatUint(proxy.Id, 10))
d.Set("proxy_id", strconv.FormatUint(proxy.Id, 10))

return nil
}
Expand Down
45 changes: 41 additions & 4 deletions google/resource_compute_target_tcp_proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/hashicorp/terraform/terraform"
)

func TestAccComputeTargeTcpProxy_basic(t *testing.T) {
func TestAccComputeTargetTcpProxy_basic(t *testing.T) {
target := fmt.Sprintf("ttcp-test-%s", acctest.RandString(10))
backend := fmt.Sprintf("ttcp-test-%s", acctest.RandString(10))
hc := fmt.Sprintf("ttcp-test-%s", acctest.RandString(10))
Expand Down Expand Up @@ -47,6 +47,13 @@ func TestAccComputeTargetTcpProxy_update(t *testing.T) {
"google_compute_target_tcp_proxy.foobar"),
),
},
resource.TestStep{
Config: testAccComputeTargetTcpProxy_basic2(target, backend, hc),
Check: resource.ComposeTestCheckFunc(
testAccCheckComputeTargetTcpProxyExists(
"google_compute_target_tcp_proxy.foobar"),
),
},
},
})
}
Expand Down Expand Up @@ -102,18 +109,48 @@ func testAccComputeTargetTcpProxy_basic1(target, backend, hc string) string {
description = "Resource created for Terraform acceptance testing"
name = "%s"
backend_service = "${google_compute_backend_service.foobar.self_link}"
proxy_header = "NONE"
}
resource "google_compute_backend_service" "foobar" {
name = "%s"
protocol = "TCP"
health_checks = ["${google_compute_health_check.zero.self_link}"]
}
resource "google_compute_health_check" "zero" {
name = "%s"
check_interval_sec = 1
timeout_sec = 1
tcp_health_check {
port = "443"
}
}
`, target, backend, hc)
}

func testAccComputeTargetTcpProxy_basic2(target, backend, hc string) string {
return fmt.Sprintf(`
resource "google_compute_target_tcp_proxy" "foobar" {
description = "Resource created for Terraform acceptance testing"
name = "%s"
backend_service = "${google_compute_backend_service.foobar.self_link}"
proxy_header = "PROXY_V1"
}
resource "google_compute_backend_service" "foobar" {
name = "%s"
health_checks = ["${google_compute_http_health_check.zero.self_link}"]
protocol = "TCP"
health_checks = ["${google_compute_health_check.zero.self_link}"]
}
resource "google_compute_http_health_check" "zero" {
resource "google_compute_health_check" "zero" {
name = "%s"
request_path = "/"
check_interval_sec = 1
timeout_sec = 1
tcp_health_check {
port = "443"
}
}
`, target, backend, hc)
}
2 changes: 1 addition & 1 deletion website/docs/r/compute_target_tcp_proxy.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ The following arguments are supported:
In addition to the arguments listed above, the following computed attributes are
exported:

* `id` - A unique ID assigned by GCE.
* `proxy_id` - A unique ID assigned by GCE.

* `self_link` - The URI of the created resource.

0 comments on commit d8e2fcd

Please sign in to comment.