@@ -39,6 +39,24 @@ func TestAccContainerAttachedCluster_update(t *testing.T) {
3939 ImportStateVerify : true ,
4040 ImportStateVerifyIgnore : []string {"location" , "annotations" },
4141 },
42+ {
43+ Config : testAccContainerAttachedCluster_containerAttachedCluster_removeAuthorizationUsers (context ),
44+ },
45+ {
46+ ResourceName : "google_container_attached_cluster.primary" ,
47+ ImportState : true ,
48+ ImportStateVerify : true ,
49+ ImportStateVerifyIgnore : []string {"location" , "annotations" },
50+ },
51+ {
52+ Config : testAccContainerAttachedCluster_containerAttachedCluster_removeAuthorizationGroups (context ),
53+ },
54+ {
55+ ResourceName : "google_container_attached_cluster.primary" ,
56+ ImportState : true ,
57+ ImportStateVerify : true ,
58+ ImportStateVerifyIgnore : []string {"location" , "annotations" },
59+ },
4260 {
4361 Config : testAccContainerAttachedCluster_containerAttachedCluster_destroy (context ),
4462 },
@@ -157,9 +175,7 @@ resource "google_container_attached_cluster" "primary" {
157175` , context )
158176}
159177
160- // Duplicate of testAccContainerAttachedCluster_containerAttachedCluster_update without lifecycle.prevent_destroy set
161- // so the test can clean up the resource after the update.
162- func testAccContainerAttachedCluster_containerAttachedCluster_destroy (context map [string ]interface {}) string {
178+ func testAccContainerAttachedCluster_containerAttachedCluster_removeAuthorizationUsers (context map [string ]interface {}) string {
163179 return acctest .Nprintf (`
164180data "google_project" "project" {
165181}
@@ -180,7 +196,6 @@ resource "google_container_attached_cluster" "primary" {
180196 label-two = "value-two"
181197 }
182198 authorization {
183- 184199 admin_groups = [ "[email protected] "] 185200 }
186201 oidc_config {
@@ -203,6 +218,102 @@ resource "google_container_attached_cluster" "primary" {
203218 namespace = "custom-ns"
204219 }
205220 }
221+ lifecycle {
222+ prevent_destroy = true
223+ }
224+ }
225+ ` , context )
226+ }
227+
228+ func testAccContainerAttachedCluster_containerAttachedCluster_removeAuthorizationGroups (context map [string ]interface {}) string {
229+ return acctest .Nprintf (`
230+ data "google_project" "project" {
231+ }
232+
233+ data "google_container_attached_versions" "versions" {
234+ location = "us-west1"
235+ project = data.google_project.project.project_id
236+ }
237+
238+ resource "google_container_attached_cluster" "primary" {
239+ name = "update%{random_suffix}"
240+ project = data.google_project.project.project_id
241+ location = "us-west1"
242+ description = "Test cluster updated"
243+ distribution = "aks"
244+ annotations = {
245+ label-one = "value-one"
246+ label-two = "value-two"
247+ }
248+ oidc_config {
249+ issuer_url = "https://oidc.issuer.url"
250+ jwks = base64encode("{\"keys\":[{\"use\":\"sig\",\"kty\":\"RSA\",\"kid\":\"testid\",\"alg\":\"RS256\",\"n\":\"somedata\",\"e\":\"AQAB\"}]}")
251+ }
252+ platform_version = data.google_container_attached_versions.versions.valid_versions[0]
253+ fleet {
254+ project = "projects/${data.google_project.project.number}"
255+ }
256+ monitoring_config {
257+ managed_prometheus_config {}
258+ }
259+ binary_authorization {
260+ evaluation_mode = "DISABLED"
261+ }
262+ proxy_config {
263+ kubernetes_secret {
264+ name = "new-proxy-config"
265+ namespace = "custom-ns"
266+ }
267+ }
268+ lifecycle {
269+ prevent_destroy = true
270+ }
271+ }
272+ ` , context )
273+ }
274+
275+ // Duplicate of testAccContainerAttachedCluster_containerAttachedCluster_update without lifecycle.prevent_destroy set
276+ // so the test can clean up the resource after the update.
277+ func testAccContainerAttachedCluster_containerAttachedCluster_destroy (context map [string ]interface {}) string {
278+ return acctest .Nprintf (`
279+ data "google_project" "project" {
280+ }
281+
282+ data "google_container_attached_versions" "versions" {
283+ location = "us-west1"
284+ project = data.google_project.project.project_id
285+ }
286+
287+ resource "google_container_attached_cluster" "primary" {
288+ name = "update%{random_suffix}"
289+ project = data.google_project.project.project_id
290+ location = "us-west1"
291+ description = "Test cluster updated"
292+ distribution = "aks"
293+ annotations = {
294+ label-one = "value-one"
295+ label-two = "value-two"
296+ }
297+ oidc_config {
298+ issuer_url = "https://oidc.issuer.url"
299+ jwks = base64encode("{\"keys\":[{\"use\":\"sig\",\"kty\":\"RSA\",\"kid\":\"testid\",\"alg\":\"RS256\",\"n\":\"somedata\",\"e\":\"AQAB\"}]}")
300+ }
301+ platform_version = data.google_container_attached_versions.versions.valid_versions[0]
302+ fleet {
303+ project = "projects/${data.google_project.project.number}"
304+ }
305+ monitoring_config {
306+ managed_prometheus_config {}
307+ }
308+ binary_authorization {
309+ evaluation_mode = "DISABLED"
310+ }
311+ proxy_config {
312+ kubernetes_secret {
313+ name = "new-proxy-config"
314+ namespace = "custom-ns"
315+ }
316+ }
206317}
207318` , context )
208319}
0 commit comments