Skip to content

Commit b8adcc2

Browse files
mrparkersdanawillow
authored andcommitted
Updates container_cluster to set enable_legacy_abac to false by default (#1281)
* Updates the default GKE legacy ABAC setting to false * Updates docs for container_cluster * Update test comments * Format fix * Adds ImportState test step to default legacy ABAC test
1 parent f8efd63 commit b8adcc2

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

google/resource_container_cluster.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ func resourceContainerCluster() *schema.Resource {
206206
"enable_legacy_abac": {
207207
Type: schema.TypeBool,
208208
Optional: true,
209-
Default: true,
209+
Default: false,
210210
},
211211

212212
"initial_node_count": {

google/resource_container_cluster_test.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,35 @@ func TestAccContainerCluster_withLegacyAbac(t *testing.T) {
374374
})
375375
}
376376

377+
/*
378+
Since GKE disables legacy ABAC by default in Kubernetes version 1.8+, and the default Kubernetes
379+
version for GKE is also 1.8+, this test will ensure that legacy ABAC is disabled by default to be
380+
more consistent with default settings in the Cloud Console
381+
*/
382+
func TestAccContainerCluster_withDefaultLegacyAbac(t *testing.T) {
383+
t.Parallel()
384+
385+
resource.Test(t, resource.TestCase{
386+
PreCheck: func() { testAccPreCheck(t) },
387+
Providers: testAccProviders,
388+
CheckDestroy: testAccCheckContainerClusterDestroy,
389+
Steps: []resource.TestStep{
390+
{
391+
Config: testAccContainerCluster_defaultLegacyAbac(acctest.RandString(10)),
392+
Check: resource.ComposeTestCheckFunc(
393+
resource.TestCheckResourceAttr("google_container_cluster.default_legacy_abac", "enable_legacy_abac", "false"),
394+
),
395+
},
396+
{
397+
ResourceName: "google_container_cluster.default_legacy_abac",
398+
ImportStateIdPrefix: "us-central1-a/",
399+
ImportState: true,
400+
ImportStateVerify: true,
401+
},
402+
},
403+
})
404+
}
405+
377406
func TestAccContainerCluster_withVersion(t *testing.T) {
378407
t.Parallel()
379408

@@ -1320,6 +1349,15 @@ resource "google_container_cluster" "with_kubernetes_alpha" {
13201349
}`, clusterName)
13211350
}
13221351

1352+
func testAccContainerCluster_defaultLegacyAbac(clusterName string) string {
1353+
return fmt.Sprintf(`
1354+
resource "google_container_cluster" "default_legacy_abac" {
1355+
name = "cluster-test-%s"
1356+
zone = "us-central1-a"
1357+
initial_node_count = 1
1358+
}`, clusterName)
1359+
}
1360+
13231361
func testAccContainerCluster_withLegacyAbac(clusterName string) string {
13241362
return fmt.Sprintf(`
13251363
resource "google_container_cluster" "with_legacy_abac" {

website/docs/r/container_cluster.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ output "cluster_ca_certificate" {
9494
* `enable_legacy_abac` - (Optional) Whether the ABAC authorizer is enabled for this cluster.
9595
When enabled, identities in the system, including service accounts, nodes, and controllers,
9696
will have statically granted permissions beyond those provided by the RBAC configuration or IAM.
97-
Defaults to `true`
97+
Defaults to `false`
9898

9999
* `initial_node_count` - (Optional) The number of nodes to create in this
100100
cluster (not including the Kubernetes master). Must be set if `node_pool` is not set.

0 commit comments

Comments
 (0)