Skip to content

Commit

Permalink
fix beta dataproc resources by adding min_cpu_platform in all the pla…
Browse files Browse the repository at this point in the history
…ces it exists in the API (hashicorp#848)

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored and danawillow committed Jun 17, 2019
1 parent 7175929 commit b538e09
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
13 changes: 7 additions & 6 deletions google-beta/resource_dataproc_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,7 @@ func resourceDataprocCluster() *schema.Resource {
// API does not honour this if set ...
// It always uses whatever is specified for the worker_config
// "machine_type": { ... }
"min_cpu_platform": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
// "min_cpu_platform": { ... }
"disk_config": {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -363,6 +358,12 @@ func instanceConfigSchema() *schema.Schema {
ForceNew: true,
},

"min_cpu_platform": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
"disk_config": {
Type: schema.TypeList,
Optional: true,
Expand Down
10 changes: 7 additions & 3 deletions google-beta/resource_dataproc_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"

"google.golang.org/api/dataproc/v1"
dataproc "google.golang.org/api/dataproc/v1beta2"
"google.golang.org/api/googleapi"
)

Expand Down Expand Up @@ -523,7 +523,7 @@ func testAccCheckDataprocClusterDestroy() resource.TestCheckFunc {
return err
}

_, err = config.clientDataproc.Projects.Regions.Clusters.Get(
_, err = config.clientDataprocBeta.Projects.Regions.Clusters.Get(
project, attributes["region"], rs.Primary.ID).Do()

if err != nil {
Expand Down Expand Up @@ -623,13 +623,15 @@ func validateDataprocCluster_withConfigOverrides(n string, cluster *dataproc.Clu
{"cluster_config.0.master_config.0.disk_config.0.boot_disk_type", "pd-ssd", cluster.Config.MasterConfig.DiskConfig.BootDiskType},
{"cluster_config.0.master_config.0.machine_type", "n1-standard-1", GetResourceNameFromSelfLink(cluster.Config.MasterConfig.MachineTypeUri)},
{"cluster_config.0.master_config.0.instance_names.#", "3", strconv.Itoa(len(cluster.Config.MasterConfig.InstanceNames))},
{"cluster_config.0.master_config.0.min_cpu_platform", "Intel Skylake", cluster.Config.MasterConfig.MinCpuPlatform},

{"cluster_config.0.worker_config.0.num_instances", "3", strconv.Itoa(int(cluster.Config.WorkerConfig.NumInstances))},
{"cluster_config.0.worker_config.0.disk_config.0.boot_disk_size_gb", "16", strconv.Itoa(int(cluster.Config.WorkerConfig.DiskConfig.BootDiskSizeGb))},
{"cluster_config.0.worker_config.0.disk_config.0.num_local_ssds", "1", strconv.Itoa(int(cluster.Config.WorkerConfig.DiskConfig.NumLocalSsds))},
{"cluster_config.0.worker_config.0.disk_config.0.boot_disk_type", "pd-standard", cluster.Config.WorkerConfig.DiskConfig.BootDiskType},
{"cluster_config.0.worker_config.0.machine_type", "n1-standard-1", GetResourceNameFromSelfLink(cluster.Config.WorkerConfig.MachineTypeUri)},
{"cluster_config.0.worker_config.0.instance_names.#", "3", strconv.Itoa(len(cluster.Config.WorkerConfig.InstanceNames))},
{"cluster_config.0.worker_config.0.min_cpu_platform", "Intel Broadwell", cluster.Config.WorkerConfig.MinCpuPlatform},

{"cluster_config.0.preemptible_worker_config.0.num_instances", "1", strconv.Itoa(int(cluster.Config.SecondaryWorkerConfig.NumInstances))},
{"cluster_config.0.preemptible_worker_config.0.disk_config.0.boot_disk_size_gb", "17", strconv.Itoa(int(cluster.Config.SecondaryWorkerConfig.DiskConfig.BootDiskSizeGb))},
Expand Down Expand Up @@ -669,7 +671,7 @@ func testAccCheckDataprocClusterExists(n string, cluster *dataproc.Cluster) reso
return err
}

found, err := config.clientDataproc.Projects.Regions.Clusters.Get(
found, err := config.clientDataprocBeta.Projects.Regions.Clusters.Get(
project, rs.Primary.Attributes["region"], rs.Primary.ID).Do()
if err != nil {
return err
Expand Down Expand Up @@ -863,6 +865,7 @@ resource "google_dataproc_cluster" "with_config_overrides" {
boot_disk_type = "pd-ssd"
boot_disk_size_gb = 15
}
min_cpu_platform = "Intel Skylake"
}
worker_config {
Expand All @@ -873,6 +876,7 @@ resource "google_dataproc_cluster" "with_config_overrides" {
boot_disk_size_gb = 16
num_local_ssds = 1
}
min_cpu_platform = "Intel Broadwell"
}
preemptible_worker_config {
Expand Down

0 comments on commit b538e09

Please sign in to comment.