mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-07-09 11:38:29 +00:00
Add import support to google_compute_target_tcp_proxy (#534)
This commit is contained in:
parent
f03780986a
commit
c94cbde1f6
30
google/import_compute_target_tcp_proxy_test.go
Normal file
30
google/import_compute_target_tcp_proxy_test.go
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
package google
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/hashicorp/terraform/helper/acctest"
|
||||||
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestAccComputeTargetTcpProxy_import(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))
|
||||||
|
|
||||||
|
resource.Test(t, resource.TestCase{
|
||||||
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
Providers: testAccProviders,
|
||||||
|
CheckDestroy: testAccCheckComputeTargetTcpProxyDestroy,
|
||||||
|
Steps: []resource.TestStep{
|
||||||
|
resource.TestStep{
|
||||||
|
Config: testAccComputeTargetTcpProxy_basic1(target, backend, hc),
|
||||||
|
},
|
||||||
|
resource.TestStep{
|
||||||
|
ResourceName: "google_compute_target_tcp_proxy.foobar",
|
||||||
|
ImportState: true,
|
||||||
|
ImportStateVerify: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
|
@ -16,6 +16,10 @@ func resourceComputeTargetTcpProxy() *schema.Resource {
|
||||||
Delete: resourceComputeTargetTcpProxyDelete,
|
Delete: resourceComputeTargetTcpProxyDelete,
|
||||||
Update: resourceComputeTargetTcpProxyUpdate,
|
Update: resourceComputeTargetTcpProxyUpdate,
|
||||||
|
|
||||||
|
Importer: &schema.ResourceImporter{
|
||||||
|
State: schema.ImportStatePassthrough,
|
||||||
|
},
|
||||||
|
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"name": &schema.Schema{
|
"name": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
|
@ -27,11 +31,13 @@ func resourceComputeTargetTcpProxy() *schema.Resource {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
"proxy_header": &schema.Schema{
|
"proxy_header": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Default: "NONE",
|
Default: "NONE",
|
||||||
},
|
},
|
||||||
|
|
||||||
"description": &schema.Schema{
|
"description": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
|
@ -137,6 +143,10 @@ func resourceComputeTargetTcpProxyRead(d *schema.ResourceData, meta interface{})
|
||||||
return handleNotFoundError(err, d, fmt.Sprintf("Target TCP Proxy %q", d.Get("name").(string)))
|
return handleNotFoundError(err, d, fmt.Sprintf("Target TCP Proxy %q", d.Get("name").(string)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
d.Set("name", proxy.Name)
|
||||||
|
d.Set("backend_service", proxy.Service)
|
||||||
|
d.Set("proxy_header", proxy.ProxyHeader)
|
||||||
|
d.Set("description", proxy.Description)
|
||||||
d.Set("self_link", proxy.SelfLink)
|
d.Set("self_link", proxy.SelfLink)
|
||||||
d.Set("proxy_id", strconv.FormatUint(proxy.Id, 10))
|
d.Set("proxy_id", strconv.FormatUint(proxy.Id, 10))
|
||||||
|
|
||||||
|
|
|
@ -51,11 +51,11 @@ The following arguments are supported:
|
||||||
|
|
||||||
* `backend_service` - (Required) The URL of a Backend Service resource to receive the matched traffic.
|
* `backend_service` - (Required) The URL of a Backend Service resource to receive the matched traffic.
|
||||||
|
|
||||||
|
- - -
|
||||||
|
|
||||||
* `proxy_header` - (Optional) Type of proxy header to append before sending
|
* `proxy_header` - (Optional) Type of proxy header to append before sending
|
||||||
data to the backend, either NONE or PROXY_V1 (default NONE).
|
data to the backend, either NONE or PROXY_V1 (default NONE).
|
||||||
|
|
||||||
- - -
|
|
||||||
|
|
||||||
* `description` - (Optional) A description of this resource. Changing this
|
* `description` - (Optional) A description of this resource. Changing this
|
||||||
forces a new resource to be created.
|
forces a new resource to be created.
|
||||||
|
|
||||||
|
@ -70,3 +70,11 @@ exported:
|
||||||
* `proxy_id` - A unique ID assigned by GCE.
|
* `proxy_id` - A unique ID assigned by GCE.
|
||||||
|
|
||||||
* `self_link` - The URI of the created resource.
|
* `self_link` - The URI of the created resource.
|
||||||
|
|
||||||
|
## Import
|
||||||
|
|
||||||
|
TCP proxy can be imported using the `name`, e.g.
|
||||||
|
|
||||||
|
```
|
||||||
|
$ terraform import google_compute_target_tcp_proxy.default test
|
||||||
|
```
|
Loading…
Reference in New Issue
Block a user