Skip to content

Commit 033e21e

Browse files
Update encryption_spec field to be mutable (#15791)
1 parent c22a85e commit 033e21e

File tree

2 files changed

+127
-2
lines changed

2 files changed

+127
-2
lines changed

mmv1/products/privateca/CaPool.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,11 +518,9 @@ properties:
518518
Used when customer would like to encrypt data at rest. The customer-provided key will be used
519519
to encrypt the Subject, SubjectAltNames and PEM-encoded certificate fields. When unspecified,
520520
customer data will remain unencrypted.
521-
immutable: true
522521
properties:
523522
- name: 'cloudKmsKey'
524523
type: String
525524
description: |
526525
The resource name for an existing Cloud KMS key in the format
527526
`projects/*/locations/*/keyRings/*/cryptoKeys/*`.
528-
immutable: true

mmv1/third_party/terraform/services/privateca/resource_privateca_ca_pool_test.go

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,3 +443,130 @@ resource "google_privateca_ca_pool" "default" {
443443
}
444444
`, context)
445445
}
446+
447+
func TestAccPrivatecaCaPool_CmekKeyUpdate(t *testing.T) {
448+
t.Parallel()
449+
450+
acctest.BootstrapIamMembers(t, []acctest.IamMember{
451+
{
452+
Member: "serviceAccount:service-{project_number}@gcp-sa-privateca.iam.gserviceaccount.com",
453+
Role: "roles/cloudkms.cryptoKeyEncrypterDecrypter",
454+
},
455+
})
456+
457+
context := map[string]interface{}{
458+
"kms_key1": acctest.BootstrapKMSKeyWithPurposeInLocation(t, "ENCRYPT_DECRYPT", "us-central1").CryptoKey.Name,
459+
"kms_key2": acctest.BootstrapKMSKeyWithPurposeInLocation(t, "ENCRYPT_DECRYPT", "us-central1").CryptoKey.Name,
460+
"random_suffix": acctest.RandString(t, 10),
461+
}
462+
463+
acctest.VcrTest(t, resource.TestCase{
464+
PreCheck: func() { acctest.AccTestPreCheck(t) },
465+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
466+
CheckDestroy: testAccCheckPrivatecaCaPoolDestroyProducer(t),
467+
Steps: []resource.TestStep{
468+
{
469+
Config: testAccPrivatecaCaPool_privatecaCapoolWithCmek(context),
470+
},
471+
{
472+
ResourceName: "google_privateca_ca_pool.default",
473+
ImportState: true,
474+
ImportStateVerify: true,
475+
ImportStateVerifyIgnore: []string{"name", "location", "labels"},
476+
},
477+
{
478+
Config: testAccPrivatecaCaPool_privatecaCapoolWithCmekUpdate0(context),
479+
},
480+
{
481+
ResourceName: "google_privateca_ca_pool.default",
482+
ImportState: true,
483+
ImportStateVerify: true,
484+
ImportStateVerifyIgnore: []string{"name", "location", "labels"},
485+
},
486+
},
487+
})
488+
}
489+
490+
func testAccPrivatecaCaPool_privatecaCapoolWithCmek(context map[string]interface{}) string {
491+
return acctest.Nprintf(`
492+
resource "google_privateca_ca_pool" "default" {
493+
name = "tf-test-my-capool%{random_suffix}"
494+
location = "us-central1"
495+
tier = "ENTERPRISE"
496+
publishing_options {
497+
publish_ca_cert = false
498+
publish_crl = true
499+
}
500+
labels = {
501+
foo = "bar"
502+
}
503+
encryption_spec {
504+
cloud_kms_key = "%{kms_key1}"
505+
}
506+
issuance_policy {
507+
baseline_values {
508+
additional_extensions {
509+
critical = false
510+
value = "asdf"
511+
object_id {
512+
object_id_path = [1, 6]
513+
}
514+
}
515+
ca_options {
516+
is_ca = false
517+
}
518+
key_usage {
519+
base_key_usage {
520+
digital_signature = false
521+
}
522+
extended_key_usage {
523+
server_auth = false
524+
}
525+
}
526+
}
527+
}
528+
}
529+
`, context)
530+
}
531+
532+
func testAccPrivatecaCaPool_privatecaCapoolWithCmekUpdate0(context map[string]interface{}) string {
533+
return acctest.Nprintf(`
534+
resource "google_privateca_ca_pool" "default" {
535+
name = "tf-test-my-capool%{random_suffix}"
536+
location = "us-central1"
537+
tier = "ENTERPRISE"
538+
publishing_options {
539+
publish_ca_cert = false
540+
publish_crl = true
541+
}
542+
labels = {
543+
foo = "bar"
544+
}
545+
encryption_spec {
546+
cloud_kms_key = "%{kms_key2}"
547+
}
548+
issuance_policy {
549+
baseline_values {
550+
additional_extensions {
551+
critical = false
552+
value = "asdf"
553+
object_id {
554+
object_id_path = [1, 6]
555+
}
556+
}
557+
ca_options {
558+
is_ca = false
559+
}
560+
key_usage {
561+
base_key_usage {
562+
digital_signature = false
563+
}
564+
extended_key_usage {
565+
server_auth = false
566+
}
567+
}
568+
}
569+
}
570+
}
571+
`, context)
572+
}

0 commit comments

Comments
 (0)