Skip to content

Commit 69e2d0a

Browse files
(GA) support for SM-GKE Auto rotation (#15040) (#24244)
[upstream:78ad34e2dbe6679c108ab9cf33de9bf0d08f96c8] Signed-off-by: Modular Magician <[email protected]>
1 parent f29e964 commit 69e2d0a

File tree

4 files changed

+67
-1
lines changed

4 files changed

+67
-1
lines changed

.changelog/15040.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
3+
```

google/services/container/resource_container_cluster.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,6 +1534,28 @@ func ResourceContainerCluster() *schema.Resource {
15341534
Required: true,
15351535
Description: `Enable the Secret manager csi component.`,
15361536
},
1537+
"rotation_config": {
1538+
Type: schema.TypeList,
1539+
Optional: true,
1540+
Computed: true,
1541+
MaxItems: 1,
1542+
Description: `Configuration for Secret Manager auto rotation.`,
1543+
Elem: &schema.Resource{
1544+
Schema: map[string]*schema.Schema{
1545+
"enabled": {
1546+
Type: schema.TypeBool,
1547+
Required: true,
1548+
Description: `Enable the Secret manager auto rotation.`,
1549+
},
1550+
"rotation_interval": {
1551+
Type: schema.TypeString,
1552+
Optional: true,
1553+
Computed: true,
1554+
Description: `The interval between two consecutive rotations. Default rotation interval is 2 minutes`,
1555+
},
1556+
},
1557+
},
1558+
},
15371559
},
15381560
},
15391561
},
@@ -5963,6 +5985,23 @@ func expandSecretManagerConfig(configured interface{}) *container.SecretManagerC
59635985
Enabled: config["enabled"].(bool),
59645986
ForceSendFields: []string{"Enabled"},
59655987
}
5988+
if autoRotation, ok := config["rotation_config"]; ok {
5989+
if autoRotationList, ok := autoRotation.([]interface{}); ok {
5990+
if len(autoRotationList) > 0 {
5991+
autoRotationConfig := autoRotationList[0].(map[string]interface{})
5992+
if rotationInterval, ok := autoRotationConfig["rotation_interval"].(string); ok && rotationInterval != "" {
5993+
sc.RotationConfig = &container.RotationConfig{
5994+
Enabled: autoRotationConfig["enabled"].(bool),
5995+
RotationInterval: rotationInterval,
5996+
}
5997+
} else {
5998+
sc.RotationConfig = &container.RotationConfig{
5999+
Enabled: autoRotationConfig["enabled"].(bool),
6000+
}
6001+
}
6002+
}
6003+
}
6004+
}
59666005
return sc
59676006
}
59686007

@@ -6941,6 +6980,18 @@ func flattenSecretManagerConfig(c *container.SecretManagerConfig) []map[string]i
69416980
result := make(map[string]interface{})
69426981

69436982
result["enabled"] = c.Enabled
6983+
6984+
rotationList := []map[string]interface{}{}
6985+
if c.RotationConfig != nil {
6986+
rotationConfigMap := map[string]interface{}{
6987+
"enabled": c.RotationConfig.Enabled,
6988+
}
6989+
if c.RotationConfig.RotationInterval != "" {
6990+
rotationConfigMap["rotation_interval"] = c.RotationConfig.RotationInterval
6991+
}
6992+
rotationList = append(rotationList, rotationConfigMap)
6993+
}
6994+
result["rotation_config"] = rotationList
69446995
return []map[string]interface{}{result}
69456996
}
69466997

google/services/container/resource_container_cluster_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10894,6 +10894,10 @@ resource "google_container_cluster" "primary" {
1089410894
initial_node_count = 1
1089510895
secret_manager_config {
1089610896
enabled = true
10897+
rotation_config {
10898+
enabled = true
10899+
rotation_interval = "300s"
10900+
}
1089710901
}
1089810902
deletion_protection = false
1089910903
network = "%s"
@@ -10916,6 +10920,10 @@ resource "google_container_cluster" "primary" {
1091610920
initial_node_count = 1
1091710921
secret_manager_config {
1091810922
enabled = true
10923+
rotation_config {
10924+
enabled = true
10925+
rotation_interval = "120s"
10926+
}
1091910927
}
1092010928
deletion_protection = false
1092110929
network = "%s"
@@ -10938,6 +10946,10 @@ resource "google_container_cluster" "primary" {
1093810946
initial_node_count = 1
1093910947
secret_manager_config {
1094010948
enabled = true
10949+
rotation_config {
10950+
enabled = false
10951+
rotation_interval = "120s"
10952+
}
1094110953
}
1094210954
deletion_protection = false
1094310955
network = "%s"

website/docs/r/container_cluster.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1299,7 +1299,7 @@ notification_config {
12991299
<a name="nested_secret_manager_config"></a>The `secret_manager_config` block supports:
13001300

13011301
* `enabled` (Required) - Enable the Secret Manager add-on for this cluster.
1302-
* `rotation_config` (Optional, Beta) - config for secret manager auto rotation. Structure is [docuemented below](#rotation_config)
1302+
* `rotation_config` (Optional) - config for secret manager auto rotation. Structure is [docuemented below](#rotation_config)
13031303

13041304
<a name="rotation_config"></a>The `rotation_config` block supports:
13051305

0 commit comments

Comments
 (0)