mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-07-03 08:42:39 +00:00
Release autogenerated google_compute_target_ssl_proxy resource (#1373)
This commit is contained in:
parent
0544ef468f
commit
e02587855a
|
@ -17,6 +17,7 @@ package google
|
|||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
|
@ -367,6 +368,12 @@ func resourceComputeHttpHealthCheckImport(d *schema.ResourceData, meta interface
|
|||
}
|
||||
|
||||
func flattenComputeHttpHealthCheckCheckIntervalSec(v interface{}) interface{} {
|
||||
// Handles the string fixed64 format
|
||||
if strVal, ok := v.(string); ok {
|
||||
if intVal, err := strconv.Atoi(strVal); err == nil {
|
||||
return intVal
|
||||
} // let terraform core handle it if we can't convert the string to an int.
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
|
@ -379,6 +386,12 @@ func flattenComputeHttpHealthCheckDescription(v interface{}) interface{} {
|
|||
}
|
||||
|
||||
func flattenComputeHttpHealthCheckHealthyThreshold(v interface{}) interface{} {
|
||||
// Handles the string fixed64 format
|
||||
if strVal, ok := v.(string); ok {
|
||||
if intVal, err := strconv.Atoi(strVal); err == nil {
|
||||
return intVal
|
||||
} // let terraform core handle it if we can't convert the string to an int.
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
|
@ -391,6 +404,12 @@ func flattenComputeHttpHealthCheckName(v interface{}) interface{} {
|
|||
}
|
||||
|
||||
func flattenComputeHttpHealthCheckPort(v interface{}) interface{} {
|
||||
// Handles the string fixed64 format
|
||||
if strVal, ok := v.(string); ok {
|
||||
if intVal, err := strconv.Atoi(strVal); err == nil {
|
||||
return intVal
|
||||
} // let terraform core handle it if we can't convert the string to an int.
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
|
@ -399,10 +418,22 @@ func flattenComputeHttpHealthCheckRequestPath(v interface{}) interface{} {
|
|||
}
|
||||
|
||||
func flattenComputeHttpHealthCheckTimeoutSec(v interface{}) interface{} {
|
||||
// Handles the string fixed64 format
|
||||
if strVal, ok := v.(string); ok {
|
||||
if intVal, err := strconv.Atoi(strVal); err == nil {
|
||||
return intVal
|
||||
} // let terraform core handle it if we can't convert the string to an int.
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
func flattenComputeHttpHealthCheckUnhealthyThreshold(v interface{}) interface{} {
|
||||
// Handles the string fixed64 format
|
||||
if strVal, ok := v.(string); ok {
|
||||
if intVal, err := strconv.Atoi(strVal); err == nil {
|
||||
return intVal
|
||||
} // let terraform core handle it if we can't convert the string to an int.
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ package google
|
|||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
|
@ -367,6 +368,12 @@ func resourceComputeHttpsHealthCheckImport(d *schema.ResourceData, meta interfac
|
|||
}
|
||||
|
||||
func flattenComputeHttpsHealthCheckCheckIntervalSec(v interface{}) interface{} {
|
||||
// Handles the string fixed64 format
|
||||
if strVal, ok := v.(string); ok {
|
||||
if intVal, err := strconv.Atoi(strVal); err == nil {
|
||||
return intVal
|
||||
} // let terraform core handle it if we can't convert the string to an int.
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
|
@ -379,6 +386,12 @@ func flattenComputeHttpsHealthCheckDescription(v interface{}) interface{} {
|
|||
}
|
||||
|
||||
func flattenComputeHttpsHealthCheckHealthyThreshold(v interface{}) interface{} {
|
||||
// Handles the string fixed64 format
|
||||
if strVal, ok := v.(string); ok {
|
||||
if intVal, err := strconv.Atoi(strVal); err == nil {
|
||||
return intVal
|
||||
} // let terraform core handle it if we can't convert the string to an int.
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
|
@ -391,6 +404,12 @@ func flattenComputeHttpsHealthCheckName(v interface{}) interface{} {
|
|||
}
|
||||
|
||||
func flattenComputeHttpsHealthCheckPort(v interface{}) interface{} {
|
||||
// Handles the string fixed64 format
|
||||
if strVal, ok := v.(string); ok {
|
||||
if intVal, err := strconv.Atoi(strVal); err == nil {
|
||||
return intVal
|
||||
} // let terraform core handle it if we can't convert the string to an int.
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
|
@ -399,10 +418,22 @@ func flattenComputeHttpsHealthCheckRequestPath(v interface{}) interface{} {
|
|||
}
|
||||
|
||||
func flattenComputeHttpsHealthCheckTimeoutSec(v interface{}) interface{} {
|
||||
// Handles the string fixed64 format
|
||||
if strVal, ok := v.(string); ok {
|
||||
if intVal, err := strconv.Atoi(strVal); err == nil {
|
||||
return intVal
|
||||
} // let terraform core handle it if we can't convert the string to an int.
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
func flattenComputeHttpsHealthCheckUnhealthyThreshold(v interface{}) interface{} {
|
||||
// Handles the string fixed64 format
|
||||
if strVal, ok := v.(string); ok {
|
||||
if intVal, err := strconv.Atoi(strVal); err == nil {
|
||||
return intVal
|
||||
} // let terraform core handle it if we can't convert the string to an int.
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
|
|
|
@ -1,38 +1,58 @@
|
|||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// This file is automatically generated by Magic Modules and manual
|
||||
// changes will be clobbered when the file is regenerated.
|
||||
//
|
||||
// Please read more about how to change this file in
|
||||
// .github/CONTRIBUTING.md.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
package google
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
"google.golang.org/api/compute/v1"
|
||||
compute "google.golang.org/api/compute/v1"
|
||||
)
|
||||
|
||||
func resourceComputeTargetSslProxy() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
Create: resourceComputeTargetSslProxyCreate,
|
||||
Read: resourceComputeTargetSslProxyRead,
|
||||
Delete: resourceComputeTargetSslProxyDelete,
|
||||
Update: resourceComputeTargetSslProxyUpdate,
|
||||
Delete: resourceComputeTargetSslProxyDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
State: resourceComputeTargetSslProxyImport,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Create: schema.DefaultTimeout(240 * time.Second),
|
||||
Update: schema.DefaultTimeout(240 * time.Second),
|
||||
Delete: schema.DefaultTimeout(240 * time.Second),
|
||||
},
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": &schema.Schema{
|
||||
"backend_service": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
DiffSuppressFunc: compareSelfLinkOrResourceName,
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"backend_service": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
|
||||
"ssl_certificates": &schema.Schema{
|
||||
"ssl_certificates": {
|
||||
Type: schema.TypeList,
|
||||
Required: true,
|
||||
MaxItems: 1,
|
||||
|
@ -41,31 +61,30 @@ func resourceComputeTargetSslProxy() *schema.Resource {
|
|||
DiffSuppressFunc: compareSelfLinkOrResourceName,
|
||||
},
|
||||
},
|
||||
|
||||
"description": &schema.Schema{
|
||||
"description": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"proxy_header": &schema.Schema{
|
||||
"proxy_header": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Default: "NONE",
|
||||
},
|
||||
|
||||
"creation_timestamp": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"proxy_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"project": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"proxy_id": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"self_link": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
|
@ -82,106 +101,69 @@ func resourceComputeTargetSslProxyCreate(d *schema.ResourceData, meta interface{
|
|||
return err
|
||||
}
|
||||
|
||||
sslCertificates, err := expandSslCertificates(d, config)
|
||||
descriptionProp, err := expandComputeTargetSslProxyDescription(d.Get("description"), d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
nameProp, err := expandComputeTargetSslProxyName(d.Get("name"), d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
proxyHeaderProp, err := expandComputeTargetSslProxyProxyHeader(d.Get("proxy_header"), d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
serviceProp, err := expandComputeTargetSslProxyBackendService(d.Get("backend_service"), d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
sslCertificatesProp, err := expandComputeTargetSslProxySslCertificates(d.Get("ssl_certificates"), d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
proxy := &compute.TargetSslProxy{
|
||||
Name: d.Get("name").(string),
|
||||
Service: d.Get("backend_service").(string),
|
||||
ProxyHeader: d.Get("proxy_header").(string),
|
||||
Description: d.Get("description").(string),
|
||||
SslCertificates: sslCertificates,
|
||||
obj := map[string]interface{}{
|
||||
"description": descriptionProp,
|
||||
"name": nameProp,
|
||||
"proxyHeader": proxyHeaderProp,
|
||||
"service": serviceProp,
|
||||
"sslCertificates": sslCertificatesProp,
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] TargetSslProxy insert request: %#v", proxy)
|
||||
op, err := config.clientCompute.TargetSslProxies.Insert(
|
||||
project, proxy).Do()
|
||||
url, err := replaceVars(d, config, "https://www.googleapis.com/compute/v1/projects/{{project}}/global/targetSslProxies")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] Creating new TargetSslProxy: %#v", obj)
|
||||
res, err := Post(config, url, obj)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating TargetSslProxy: %s", err)
|
||||
}
|
||||
|
||||
err = computeOperationWait(config.clientCompute, op, project, "Creating Target Ssl Proxy")
|
||||
// Store the ID now
|
||||
id, err := replaceVars(d, config, "{{name}}")
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error constructing id: %s", err)
|
||||
}
|
||||
d.SetId(id)
|
||||
|
||||
op := &compute.Operation{}
|
||||
err = Convert(res, op)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
d.SetId(proxy.Name)
|
||||
waitErr := computeOperationWaitTime(
|
||||
config.clientCompute, op, project, "Creating TargetSslProxy",
|
||||
int(d.Timeout(schema.TimeoutCreate).Minutes()))
|
||||
|
||||
return resourceComputeTargetSslProxyRead(d, meta)
|
||||
}
|
||||
|
||||
func resourceComputeTargetSslProxyUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
|
||||
project, err := getProject(d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
if waitErr != nil {
|
||||
// The resource didn't actually create
|
||||
d.SetId("")
|
||||
return waitErr
|
||||
}
|
||||
|
||||
d.Partial(true)
|
||||
|
||||
if d.HasChange("proxy_header") {
|
||||
proxyHeader := d.Get("proxy_header").(string)
|
||||
proxyHeaderPayload := &compute.TargetSslProxiesSetProxyHeaderRequest{
|
||||
ProxyHeader: proxyHeader,
|
||||
}
|
||||
op, err := config.clientCompute.TargetSslProxies.SetProxyHeader(
|
||||
project, d.Id(), proxyHeaderPayload).Do()
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error updating proxy_header: %s", err)
|
||||
}
|
||||
|
||||
err = computeOperationWait(config.clientCompute, op, project, "Updating Target SSL Proxy")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
d.SetPartial("proxy_header")
|
||||
}
|
||||
|
||||
if d.HasChange("backend_service") {
|
||||
op, err := config.clientCompute.TargetSslProxies.SetBackendService(project, d.Id(), &compute.TargetSslProxiesSetBackendServiceRequest{
|
||||
Service: d.Get("backend_service").(string),
|
||||
}).Do()
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error updating backend_service: %s", err)
|
||||
}
|
||||
|
||||
err = computeOperationWait(config.clientCompute, op, project, "Updating Target SSL Proxy")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
d.SetPartial("backend_service")
|
||||
}
|
||||
|
||||
if d.HasChange("ssl_certificates") {
|
||||
sslCertificates, err := expandSslCertificates(d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
op, err := config.clientCompute.TargetSslProxies.SetSslCertificates(project, d.Id(), &compute.TargetSslProxiesSetSslCertificatesRequest{
|
||||
SslCertificates: sslCertificates,
|
||||
}).Do()
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error updating backend_service: %s", err)
|
||||
}
|
||||
|
||||
err = computeOperationWait(config.clientCompute, op, project, "Updating Target SSL Proxy")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
d.SetPartial("ssl_certificates")
|
||||
}
|
||||
|
||||
d.Partial(false)
|
||||
|
||||
return resourceComputeTargetSslProxyRead(d, meta)
|
||||
}
|
||||
|
||||
|
@ -193,24 +175,198 @@ func resourceComputeTargetSslProxyRead(d *schema.ResourceData, meta interface{})
|
|||
return err
|
||||
}
|
||||
|
||||
proxy, err := config.clientCompute.TargetSslProxies.Get(
|
||||
project, d.Id()).Do()
|
||||
url, err := replaceVars(d, config, "https://www.googleapis.com/compute/v1/projects/{{project}}/global/targetSslProxies/{{name}}")
|
||||
if err != nil {
|
||||
return handleNotFoundError(err, d, fmt.Sprintf("Target SSL Proxy %q", d.Get("name").(string)))
|
||||
return err
|
||||
}
|
||||
|
||||
d.Set("name", proxy.Name)
|
||||
d.Set("description", proxy.Description)
|
||||
d.Set("proxy_header", proxy.ProxyHeader)
|
||||
d.Set("backend_service", proxy.Service)
|
||||
d.Set("ssl_certificates", proxy.SslCertificates)
|
||||
res, err := Get(config, url)
|
||||
if err != nil {
|
||||
return handleNotFoundError(err, d, fmt.Sprintf("ComputeTargetSslProxy %q", d.Id()))
|
||||
}
|
||||
|
||||
d.Set("creation_timestamp", flattenComputeTargetSslProxyCreationTimestamp(res["creationTimestamp"]))
|
||||
d.Set("description", flattenComputeTargetSslProxyDescription(res["description"]))
|
||||
d.Set("proxy_id", flattenComputeTargetSslProxyProxyId(res["id"]))
|
||||
d.Set("name", flattenComputeTargetSslProxyName(res["name"]))
|
||||
d.Set("proxy_header", flattenComputeTargetSslProxyProxyHeader(res["proxyHeader"]))
|
||||
d.Set("backend_service", flattenComputeTargetSslProxyBackendService(res["service"]))
|
||||
d.Set("ssl_certificates", flattenComputeTargetSslProxySslCertificates(res["sslCertificates"]))
|
||||
d.Set("self_link", res["selfLink"])
|
||||
d.Set("project", project)
|
||||
d.Set("self_link", proxy.SelfLink)
|
||||
d.Set("proxy_id", strconv.FormatUint(proxy.Id, 10))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceComputeTargetSslProxyUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
|
||||
project, err := getProject(d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var url string
|
||||
var res map[string]interface{}
|
||||
op := &compute.Operation{}
|
||||
|
||||
if d.HasChange("proxy_header") {
|
||||
descriptionProp, err := expandComputeTargetSslProxyDescription(d.Get("description"), d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
nameProp, err := expandComputeTargetSslProxyName(d.Get("name"), d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
proxyHeaderProp, err := expandComputeTargetSslProxyProxyHeader(d.Get("proxy_header"), d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
serviceProp, err := expandComputeTargetSslProxyBackendService(d.Get("backend_service"), d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
sslCertificatesProp, err := expandComputeTargetSslProxySslCertificates(d.Get("ssl_certificates"), d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
obj := map[string]interface{}{
|
||||
"description": descriptionProp,
|
||||
"name": nameProp,
|
||||
"proxyHeader": proxyHeaderProp,
|
||||
"service": serviceProp,
|
||||
"sslCertificates": sslCertificatesProp,
|
||||
}
|
||||
url, err = replaceVars(d, config, "https://www.googleapis.com/compute/v1/projects/{{project}}/global/targetSslProxies/{{name}}/setProxyHeader")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
res, err = sendRequest(config, "POST", url, obj)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error updating TargetSslProxy %q: %s", d.Id(), err)
|
||||
}
|
||||
|
||||
err = Convert(res, op)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = computeOperationWaitTime(
|
||||
config.clientCompute, op, project, "Updating TargetSslProxy",
|
||||
int(d.Timeout(schema.TimeoutUpdate).Minutes()))
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if d.HasChange("backend_service") {
|
||||
descriptionProp, err := expandComputeTargetSslProxyDescription(d.Get("description"), d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
nameProp, err := expandComputeTargetSslProxyName(d.Get("name"), d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
proxyHeaderProp, err := expandComputeTargetSslProxyProxyHeader(d.Get("proxy_header"), d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
serviceProp, err := expandComputeTargetSslProxyBackendService(d.Get("backend_service"), d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
sslCertificatesProp, err := expandComputeTargetSslProxySslCertificates(d.Get("ssl_certificates"), d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
obj := map[string]interface{}{
|
||||
"description": descriptionProp,
|
||||
"name": nameProp,
|
||||
"proxyHeader": proxyHeaderProp,
|
||||
"service": serviceProp,
|
||||
"sslCertificates": sslCertificatesProp,
|
||||
}
|
||||
url, err = replaceVars(d, config, "https://www.googleapis.com/compute/v1/projects/{{project}}/global/targetSslProxies/{{name}}/setBackendService")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
res, err = sendRequest(config, "POST", url, obj)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error updating TargetSslProxy %q: %s", d.Id(), err)
|
||||
}
|
||||
|
||||
err = Convert(res, op)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = computeOperationWaitTime(
|
||||
config.clientCompute, op, project, "Updating TargetSslProxy",
|
||||
int(d.Timeout(schema.TimeoutUpdate).Minutes()))
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if d.HasChange("ssl_certificates") {
|
||||
descriptionProp, err := expandComputeTargetSslProxyDescription(d.Get("description"), d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
nameProp, err := expandComputeTargetSslProxyName(d.Get("name"), d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
proxyHeaderProp, err := expandComputeTargetSslProxyProxyHeader(d.Get("proxy_header"), d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
serviceProp, err := expandComputeTargetSslProxyBackendService(d.Get("backend_service"), d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
sslCertificatesProp, err := expandComputeTargetSslProxySslCertificates(d.Get("ssl_certificates"), d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
obj := map[string]interface{}{
|
||||
"description": descriptionProp,
|
||||
"name": nameProp,
|
||||
"proxyHeader": proxyHeaderProp,
|
||||
"service": serviceProp,
|
||||
"sslCertificates": sslCertificatesProp,
|
||||
}
|
||||
url, err = replaceVars(d, config, "https://www.googleapis.com/compute/v1/projects/{{project}}/global/targetSslProxies/{{name}}/setSslCertificates")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
res, err = sendRequest(config, "POST", url, obj)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error updating TargetSslProxy %q: %s", d.Id(), err)
|
||||
}
|
||||
|
||||
err = Convert(res, op)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = computeOperationWaitTime(
|
||||
config.clientCompute, op, project, "Updating TargetSslProxy",
|
||||
int(d.Timeout(schema.TimeoutUpdate).Minutes()))
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return resourceComputeTargetSslProxyRead(d, meta)
|
||||
}
|
||||
|
||||
func resourceComputeTargetSslProxyDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
|
||||
|
@ -219,17 +375,111 @@ func resourceComputeTargetSslProxyDelete(d *schema.ResourceData, meta interface{
|
|||
return err
|
||||
}
|
||||
|
||||
op, err := config.clientCompute.TargetSslProxies.Delete(
|
||||
project, d.Id()).Do()
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error deleting TargetSslProxy: %s", err)
|
||||
}
|
||||
|
||||
err = computeOperationWait(config.clientCompute, op, project, "Deleting Target SSL Proxy")
|
||||
url, err := replaceVars(d, config, "https://www.googleapis.com/compute/v1/projects/{{project}}/global/targetSslProxies/{{name}}")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] Deleting TargetSslProxy %q", d.Id())
|
||||
res, err := Delete(config, url)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error deleting TargetSslProxy %q: %s", d.Id(), err)
|
||||
}
|
||||
|
||||
op := &compute.Operation{}
|
||||
err = Convert(res, op)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = computeOperationWaitTime(
|
||||
config.clientCompute, op, project, "Deleting TargetSslProxy",
|
||||
int(d.Timeout(schema.TimeoutDelete).Minutes()))
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
d.SetId("")
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceComputeTargetSslProxyImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
|
||||
config := meta.(*Config)
|
||||
parseImportId([]string{"projects/(?P<project>[^/]+)/global/targetSslProxies/(?P<name>[^/]+)", "(?P<project>[^/]+)/(?P<name>[^/]+)", "(?P<name>[^/]+)"}, d, config)
|
||||
|
||||
// Replace import id for the resource id
|
||||
id, err := replaceVars(d, config, "{{name}}")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Error constructing id: %s", err)
|
||||
}
|
||||
d.SetId(id)
|
||||
|
||||
return []*schema.ResourceData{d}, nil
|
||||
}
|
||||
|
||||
func flattenComputeTargetSslProxyCreationTimestamp(v interface{}) interface{} {
|
||||
return v
|
||||
}
|
||||
|
||||
func flattenComputeTargetSslProxyDescription(v interface{}) interface{} {
|
||||
return v
|
||||
}
|
||||
|
||||
func flattenComputeTargetSslProxyProxyId(v interface{}) interface{} {
|
||||
// Handles the string fixed64 format
|
||||
if strVal, ok := v.(string); ok {
|
||||
if intVal, err := strconv.Atoi(strVal); err == nil {
|
||||
return intVal
|
||||
} // let terraform core handle it if we can't convert the string to an int.
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
func flattenComputeTargetSslProxyName(v interface{}) interface{} {
|
||||
return v
|
||||
}
|
||||
|
||||
func flattenComputeTargetSslProxyProxyHeader(v interface{}) interface{} {
|
||||
return v
|
||||
}
|
||||
|
||||
func flattenComputeTargetSslProxyBackendService(v interface{}) interface{} {
|
||||
return v
|
||||
}
|
||||
|
||||
func flattenComputeTargetSslProxySslCertificates(v interface{}) interface{} {
|
||||
return v
|
||||
}
|
||||
|
||||
func expandComputeTargetSslProxyDescription(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
|
||||
return v, nil
|
||||
}
|
||||
|
||||
func expandComputeTargetSslProxyName(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
|
||||
return v, nil
|
||||
}
|
||||
|
||||
func expandComputeTargetSslProxyProxyHeader(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
|
||||
return v, nil
|
||||
}
|
||||
|
||||
func expandComputeTargetSslProxyBackendService(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
|
||||
f, err := parseGlobalFieldValue("backendServices", v.(string), "project", d, config, true)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Invalid value for backend_service: %s", err)
|
||||
}
|
||||
return f.RelativeLink(), nil
|
||||
}
|
||||
|
||||
func expandComputeTargetSslProxySslCertificates(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
|
||||
l := v.([]interface{})
|
||||
req := make([]interface{}, 0, len(l))
|
||||
for _, raw := range l {
|
||||
f, err := parseGlobalFieldValue("sslCertificates", raw.(string), "project", d, config, true)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Invalid value for ssl_certificates: %s", err)
|
||||
}
|
||||
req = append(req, f.RelativeLink())
|
||||
}
|
||||
return req, nil
|
||||
}
|
||||
|
|
|
@ -1,18 +1,40 @@
|
|||
<!--
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
*** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
This file is automatically generated by Magic Modules and manual
|
||||
changes will be clobbered when the file is regenerated.
|
||||
|
||||
Please read more about how to change this file in
|
||||
.github/CONTRIBUTING.md.
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
-->
|
||||
|
||||
---
|
||||
layout: "google"
|
||||
page_title: "Google: google_compute_target_ssl_proxy"
|
||||
sidebar_current: "docs-google-compute-target-ssl-proxy"
|
||||
description: |-
|
||||
Creates a Target SSL Proxy resource in GCE.
|
||||
Represents a TargetSslProxy resource, which is used by one or more
|
||||
global forwarding rule to route incoming SSL requests to a backend
|
||||
service.
|
||||
---
|
||||
|
||||
# google\_compute\_target\_ssl\_proxy
|
||||
|
||||
Creates a target SSL proxy resource in GCE. For more information see
|
||||
[the official
|
||||
documentation](https://cloud.google.com/compute/docs/load-balancing/ssl-ssl/) and
|
||||
[API](https://cloud.google.com/compute/docs/reference/latest/targetSslProxies).
|
||||
Represents a TargetSslProxy resource, which is used by one or more
|
||||
global forwarding rule to route incoming SSL requests to a backend
|
||||
service.
|
||||
|
||||
To get more information about TargetSslProxy, see:
|
||||
|
||||
* [API documentation](https://cloud.google.com/compute/docs/reference/latest/targetSslProxies)
|
||||
* How-to Guides
|
||||
* [Setting Up SSL proxy for Google Cloud Load Balancing](https://cloud.google.com/compute/docs/load-balancing/tcp-ssl/)
|
||||
|
||||
## Example Usage
|
||||
|
||||
|
@ -49,38 +71,64 @@ resource "google_compute_health_check" "default" {
|
|||
|
||||
The following arguments are supported:
|
||||
|
||||
* `name` - (Required) A unique name for the resource, required by GCE. Changing
|
||||
this forces a new resource to be created.
|
||||
* `name` -
|
||||
(Required)
|
||||
Name of the resource. Provided by the client when the resource is
|
||||
created. The name must be 1-63 characters long, and comply with
|
||||
RFC1035. Specifically, the name must be 1-63 characters long and match
|
||||
the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the
|
||||
first character must be a lowercase letter, and all following
|
||||
characters must be a dash, lowercase letter, or digit, except the last
|
||||
character, which cannot be a dash.
|
||||
* `backend_service` -
|
||||
(Required)
|
||||
A reference to BackendService resource
|
||||
* `ssl_certificates` -
|
||||
(Required)
|
||||
A list of SslCertificate resources that are used to authenticate
|
||||
connections between users and the load balancer. Currently, exactly
|
||||
one SSL certificate must be specified.
|
||||
|
||||
* `backend_service` - (Required) The URL of a Backend Service resource to receive the matched traffic.
|
||||
|
||||
* `ssl_certificates` - (Required) The URLs or names of the SSL Certificate resources that
|
||||
authenticate connections between users and load balancing.
|
||||
|
||||
- - -
|
||||
|
||||
* `proxy_header` - (Optional) Type of proxy header to append before sending
|
||||
data to the backend, either NONE or PROXY_V1 (default NONE).
|
||||
* `description` -
|
||||
(Optional)
|
||||
An optional description of this resource.
|
||||
* `proxy_header` -
|
||||
(Optional)
|
||||
Specifies the type of proxy header to append before sending data to
|
||||
the backend, either NONE or PROXY_V1. The default is NONE.
|
||||
* `project` (Optional) The ID of the project in which the resource belongs.
|
||||
If it is not provided, the provider project is used.
|
||||
|
||||
* `description` - (Optional) A description of this resource. Changing this
|
||||
forces a new resource to be created.
|
||||
|
||||
* `project` - (Optional) The ID of the project in which the resource belongs. If it
|
||||
is not provided, the provider project is used.
|
||||
|
||||
## Attributes Reference
|
||||
|
||||
In addition to the arguments listed above, the following computed attributes are
|
||||
exported:
|
||||
|
||||
* `proxy_id` - A unique ID assigned by GCE.
|
||||
In addition to the arguments listed above, the following computed attributes are exported:
|
||||
|
||||
* `creation_timestamp` -
|
||||
Creation timestamp in RFC3339 text format.
|
||||
* `proxy_id` -
|
||||
The unique identifier for the resource.
|
||||
* `self_link` - The URI of the created resource.
|
||||
|
||||
|
||||
## Timeouts
|
||||
|
||||
This resource provides the following
|
||||
[Timeouts](/docs/configuration/resources.html#timeouts) configuration options:
|
||||
|
||||
- `create` - Default is 4 minutes.
|
||||
- `update` - Default is 4 minutes.
|
||||
- `delete` - Default is 4 minutes.
|
||||
|
||||
## Import
|
||||
|
||||
SSL proxy can be imported using the `name`, e.g.
|
||||
TargetSslProxy can be imported using any of these accepted formats:
|
||||
|
||||
```
|
||||
$ terraform import google_compute_target_ssl_proxy.default test
|
||||
$ terraform import google_compute_target_ssl_proxy.default projects/{{project}}/global/targetSslProxies/{{name}}
|
||||
$ terraform import google_compute_target_ssl_proxy.default {{project}}/{{name}}
|
||||
$ terraform import google_compute_target_ssl_proxy.default {{name}}
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue
Block a user