@@ -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