Add enable_cdn to google_compute_backend_service.
Add the ability to add/remove the Cloud CDN configuration option on a backend service.
This commit is contained in:
parent
81fa4de2d0
commit
a8e8922ea8
|
@ -88,6 +88,11 @@ func resourceComputeBackendService() *schema.Resource {
|
|||
Optional: true,
|
||||
},
|
||||
|
||||
"enable_cdn": &schema.Schema{
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
},
|
||||
|
||||
"fingerprint": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
|
@ -165,6 +170,10 @@ func resourceComputeBackendServiceCreate(d *schema.ResourceData, meta interface{
|
|||
service.TimeoutSec = int64(v.(int))
|
||||
}
|
||||
|
||||
if v, ok := d.GetOk("enable_cdn"); ok {
|
||||
service.EnableCDN = v.(bool)
|
||||
}
|
||||
|
||||
project, err := getProject(d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -212,6 +221,7 @@ func resourceComputeBackendServiceRead(d *schema.ResourceData, meta interface{})
|
|||
}
|
||||
|
||||
d.Set("description", service.Description)
|
||||
d.Set("enable_cdn", service.EnableCDN)
|
||||
d.Set("port_name", service.PortName)
|
||||
d.Set("protocol", service.Protocol)
|
||||
d.Set("timeout_sec", service.TimeoutSec)
|
||||
|
@ -260,6 +270,10 @@ func resourceComputeBackendServiceUpdate(d *schema.ResourceData, meta interface{
|
|||
service.TimeoutSec = int64(d.Get("timeout_sec").(int))
|
||||
}
|
||||
|
||||
if d.HasChange("enable_cdn") {
|
||||
service.EnableCDN = d.Get("enable_cdn").(bool)
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] Updating existing Backend Service %q: %#v", d.Id(), service)
|
||||
op, err := config.clientCompute.BackendServices.Update(
|
||||
project, d.Id(), &service).Do()
|
||||
|
|
|
@ -19,6 +19,7 @@ resource "google_compute_backend_service" "foobar" {
|
|||
port_name = "http"
|
||||
protocol = "HTTP"
|
||||
timeout_sec = 10
|
||||
enable_cdn = false
|
||||
|
||||
backend {
|
||||
group = "${google_compute_instance_group_manager.foo.instance_group}"
|
||||
|
@ -74,6 +75,8 @@ The following arguments are supported:
|
|||
|
||||
* `description` - (Optional) The textual description for the backend service.
|
||||
|
||||
* `enable_cdn` - (Optional) Whether or not to enable the Cloud CDN on the backend service.
|
||||
|
||||
* `port_name` - (Optional) The name of a service that has been added to an
|
||||
instance group in this backend. See [related docs](https://cloud.google.com/compute/docs/instance-groups/#specifying_service_endpoints) for details. Defaults to http.
|
||||
|
||||
|
|
Loading…
Reference in New Issue