diff --git a/google-beta/data_source_google_container_cluster.go b/google-beta/data_source_google_container_cluster.go index 91d8159c7f..65f0da2bab 100644 --- a/google-beta/data_source_google_container_cluster.go +++ b/google-beta/data_source_google_container_cluster.go @@ -12,7 +12,7 @@ func dataSourceGoogleContainerCluster() *schema.Resource { addRequiredFieldsToSchema(dsSchema, "name") // Set 'Optional' schema elements - addOptionalFieldsToSchema(dsSchema, "project", "zone", "region") + addOptionalFieldsToSchema(dsSchema, "project", "zone", "region", "location") return &schema.Resource{ Read: datasourceContainerClusterRead, diff --git a/google-beta/data_source_google_container_cluster_test.go b/google-beta/data_source_google_container_cluster_test.go index 414735f2ca..bdd3c6e579 100644 --- a/google-beta/data_source_google_container_cluster_test.go +++ b/google-beta/data_source_google_container_cluster_test.go @@ -110,18 +110,18 @@ func testAccContainerClusterDatasource_zonal() string { return fmt.Sprintf(` resource "google_container_cluster" "kubes" { name = "cluster-test-%s" - zone = "us-central1-a" + location = "us-central1-a" initial_node_count = 1 - + master_auth { username = "mr.yoda" password = "adoy.rm.123456789" } } - + data "google_container_cluster" "kubes" { - name = "${google_container_cluster.kubes.name}" - zone = "${google_container_cluster.kubes.zone}" + name = "${google_container_cluster.kubes.name}" + location = "${google_container_cluster.kubes.zone}" } `, acctest.RandString(10)) } @@ -130,13 +130,13 @@ func testAccContainerClusterDatasource_regional() string { return fmt.Sprintf(` resource "google_container_cluster" "kubes" { name = "cluster-test-%s" - region = "us-central1" + location = "us-central1" initial_node_count = 1 } - + data "google_container_cluster" "kubes" { - name = "${google_container_cluster.kubes.name}" - region = "${google_container_cluster.kubes.region}" + name = "${google_container_cluster.kubes.name}" + location = "${google_container_cluster.kubes.region}" } `, acctest.RandString(10)) } diff --git a/google-beta/data_source_google_container_engine_versions.go b/google-beta/data_source_google_container_engine_versions.go index adbb35f962..6058b3f4fc 100644 --- a/google-beta/data_source_google_container_engine_versions.go +++ b/google-beta/data_source_google_container_engine_versions.go @@ -20,14 +20,22 @@ func dataSourceGoogleContainerEngineVersions() *schema.Resource { Type: schema.TypeString, Optional: true, }, + "location": { + Type: schema.TypeString, + Optional: true, + ConflictsWith: []string{"zone", "region"}, + }, "zone": { - Type: schema.TypeString, - Optional: true, + Type: schema.TypeString, + Optional: true, + Deprecated: "Use location instead", + ConflictsWith: []string{"region", "location"}, }, "region": { Type: schema.TypeString, Optional: true, - ConflictsWith: []string{"zone"}, + Deprecated: "Use location instead", + ConflictsWith: []string{"zone", "location"}, }, "default_cluster_version": { Type: schema.TypeString, @@ -68,7 +76,7 @@ func dataSourceGoogleContainerEngineVersionsRead(d *schema.ResourceData, meta in return err } if len(location) == 0 { - return fmt.Errorf("Cannot determine location: set zone or region in this data source or at provider-level") + return fmt.Errorf("Cannot determine location: set location, zone, or region in this data source or at provider-level") } location = fmt.Sprintf("projects/%s/locations/%s", project, location) diff --git a/google-beta/data_source_google_container_engine_versions_test.go b/google-beta/data_source_google_container_engine_versions_test.go index e3f809dfda..7c0d5f1511 100644 --- a/google-beta/data_source_google_container_engine_versions_test.go +++ b/google-beta/data_source_google_container_engine_versions_test.go @@ -20,6 +20,7 @@ func TestAccContainerEngineVersions_basic(t *testing.T) { { Config: testAccCheckGoogleContainerEngineVersionsConfig, Check: resource.ComposeTestCheckFunc( + testAccCheckGoogleContainerEngineVersionsMeta("data.google_container_engine_versions.location"), testAccCheckGoogleContainerEngineVersionsMeta("data.google_container_engine_versions.versions"), ), }, @@ -55,6 +56,7 @@ func TestAccContainerEngineVersions_regional(t *testing.T) { { Config: testAccCheckGoogleContainerEngineVersionsRegionalConfig, Check: resource.ComposeTestCheckFunc( + testAccCheckGoogleContainerEngineVersionsMeta("data.google_container_engine_versions.location"), testAccCheckGoogleContainerEngineVersionsMeta("data.google_container_engine_versions.versions"), ), }, @@ -133,6 +135,10 @@ func testAccCheckGoogleContainerEngineVersionsMeta(n string) resource.TestCheckF } var testAccCheckGoogleContainerEngineVersionsConfig = ` +data "google_container_engine_versions" "location" { + location = "us-central1-b" +} + data "google_container_engine_versions" "versions" { zone = "us-central1-b" } @@ -146,6 +152,10 @@ data "google_container_engine_versions" "versions" { ` var testAccCheckGoogleContainerEngineVersionsRegionalConfig = ` +data "google_container_engine_versions" "location" { + location = "us-central1" +} + data "google_container_engine_versions" "versions" { region = "us-central1" } diff --git a/google-beta/regional_utils.go b/google-beta/regional_utils.go index 13f46bf96f..f6af074db1 100644 --- a/google-beta/regional_utils.go +++ b/google-beta/regional_utils.go @@ -14,7 +14,9 @@ func isZone(location string) bool { } func getLocation(d *schema.ResourceData, config *Config) (string, error) { - if v, isRegionalCluster := d.GetOk("region"); isRegionalCluster { + if v, ok := d.GetOk("location"); ok { + return v.(string), nil + } else if v, isRegionalCluster := d.GetOk("region"); isRegionalCluster { return v.(string), nil } else { // If region is not explicitly set, use "zone" (or fall back to the provider-level zone). diff --git a/google-beta/resource_container_cluster.go b/google-beta/resource_container_cluster.go index c43d574f7b..bb5b4b7969 100644 --- a/google-beta/resource_container_cluster.go +++ b/google-beta/resource_container_cluster.go @@ -96,12 +96,21 @@ func resourceContainerCluster() *schema.Resource { }, }, + "location": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + ConflictsWith: []string{"zone", "region"}, + }, + "region": { Type: schema.TypeString, Optional: true, Computed: true, ForceNew: true, - ConflictsWith: []string{"zone"}, + Deprecated: "Use location instead", + ConflictsWith: []string{"zone", "location"}, }, "zone": { @@ -109,16 +118,25 @@ func resourceContainerCluster() *schema.Resource { Optional: true, Computed: true, ForceNew: true, - ConflictsWith: []string{"region"}, + Deprecated: "Use location instead", + ConflictsWith: []string{"region", "location"}, }, - "additional_zones": { + "node_locations": { Type: schema.TypeSet, Optional: true, Computed: true, Elem: &schema.Schema{Type: schema.TypeString}, }, + "additional_zones": { + Type: schema.TypeSet, + Optional: true, + Computed: true, + Deprecated: "Use node_locations instead", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "addons_config": { Type: schema.TypeList, Optional: true, @@ -721,14 +739,29 @@ func resourceContainerClusterCreate(d *schema.ResourceData, meta interface{}) er } } - if v, ok := d.GetOk("additional_zones"); ok { + if v, ok := d.GetOk("node_locations"); ok { locationsSet := v.(*schema.Set) if locationsSet.Contains(location) { - return fmt.Errorf("additional_zones should not contain the original 'zone'") + return fmt.Errorf("when using a multi-zonal cluster, additional_zones should not contain the original 'zone'") + } + + // GKE requires a full list of node locations + // but when using a multi-zonal cluster our schema only asks for the + // additional zones, so append the cluster location if it's a zone + if isZone(location) { + locationsSet.Add(location) + } + cluster.Locations = convertStringSet(locationsSet) + } else if v, ok := d.GetOk("additional_zones"); ok { + locationsSet := v.(*schema.Set) + if locationsSet.Contains(location) { + return fmt.Errorf("when using a multi-zonal cluster, additional_zones should not contain the original 'zone'") } + + // GKE requires a full list of node locations + // but when using a multi-zonal cluster our schema only asks for the + // additional zones, so append the cluster location if it's a zone if isZone(location) { - // GKE requires a full list of locations (including the original zone), - // but our schema only asks for additional zones, so append the original. locationsSet.Add(location) } cluster.Locations = convertStringSet(locationsSet) @@ -859,10 +892,17 @@ func resourceContainerClusterRead(d *schema.ResourceData, meta interface{}) erro if err := d.Set("network_policy", flattenNetworkPolicy(cluster.NetworkPolicy)); err != nil { return err } - d.Set("zone", cluster.Zone) + + d.Set("location", cluster.Location) + if isZone(cluster.Location) { + d.Set("zone", cluster.Location) + } else { + d.Set("region", cluster.Location) + } locations := schema.NewSet(schema.HashString, convertStringArrToInterface(cluster.Locations)) locations.Remove(cluster.Zone) // Remove the original zone since we only store additional zones + d.Set("node_locations", locations) d.Set("additional_zones", locations) d.Set("endpoint", cluster.Endpoint) @@ -1078,6 +1118,9 @@ func resourceContainerClusterUpdate(d *schema.ResourceData, meta interface{}) er d.SetPartial("maintenance_policy") } + // we can only ever see a change to one of additional_zones and node_locations; because + // thy conflict with each other and are each computed, Terraform will suppress the diff + // on one of them even when migrating from one to the other. if d.HasChange("additional_zones") { azSetOldI, azSetNewI := d.GetChange("additional_zones") azSetNew := azSetNewI.(*schema.Set) @@ -1099,7 +1142,7 @@ func resourceContainerClusterUpdate(d *schema.ResourceData, meta interface{}) er }, } - updateF := updateFunc(req, "updating GKE cluster locations") + updateF := updateFunc(req, "updating GKE cluster node locations") // Call update serially. if err := lockedCall(lockKey, updateF); err != nil { return err @@ -1115,16 +1158,63 @@ func resourceContainerClusterUpdate(d *schema.ResourceData, meta interface{}) er }, } - updateF := updateFunc(req, "updating GKE cluster locations") + updateF := updateFunc(req, "updating GKE cluster node locations") // Call update serially. if err := lockedCall(lockKey, updateF); err != nil { return err } } - log.Printf("[INFO] GKE cluster %s locations have been updated to %v", d.Id(), azSet.List()) + log.Printf("[INFO] GKE cluster %s node locations have been updated to %v", d.Id(), azSet.List()) d.SetPartial("additional_zones") + } else if d.HasChange("node_locations") { + azSetOldI, azSetNewI := d.GetChange("node_locations") + azSetNew := azSetNewI.(*schema.Set) + azSetOld := azSetOldI.(*schema.Set) + if azSetNew.Contains(location) { + return fmt.Errorf("for multi-zonal clusters, node_locations should not contain the primary 'zone'") + } + // Since we can't add & remove zones in the same request, first add all the + // zones, then remove the ones we aren't using anymore. + azSet := azSetOld.Union(azSetNew) + + if isZone(location) { + azSet.Add(location) + } + + req := &containerBeta.UpdateClusterRequest{ + Update: &containerBeta.ClusterUpdate{ + DesiredLocations: convertStringSet(azSet), + }, + } + + updateF := updateFunc(req, "updating GKE cluster node locations") + // Call update serially. + if err := lockedCall(lockKey, updateF); err != nil { + return err + } + + if isZone(location) { + azSetNew.Add(location) + } + if !azSet.Equal(azSetNew) { + req = &containerBeta.UpdateClusterRequest{ + Update: &containerBeta.ClusterUpdate{ + DesiredLocations: convertStringSet(azSetNew), + }, + } + + updateF := updateFunc(req, "updating GKE cluster node locations") + // Call update serially. + if err := lockedCall(lockKey, updateF); err != nil { + return err + } + } + + log.Printf("[INFO] GKE cluster %s node locations have been updated to %v", d.Id(), azSet.List()) + + d.SetPartial("node_locations") } if d.HasChange("enable_legacy_abac") { @@ -2045,7 +2135,7 @@ func resourceContainerClusterStateImporter(d *schema.ResourceData, meta interfac location = parts[1] clusterName = parts[2] default: - return nil, fmt.Errorf("Invalid container cluster specifier. Expecting {zone}/{name} or {project}/{zone}/{name}") + return nil, fmt.Errorf("Invalid container cluster specifier. Expecting {location}/{name} or {project}/{location}/{name}") } if len(project) == 0 { @@ -2057,6 +2147,7 @@ func resourceContainerClusterStateImporter(d *schema.ResourceData, meta interfac } d.Set("project", project) + d.Set("location", location) if isZone(location) { d.Set("zone", location) } else { diff --git a/google-beta/resource_container_cluster_test.go b/google-beta/resource_container_cluster_test.go index c56de861db..a5a5da86eb 100644 --- a/google-beta/resource_container_cluster_test.go +++ b/google-beta/resource_container_cluster_test.go @@ -1714,8 +1714,8 @@ func matchError(attr, tf interface{}, gcp interface{}) string { func testAccContainerCluster_basic(name string) string { return fmt.Sprintf(` resource "google_container_cluster" "primary" { - name = "%s" - zone = "us-central1-a" + name = "%s" + location = "us-central1-a" initial_node_count = 3 }`, name) } @@ -1967,8 +1967,8 @@ resource "google_container_cluster" "with_master_authorized_networks" { func testAccContainerCluster_regional(clusterName string) string { return fmt.Sprintf(` resource "google_container_cluster" "regional" { - name = "%s" - region = "us-central1" + name = "%s" + location = "us-central1" initial_node_count = 1 }`, clusterName) } @@ -1985,6 +1985,7 @@ resource "google_container_cluster" "regional" { }`, cluster, nodePool) } +// This uses zone/additional_zones over location/node_locations to ensure we can update from old -> new func testAccContainerCluster_withAdditionalZones(clusterName string) string { return fmt.Sprintf(` resource "google_container_cluster" "with_additional_zones" { @@ -2002,17 +2003,18 @@ resource "google_container_cluster" "with_additional_zones" { func testAccContainerCluster_updateAdditionalZones(clusterName string) string { return fmt.Sprintf(` resource "google_container_cluster" "with_additional_zones" { - name = "%s" - zone = "us-central1-a" + name = "%s" + location = "us-central1-a" initial_node_count = 1 - additional_zones = [ + node_locations = [ "us-central1-f", "us-central1-c", ] }`, clusterName) } +// This uses region/additional_zones over location/node_locations to ensure we can update from old -> new func testAccContainerCluster_regionalAdditionalZones(clusterName string) string { return fmt.Sprintf(` resource "google_container_cluster" "with_additional_zones" { @@ -2030,11 +2032,11 @@ resource "google_container_cluster" "with_additional_zones" { func testAccContainerCluster_regionalUpdateAdditionalZones(clusterName string) string { return fmt.Sprintf(` resource "google_container_cluster" "with_additional_zones" { - name = "%s" - region = "us-central1" + name = "%s" + location = "us-central1" initial_node_count = 1 - additional_zones = [ + node_locations = [ "us-central1-f", "us-central1-b", ] diff --git a/google-beta/resource_container_node_pool.go b/google-beta/resource_container_node_pool.go index 175a6e6b39..ee7fdf51e0 100644 --- a/google-beta/resource_container_node_pool.go +++ b/google-beta/resource_container_node_pool.go @@ -42,20 +42,29 @@ func resourceContainerNodePool() *schema.Resource { Computed: true, ForceNew: true, }, - "zone": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, "cluster": { Type: schema.TypeString, Required: true, ForceNew: true, }, + "zone": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Deprecated: "use location instead", + ForceNew: true, + }, "region": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Deprecated: "use location instead", + ForceNew: true, + }, + "location": { Type: schema.TypeString, Optional: true, + Computed: true, ForceNew: true, }, }), @@ -306,6 +315,7 @@ func resourceContainerNodePoolRead(d *schema.ResourceData, meta interface{}) err d.Set("region", nodePoolInfo.location) } + d.Set("location", nodePoolInfo.location) d.Set("project", nodePoolInfo.project) return nil @@ -411,6 +421,7 @@ func resourceContainerNodePoolStateImporter(d *schema.ResourceData, meta interfa d.Set("region", location) } + d.Set("location", location) d.Set("cluster", parts[1]) d.Set("name", parts[2]) case 4: @@ -423,13 +434,14 @@ func resourceContainerNodePoolStateImporter(d *schema.ResourceData, meta interfa d.Set("region", location) } + d.Set("location", location) d.Set("cluster", parts[2]) d.Set("name", parts[3]) // override the inputted ID with the // format d.SetId(strings.Join(parts[1:], "/")) default: - return nil, fmt.Errorf("Invalid container cluster specifier. Expecting {zone}/{cluster}/{name} or {project}/{zone}/{cluster}/{name}") + return nil, fmt.Errorf("Invalid container cluster specifier. Expecting {location}/{cluster}/{name} or {project}/{location}/{cluster}/{name}") } return []*schema.ResourceData{d}, nil diff --git a/google-beta/resource_container_node_pool_test.go b/google-beta/resource_container_node_pool_test.go index e5a191c0b8..a75f46dc4f 100644 --- a/google-beta/resource_container_node_pool_test.go +++ b/google-beta/resource_container_node_pool_test.go @@ -530,15 +530,15 @@ func TestAccContainerNodePool_regionalClusters(t *testing.T) { func testAccContainerNodePool_basic(cluster, np string) string { return fmt.Sprintf(` resource "google_container_cluster" "cluster" { - name = "%s" - zone = "us-central1-a" + name = "%s" + location = "us-central1-a" initial_node_count = 3 } resource "google_container_node_pool" "np" { - name = "%s" - zone = "us-central1-a" - cluster = "${google_container_cluster.cluster.name}" + name = "%s" + location = "us-central1-a" + cluster = "${google_container_cluster.cluster.name}" initial_node_count = 2 }`, cluster, np) } @@ -603,15 +603,15 @@ resource "google_container_node_pool" "np" { func testAccContainerNodePool_regionalClusters(cluster, np string) string { return fmt.Sprintf(` resource "google_container_cluster" "cluster" { - name = "%s" - region = "us-central1" + name = "%s" + location = "us-central1" initial_node_count = 3 } resource "google_container_node_pool" "np" { - name = "%s" - cluster = "${google_container_cluster.cluster.name}" - region = "us-central1" + name = "%s" + cluster = "${google_container_cluster.cluster.name}" + location = "us-central1" initial_node_count = 2 }`, cluster, np) } @@ -706,6 +706,7 @@ resource "google_container_node_pool" "np" { }`, cluster, np) } +// This uses zone/additional_zones over location/node_locations to ensure we can update from old -> new func testAccContainerNodePool_additionalZones(cluster, nodePool string) string { return fmt.Sprintf(` resource "google_container_cluster" "cluster" { @@ -730,20 +731,20 @@ resource "google_container_node_pool" "np" { func testAccContainerNodePool_resize(cluster, nodePool string) string { return fmt.Sprintf(` resource "google_container_cluster" "cluster" { - name = "%s" - zone = "us-central1-a" + name = "%s" + location = "us-central1-a" initial_node_count = 1 - additional_zones = [ + node_locations = [ "us-central1-b", "us-central1-c" ] } resource "google_container_node_pool" "np" { - name = "%s" - zone = "us-central1-a" - cluster = "${google_container_cluster.cluster.name}" + name = "%s" + location = "us-central1-a" + cluster = "${google_container_cluster.cluster.name}" node_count = 3 }`, cluster, nodePool) } diff --git a/website/docs/d/google_container_cluster.html.markdown b/website/docs/d/google_container_cluster.html.markdown index 091f8f119d..44a3a433d3 100644 --- a/website/docs/d/google_container_cluster.html.markdown +++ b/website/docs/d/google_container_cluster.html.markdown @@ -3,19 +3,19 @@ layout: "google" page_title: "Google: google_container_cluster" sidebar_current: "docs-google-datasource-container-cluster" description: |- - Get info about a Google Kubernetes cluster. + Get info about a Google Kubernetes Engine cluster. --- # google\_container\_cluster -Get info about a cluster within GKE from its name and zone. +Get info about a GKE cluster from its name and location. ## Example Usage ```tf data "google_container_cluster" "my_cluster" { - name = "my-cluster" - zone = "us-east1-a" + name = "my-cluster" + location = "us-east1-a" } output "cluster_username" { @@ -47,9 +47,17 @@ output "node_pools" { The following arguments are supported: -* `name` - The name of the cluster. +* `name` (Required) - The name of the cluster. -* `zone` or `region` - The zone or region this cluster has been created in. +* `location` (Optional) - The location (zone or region) this cluster has been +created in. One of `location`, `region`, `zone`, or a provider-level `zone` must +be specified. + +* `zone` (Optional) - The zone this cluster has been created in. Deprecated in +favour of `location`. + +* `region` (Optional) - The region this cluster has been created in. Deprecated +in favour of `location`. - - - @@ -58,4 +66,4 @@ The following arguments are supported: ## Attributes Reference -See [google_container_cluster](https://www.terraform.io/docs/providers/google/r/container_cluster.html) resource for details of the available attributes. \ No newline at end of file +See [google_container_cluster](https://www.terraform.io/docs/providers/google/r/container_cluster.html) resource for details of the available attributes. diff --git a/website/docs/d/google_container_engine_versions.html.markdown b/website/docs/d/google_container_engine_versions.html.markdown index 245e800e47..a7eae609ac 100644 --- a/website/docs/d/google_container_engine_versions.html.markdown +++ b/website/docs/d/google_container_engine_versions.html.markdown @@ -3,28 +3,30 @@ layout: "google" page_title: "Google: google_container_engine_versions" sidebar_current: "docs-google-datasource-container-versions" description: |- - Provides lists of available Google Container Engine versions for masters and nodes. + Provides lists of available Google Kubernetes Engine versions for masters and nodes. --- # google\_container\_engine\_versions -Provides access to available Google Container Engine versions in a zone or region for a given project. +Provides access to available Google Kubernetes Engine versions in a zone or region for a given project. --> If you are using the `google_container_engine_versions` datasource with a regional cluster, ensure that you have provided a `region` -to the datasource. A `region` can have a different set of supported versions than its corresponding `zone`s, and not all `zone`s in a -`region` are guaranteed to support the same version. +-> If you are using the `google_container_engine_versions` datasource with a +regional cluster, ensure that you have provided a region as the `location` to +the datasource. A region can have a different set of supported versions than +its component zones, and not all zones in a region are guaranteed to +support the same version. ## Example Usage ```hcl data "google_container_engine_versions" "central1b" { - zone = "us-central1-b" + location = "us-central1-b" version_prefix = "1.12." } resource "google_container_cluster" "foo" { name = "terraform-test-cluster" - zone = "us-central1-b" + location = "us-central1-b" node_version = "${data.google_container_engine_versions.central1b.latest_node_version}" initial_node_count = 1 @@ -39,17 +41,23 @@ resource "google_container_cluster" "foo" { The following arguments are supported: -* `zone` (optional) - Zone to list available cluster versions for. Should match the zone the cluster will be deployed in. - If not specified, the provider-level zone is used. One of zone or provider-level zone is required. +* `location` (Optional) - The location (region or zone) to list versions for. +Must exactly match the location the cluster will be deployed in, or listed +versions may not be available. If `location`, `region`, and `zone` are not +specified, the provider-level zone must be set and is used instead. -* `region` (optional, [Beta](https://terraform.io/docs/providers/google/provider_versions.html)) - Region to list available cluster versions for. Should match the region the cluster will be deployed in. - For regional clusters, this value must be specified and cannot be inferred from provider-level region. One of zone, - region, or provider-level zone is required. +* `zone` (Optional, Deprecated) - Zone to list available cluster versions for. +Should match the zone the cluster will be deployed in. `zone` has been +deprecated in favour of `location`. -* `project` (optional) - ID of the project to list available cluster versions for. Should match the project the cluster will be deployed to. +* `region` (Optional, Deprecated) - Region to list available cluster versions +for. Should match the region the cluster will be deployed in. `region` has been +deprecated in favour of `location`. + +* `project` (Optional) - ID of the project to list available cluster versions for. Should match the project the cluster will be deployed to. Defaults to the project that the provider is authenticated with. -* `version_prefix` (optional) - If provided, Terraform will only return versions +* `version_prefix` (Optional) - If provided, Terraform will only return versions that match the string prefix. For example, `1.11.` will match all `1.11` series releases. Since this is just a string match, it's recommended that you append a `.` after minor versions to ensure that prefixes such as `1.1` don't match diff --git a/website/docs/r/container_cluster.html.markdown b/website/docs/r/container_cluster.html.markdown index d18eecb22f..a3e2c26707 100644 --- a/website/docs/r/container_cluster.html.markdown +++ b/website/docs/r/container_cluster.html.markdown @@ -20,8 +20,8 @@ plaintext. [Read more about sensitive data in state](/docs/state/sensitive-data. ```hcl resource "google_container_cluster" "primary" { - name = "my-gke-cluster" - region = "us-central1" + name = "my-gke-cluster" + location = "us-central1" # We can't create a cluster with no node pool defined, but we want to only use # separately managed node pools. So we create the smallest possible default @@ -53,7 +53,7 @@ resource "google_container_cluster" "primary" { resource "google_container_node_pool" "primary_preemptible_nodes" { name = "my-node-pool" - region = "us-central1" + location = "us-central1" cluster = "${google_container_cluster.primary.name}" node_count = 1 @@ -90,7 +90,7 @@ output "cluster_ca_certificate" { ```hcl resource "google_container_cluster" "primary" { name = "marcellus-wallace" - zone = "us-central1-a" + location = "us-central1-a" initial_node_count = 3 # Setting an empty username and password explicitly disables basic auth @@ -138,25 +138,50 @@ output "cluster_ca_certificate" { ## Argument Reference * `name` - (Required) The name of the cluster, unique within the project and - zone. +location. - - - -* `zone` - (Optional) The zone that the master and the number of nodes specified - in `initial_node_count` should be created in. Only one of `zone` and `region` - may be set. If neither zone nor region are set, the provider zone is used. - -* `region` (Optional) - The region to create the cluster in for - [Regional Clusters](https://cloud.google.com/kubernetes-engine/docs/concepts/multi-zone-and-regional-clusters#regional). - In a Regional Cluster, the number of nodes specified in `initial_node_count` is - created in each of three zones of the region (this can be changed by setting - `additional_zones`). - -* `additional_zones` - (Optional) The list of additional Google Compute Engine - locations in which the cluster's nodes should be located. If additional zones are - configured, the number of nodes specified in `initial_node_count` is created in - all specified zones. +* `location` - (Optional) The location (region or zone) in which the cluster +master will be created, as well as the default node location. If you specify a +zone (such as `us-central1-a`), the cluster will be a zonal cluster with a +single cluster master. If you specify a region (such as `us-west1`), the +cluster will be a regional cluster with multiple masters spread across zones in +the region, and with default node locations in those zones as well. + +* `zone` - (Optional, Deprecated) The zone that the cluster master and nodes +should be created in. If specified, this cluster will be a zonal cluster. `zone` +has been deprecated in favour of `location`. + +* `region` (Optional, Deprecated) The region that the cluster master and nodes +should be created in. If specified, this cluster will be a [regional clusters](https://cloud.google.com/kubernetes-engine/docs/concepts/multi-zone-and-regional-clusters#regional) +where the cluster master and nodes (by default) will be created in several zones +throughout the region. `region` has been deprecated in favour of `location`. + +~> Only one of `location`, `zone`, and `region` may be set. If none are set, +the provider zone is used to create a zonal cluster. + +* `node_locations` - (Optional) The list of zones in which the cluster's nodes +should be located. These must be in the same region as the cluster zone for +zonal clusters, or in the region of a regional cluster. In a multi-zonal cluster, +the number of nodes specified in `initial_node_count` is created in +all specified zones as well as the primary zone. If specified for a regional +cluster, nodes will be created in only these zones. + +-> A "multi-zonal" cluster is a zonal cluster with at least one additional zone +defined; in a multi-zonal cluster, the cluster master is only present in a +single zone while nodes are present in each of the primary zone and the node +locations. In contrast, in a regional cluster, cluster master nodes are present +in multiple zones in the region. For that reason, regional clusters should be +preferred. + +* `additional_zones` - (Optional) The list of zones in which the cluster's nodes +should be located. These must be in the same region as the cluster zone for +zonal clusters, or in the region of a regional cluster. In a multi-zonal cluster, +the number of nodes specified in `initial_node_count` is created in +all specified zones as well as the primary zone. If specified for a regional +cluster, nodes will only be created in these zones. `additional_zones` has been +deprecated in favour of `node_locations`. * `addons_config` - (Optional) The configuration for addons supported by GKE. Structure is documented below. diff --git a/website/docs/r/container_node_pool.html.markdown b/website/docs/r/container_node_pool.html.markdown index 099b1074a7..ed3220b4a7 100644 --- a/website/docs/r/container_node_pool.html.markdown +++ b/website/docs/r/container_node_pool.html.markdown @@ -16,8 +16,8 @@ and [the API reference](https://cloud.google.com/container-engine/reference/rest ```hcl resource "google_container_cluster" "primary" { - name = "my-gke-cluster" - region = "us-central1" + name = "my-gke-cluster" + location = "us-central1" # We can't create a cluster with no node pool defined, but we want to only use # separately managed node pools. So we create the smallest possible default @@ -28,7 +28,7 @@ resource "google_container_cluster" "primary" { resource "google_container_node_pool" "primary_preemptible_nodes" { name = "my-node-pool" - region = "us-central1" + location = "us-central1" cluster = "${google_container_cluster.primary.name}" node_count = 1 @@ -51,7 +51,7 @@ resource "google_container_node_pool" "primary_preemptible_nodes" { ```hcl resource "google_container_node_pool" "np" { name = "my-node-pool" - zone = "us-central1-a" + location = "us-central1-a" cluster = "${google_container_cluster.primary.name}" node_count = 3 @@ -63,10 +63,10 @@ resource "google_container_node_pool" "np" { resource "google_container_cluster" "primary" { name = "marcellus-wallace" - zone = "us-central1-a" + location = "us-central1-a" initial_node_count = 3 - additional_zones = [ + node_locations = [ "us-central1-c", ] @@ -99,11 +99,17 @@ resource "google_container_cluster" "primary" { - - - -* `zone` - (Optional) The zone in which the cluster resides. +* `location` - (Optional) The location (region or zone) in which the cluster +resides. -* `region` - (Optional) The region in which the cluster resides (for regional clusters). +* `zone` - (Optional, Deprecated) The zone in which the cluster resides. `zone` +has been deprecated in favor of `location`. --> Note: You must be provide `region` for regional clusters and `zone` for zonal clusters +* `region` - (Optional, Deprecated) The region in which the cluster resides (for +regional clusters). `zone` has been deprecated in favor of `location`. + +-> Note: You must specify a `location` for either cluster type or the +type-specific `region` for regional clusters / `zone` for zonal clusters. - - -