diff --git a/google/resource_dataproc_cluster.go b/google/resource_dataproc_cluster.go index 196c7320..d12ff650 100644 --- a/google/resource_dataproc_cluster.go +++ b/google/resource_dataproc_cluster.go @@ -144,7 +144,7 @@ func resourceDataprocCluster() *schema.Resource { }, "tags": { - Type: schema.TypeList, + Type: schema.TypeSet, Optional: true, ForceNew: true, Elem: &schema.Schema{Type: schema.TypeString}, @@ -541,7 +541,7 @@ func expandGceClusterConfig(d *schema.ResourceData, config *Config) (*dataproc.G conf.SubnetworkUri = snf.RelativeLink() } if v, ok := cfg["tags"]; ok { - conf.Tags = convertStringArr(v.([]interface{})) + conf.Tags = convertStringSet(v.(*schema.Set)) } if v, ok := cfg["service_account"]; ok { conf.ServiceAccount = v.(string) @@ -840,7 +840,7 @@ func flattenInitializationActions(nia []*dataproc.NodeInitializationAction) ([]m func flattenGceClusterConfig(d *schema.ResourceData, gcc *dataproc.GceClusterConfig) []map[string]interface{} { gceConfig := map[string]interface{}{ - "tags": gcc.Tags, + "tags": schema.NewSet(schema.HashString, convertStringArrToInterface(gcc.Tags)), "service_account": gcc.ServiceAccount, "zone": GetResourceNameFromSelfLink(gcc.ZoneUri), "internal_ip_only": gcc.InternalIpOnly, diff --git a/google/resource_dataproc_cluster_test.go b/google/resource_dataproc_cluster_test.go index 1f20bf5e..c8be786b 100644 --- a/google/resource_dataproc_cluster_test.go +++ b/google/resource_dataproc_cluster_test.go @@ -217,7 +217,7 @@ func TestAccDataprocCluster_withInternalIpOnlyTrue(t *testing.T) { }) } -func TestAccDataprocCluster_withMetadata(t *testing.T) { +func TestAccDataprocCluster_withMetadataAndTags(t *testing.T) { t.Parallel() var cluster dataproc.Cluster @@ -228,12 +228,13 @@ func TestAccDataprocCluster_withMetadata(t *testing.T) { CheckDestroy: testAccCheckDataprocClusterDestroy(), Steps: []resource.TestStep{ { - Config: testAccDataprocCluster_withMetadata(rnd), + Config: testAccDataprocCluster_withMetadataAndTags(rnd), Check: resource.ComposeTestCheckFunc( testAccCheckDataprocClusterExists("google_dataproc_cluster.basic", &cluster), resource.TestCheckResourceAttr("google_dataproc_cluster.basic", "cluster_config.0.gce_cluster_config.0.metadata.foo", "bar"), resource.TestCheckResourceAttr("google_dataproc_cluster.basic", "cluster_config.0.gce_cluster_config.0.metadata.baz", "qux"), + resource.TestCheckResourceAttr("google_dataproc_cluster.basic", "cluster_config.0.gce_cluster_config.0.tags.#", "4"), ), }, }, @@ -785,7 +786,7 @@ resource "google_dataproc_cluster" "basic" { `, rnd, rnd, rnd) } -func testAccDataprocCluster_withMetadata(rnd string) string { +func testAccDataprocCluster_withMetadataAndTags(rnd string) string { return fmt.Sprintf(` resource "google_dataproc_cluster" "basic" { name = "dproc-cluster-test-%s" @@ -797,6 +798,7 @@ resource "google_dataproc_cluster" "basic" { foo = "bar" baz = "qux" } + tags = ["my-tag", "your-tag", "our-tag", "their-tag"] } } }