mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-09-07 01:26:43 +00:00
![Benjamin Pineau](/assets/img/avatar_default.png)
Exposes existing `google_compute_backend_service` as data sources. This addresses #149 . This allows, for instance, to collect a backend service's self_link and use it from an other workspace/tfstate, sharing most of the loadbalancers definition.
29 lines
700 B
Go
29 lines
700 B
Go
package google
|
|
|
|
import (
|
|
"github.com/hashicorp/terraform/helper/schema"
|
|
)
|
|
|
|
func dataSourceGoogleComputeBackendService() *schema.Resource {
|
|
dsSchema := datasourceSchemaFromResourceSchema(resourceComputeBackendService().Schema)
|
|
|
|
// Set 'Required' schema elements
|
|
addRequiredFieldsToSchema(dsSchema, "name")
|
|
|
|
// Set 'Optional' schema elements
|
|
addOptionalFieldsToSchema(dsSchema, "project")
|
|
|
|
return &schema.Resource{
|
|
Read: dataSourceComputeBackendServiceRead,
|
|
Schema: dsSchema,
|
|
}
|
|
}
|
|
|
|
func dataSourceComputeBackendServiceRead(d *schema.ResourceData, meta interface{}) error {
|
|
serviceName := d.Get("name").(string)
|
|
|
|
d.SetId(serviceName)
|
|
|
|
return resourceComputeBackendServiceRead(d, meta)
|
|
}
|