Skip to content

Commit 14ff52b

Browse files
(Beta) support for SM GKE auto rotation (#14362) (#23482)
[upstream:a9aac07971c341b2d0ca3e11052e13a5d7c8f4c0] Signed-off-by: Modular Magician <[email protected]>
1 parent 3ad4a48 commit 14ff52b

File tree

4 files changed

+78
-6
lines changed

4 files changed

+78
-6
lines changed

.changelog/14362.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
container: added `secret_manager_config.rotation_config` field to `google_container_cluster` resource (beta)
3+
```

google/services/container/resource_container_cluster.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5673,10 +5673,11 @@ func expandSecretManagerConfig(configured interface{}) *container.SecretManagerC
56735673
}
56745674

56755675
config := l[0].(map[string]interface{})
5676-
return &container.SecretManagerConfig{
5676+
sc := &container.SecretManagerConfig{
56775677
Enabled: config["enabled"].(bool),
56785678
ForceSendFields: []string{"Enabled"},
56795679
}
5680+
return sc
56805681
}
56815682

56825683
func expandDefaultMaxPodsConstraint(v interface{}) *container.MaxPodsConstraint {
@@ -6606,11 +6607,11 @@ func flattenSecretManagerConfig(c *container.SecretManagerConfig) []map[string]i
66066607
},
66076608
}
66086609
}
6609-
return []map[string]interface{}{
6610-
{
6611-
"enabled": c.Enabled,
6612-
},
6613-
}
6610+
6611+
result := make(map[string]interface{})
6612+
6613+
result["enabled"] = c.Enabled
6614+
return []map[string]interface{}{result}
66146615
}
66156616

66166617
func flattenResourceUsageExportConfig(c *container.ResourceUsageExportConfig) []map[string]interface{} {

google/services/container/resource_container_cluster_test.go

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4064,6 +4064,24 @@ func TestAccContainerCluster_withSecretManagerConfig(t *testing.T) {
40644064
ImportStateVerify: true,
40654065
ImportStateVerifyIgnore: []string{"deletion_protection"},
40664066
},
4067+
{
4068+
Config: testAccContainerCluster_withSecretManagerRotationPeriodUpdated(pid, clusterName, networkName, subnetworkName),
4069+
},
4070+
{
4071+
ResourceName: "google_container_cluster.primary",
4072+
ImportState: true,
4073+
ImportStateVerify: true,
4074+
ImportStateVerifyIgnore: []string{"deletion_protection"},
4075+
},
4076+
{
4077+
Config: testAccContainerCluster_withSecretManagerConfigRotationDisabled(pid, clusterName, networkName, subnetworkName),
4078+
},
4079+
{
4080+
ResourceName: "google_container_cluster.primary",
4081+
ImportState: true,
4082+
ImportStateVerify: true,
4083+
ImportStateVerifyIgnore: []string{"deletion_protection"},
4084+
},
40674085
{
40684086
Config: testAccContainerCluster_withSecretManagerConfigUpdated(pid, clusterName, networkName, subnetworkName),
40694087
},
@@ -10676,6 +10694,50 @@ resource "google_container_cluster" "primary" {
1067610694
`, projectID, name, networkName, subnetworkName)
1067710695
}
1067810696

10697+
func testAccContainerCluster_withSecretManagerRotationPeriodUpdated(projectID, name, networkName, subnetworkName string) string {
10698+
return fmt.Sprintf(`
10699+
data "google_project" "project" {
10700+
project_id = "%s"
10701+
}
10702+
resource "google_container_cluster" "primary" {
10703+
name = "%s"
10704+
location = "us-central1-a"
10705+
initial_node_count = 1
10706+
secret_manager_config {
10707+
enabled = true
10708+
}
10709+
deletion_protection = false
10710+
network = "%s"
10711+
subnetwork = "%s"
10712+
workload_identity_config {
10713+
workload_pool = "${data.google_project.project.project_id}.svc.id.goog"
10714+
}
10715+
}
10716+
`, projectID, name, networkName, subnetworkName)
10717+
}
10718+
10719+
func testAccContainerCluster_withSecretManagerConfigRotationDisabled(projectID, name, networkName, subnetworkName string) string {
10720+
return fmt.Sprintf(`
10721+
data "google_project" "project" {
10722+
project_id = "%s"
10723+
}
10724+
resource "google_container_cluster" "primary" {
10725+
name = "%s"
10726+
location = "us-central1-a"
10727+
initial_node_count = 1
10728+
secret_manager_config {
10729+
enabled = true
10730+
}
10731+
deletion_protection = false
10732+
network = "%s"
10733+
subnetwork = "%s"
10734+
workload_identity_config {
10735+
workload_pool = "${data.google_project.project.project_id}.svc.id.goog"
10736+
}
10737+
}
10738+
`, projectID, name, networkName, subnetworkName)
10739+
}
10740+
1067910741
func testAccContainerCluster_withSecretManagerConfigUpdated(projectID, name, networkName, subnetworkName string) string {
1068010742
return fmt.Sprintf(`
1068110743
data "google_project" "project" {

website/docs/r/container_cluster.html.markdown

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,6 +1253,12 @@ notification_config {
12531253
<a name="nested_secret_manager_config"></a>The `secret_manager_config` block supports:
12541254

12551255
* `enabled` (Required) - Enable the Secret Manager add-on for this cluster.
1256+
* `rotation_config` (Optional, Beta) - config for secret manager auto rotation. Structure is [docuemented below](#rotation_config)
1257+
1258+
<a name="rotation_config"></a>The `rotation_config` block supports:
1259+
1260+
* `enabled` (Optional) - Enable the roation in Secret Manager add-on for this cluster.
1261+
* `rotation_interval` (Optional) - The interval between two consecutive rotations. Default rotation interval is 2 minutes.
12561262

12571263
<a name="nested_user_managed_keys_config"></a>The `user_managed_keys_config` block supports:
12581264

0 commit comments

Comments
 (0)