diff --git a/google/data_source_google_compute_instance_group.go b/google/data_source_google_compute_instance_group.go index 09ffd7602b6..929976ccae2 100644 --- a/google/data_source_google_compute_instance_group.go +++ b/google/data_source_google_compute_instance_group.go @@ -18,11 +18,13 @@ func dataSourceGoogleComputeInstanceGroup() *schema.Resource { "zone": { Type: schema.TypeString, Optional: true, + Computed: true, }, "project": { Type: schema.TypeString, Optional: true, + Computed: true, }, "description": { diff --git a/google/resource_bigtable_instance.go b/google/resource_bigtable_instance.go index cf0e8f73ef1..78b82687368 100644 --- a/google/resource_bigtable_instance.go +++ b/google/resource_bigtable_instance.go @@ -33,6 +33,7 @@ func resourceBigtableInstance() *schema.Resource { "zone": { Type: schema.TypeString, Optional: true, + Computed: true, ForceNew: true, }, @@ -152,6 +153,11 @@ func resourceBigtableInstanceRead(d *schema.ResourceData, meta interface{}) erro return err } + zone, err := getZone(d, config) + if err != nil { + return err + } + c, err := config.bigtableClientFactory.NewInstanceAdminClient(project) if err != nil { return fmt.Errorf("Error starting instance admin client. %s", err) @@ -167,6 +173,7 @@ func resourceBigtableInstanceRead(d *schema.ResourceData, meta interface{}) erro } d.Set("project", project) + d.Set("zone", zone) d.Set("name", instance.Name) d.Set("display_name", instance.DisplayName) diff --git a/google/resource_compute_autoscaler.go b/google/resource_compute_autoscaler.go index c8d6b342ffb..f2095f24b12 100644 --- a/google/resource_compute_autoscaler.go +++ b/google/resource_compute_autoscaler.go @@ -107,6 +107,7 @@ func resourceComputeAutoscaler() *schema.Resource { "zone": &schema.Schema{ Type: schema.TypeString, Optional: true, + Computed: true, ForceNew: true, }, diff --git a/google/resource_compute_disk.go b/google/resource_compute_disk.go index 39465800590..d5fc1b063b5 100644 --- a/google/resource_compute_disk.go +++ b/google/resource_compute_disk.go @@ -46,6 +46,7 @@ func resourceComputeDisk() *schema.Resource { "zone": &schema.Schema{ Type: schema.TypeString, Optional: true, + Computed: true, ForceNew: true, }, @@ -306,12 +307,10 @@ func resourceComputeDiskRead(d *schema.ResourceData, meta interface{}) error { disk = resource.(*compute.Disk) } - zoneUrlParts := strings.Split(disk.Zone, "/") - typeUrlParts := strings.Split(disk.Type, "/") d.Set("name", disk.Name) d.Set("self_link", disk.SelfLink) - d.Set("type", typeUrlParts[len(typeUrlParts)-1]) - d.Set("zone", zoneUrlParts[len(zoneUrlParts)-1]) + d.Set("type", GetResourceNameFromSelfLink(disk.Type)) + d.Set("zone", GetResourceNameFromSelfLink(disk.Zone)) d.Set("size", disk.SizeGb) d.Set("users", disk.Users) if disk.DiskEncryptionKey != nil && disk.DiskEncryptionKey.Sha256 != "" { diff --git a/google/resource_compute_instance.go b/google/resource_compute_instance.go index 2903ab6e11b..393cff8a669 100644 --- a/google/resource_compute_instance.go +++ b/google/resource_compute_instance.go @@ -251,6 +251,7 @@ func resourceComputeInstance() *schema.Resource { "zone": &schema.Schema{ Type: schema.TypeString, Optional: true, + Computed: true, ForceNew: true, }, @@ -861,6 +862,7 @@ func resourceComputeInstanceRead(d *schema.ResourceData, meta interface{}) error d.Set("self_link", ConvertSelfLinkToV1(instance.SelfLink)) d.Set("instance_id", fmt.Sprintf("%d", instance.Id)) d.Set("project", project) + d.Set("zone", GetResourceNameFromSelfLink(instance.Zone)) d.Set("name", instance.Name) d.SetId(instance.Name) diff --git a/google/resource_compute_instance_group.go b/google/resource_compute_instance_group.go index 66da2bc8016..70f10f41b95 100644 --- a/google/resource_compute_instance_group.go +++ b/google/resource_compute_instance_group.go @@ -34,6 +34,7 @@ func resourceComputeInstanceGroup() *schema.Resource { "zone": { Type: schema.TypeString, Optional: true, + Computed: true, ForceNew: true, }, @@ -240,6 +241,7 @@ func resourceComputeInstanceGroupRead(d *schema.ResourceData, meta interface{}) d.Set("network", instanceGroup.Network) d.Set("size", instanceGroup.Size) d.Set("project", project) + d.Set("zone", zone) d.Set("self_link", instanceGroup.SelfLink) return nil diff --git a/google/resource_compute_instance_group_manager.go b/google/resource_compute_instance_group_manager.go index 9d44c494083..00a7bcab849 100644 --- a/google/resource_compute_instance_group_manager.go +++ b/google/resource_compute_instance_group_manager.go @@ -48,6 +48,7 @@ func resourceComputeInstanceGroupManager() *schema.Resource { "zone": &schema.Schema{ Type: schema.TypeString, Optional: true, + Computed: true, ForceNew: true, }, diff --git a/google/resource_compute_snapshot.go b/google/resource_compute_snapshot.go index 8f31df61b39..7ab1dc588a4 100644 --- a/google/resource_compute_snapshot.go +++ b/google/resource_compute_snapshot.go @@ -27,6 +27,7 @@ func resourceComputeSnapshot() *schema.Resource { "zone": &schema.Schema{ Type: schema.TypeString, Optional: true, + Computed: true, ForceNew: true, }, @@ -160,6 +161,11 @@ func resourceComputeSnapshotRead(d *schema.ResourceData, meta interface{}) error return err } + zone, err := getZone(d, config) + if err != nil { + return err + } + snapshot, err := config.clientCompute.Snapshots.Get( project, d.Id()).Do() if err != nil { @@ -181,6 +187,7 @@ func resourceComputeSnapshotRead(d *schema.ResourceData, meta interface{}) error d.Set("labels", snapshot.Labels) d.Set("label_fingerprint", snapshot.LabelFingerprint) d.Set("project", project) + d.Set("zone", zone) return nil } diff --git a/google/resource_container_cluster.go b/google/resource_container_cluster.go index 6badc77d652..4150c762962 100644 --- a/google/resource_container_cluster.go +++ b/google/resource_container_cluster.go @@ -69,6 +69,7 @@ func resourceContainerCluster() *schema.Resource { "zone": { Type: schema.TypeString, Optional: true, + Computed: true, ForceNew: true, }, @@ -622,6 +623,7 @@ func resourceContainerClusterRead(d *schema.ResourceData, meta interface{}) erro d.Set("network", cluster.Network) d.Set("subnetwork", cluster.Subnetwork) d.Set("node_config", flattenNodeConfig(cluster.NodeConfig)) + d.Set("zone", zoneName) d.Set("project", project) if cluster.AddonsConfig != nil { d.Set("addons_config", flattenClusterAddonsConfig(cluster.AddonsConfig)) diff --git a/google/resource_container_node_pool.go b/google/resource_container_node_pool.go index 4838ea7db9d..91102e013e4 100644 --- a/google/resource_container_node_pool.go +++ b/google/resource_container_node_pool.go @@ -45,6 +45,7 @@ func resourceContainerNodePool() *schema.Resource { "zone": &schema.Schema{ Type: schema.TypeString, Optional: true, + Computed: true, ForceNew: true, }, "cluster": &schema.Schema{ @@ -205,6 +206,7 @@ func resourceContainerNodePoolRead(d *schema.ResourceData, meta interface{}) err d.Set(k, v) } + d.Set("zone", zone) d.Set("project", project) return nil