mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-09-07 01:26:43 +00:00
![Nathan McKinley](/assets/img/avatar_default.png)
- Fetch Zone attribute any place where it *was* being fetched from the schema by combination schema / provider-level attribute. - Allow region to be unspecified if zone is specified. - Switch one example to using provider-level zone as an example. - Make provider-level zone optional. (Individual resources will fail if they can't find a zone.) - Add tests for getZone and getRegion.
88 lines
1.5 KiB
Go
88 lines
1.5 KiB
Go
package google
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/hashicorp/terraform/helper/schema"
|
|
)
|
|
|
|
func dataSourceGoogleComputeInstanceGroup() *schema.Resource {
|
|
return &schema.Resource{
|
|
Read: dataSourceComputeInstanceGroupRead,
|
|
Schema: map[string]*schema.Schema{
|
|
"name": {
|
|
Type: schema.TypeString,
|
|
Required: true,
|
|
},
|
|
|
|
"zone": {
|
|
Type: schema.TypeString,
|
|
Optional: true,
|
|
},
|
|
|
|
"project": {
|
|
Type: schema.TypeString,
|
|
Optional: true,
|
|
},
|
|
|
|
"description": {
|
|
Type: schema.TypeString,
|
|
Computed: true,
|
|
},
|
|
|
|
"instances": {
|
|
Type: schema.TypeSet,
|
|
Computed: true,
|
|
Elem: &schema.Schema{Type: schema.TypeString},
|
|
Set: schema.HashString,
|
|
},
|
|
|
|
"named_port": {
|
|
Type: schema.TypeList,
|
|
Computed: true,
|
|
Elem: &schema.Resource{
|
|
Schema: map[string]*schema.Schema{
|
|
"name": {
|
|
Type: schema.TypeString,
|
|
Computed: true,
|
|
},
|
|
|
|
"port": {
|
|
Type: schema.TypeInt,
|
|
Computed: true,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
|
|
"network": {
|
|
Type: schema.TypeString,
|
|
Computed: true,
|
|
},
|
|
|
|
"self_link": {
|
|
Type: schema.TypeString,
|
|
Computed: true,
|
|
},
|
|
|
|
"size": {
|
|
Type: schema.TypeInt,
|
|
Computed: true,
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
func dataSourceComputeInstanceGroupRead(d *schema.ResourceData, meta interface{}) error {
|
|
|
|
zone, err := getZone(d, meta.(*Config))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
name := d.Get("name").(string)
|
|
|
|
d.SetId(fmt.Sprintf("%s/%s", zone, name))
|
|
|
|
return resourceComputeInstanceGroupRead(d, meta)
|
|
}
|