@@ -78,6 +78,26 @@ running 'gcloud privateca locations list'.`,
7878 ValidateFunc : verify .ValidateEnum ([]string {"ENTERPRISE" , "DEVOPS" }),
7979 Description : `The Tier of this CaPool. Possible values: ["ENTERPRISE", "DEVOPS"]` ,
8080 },
81+ "encryption_spec" : {
82+ Type : schema .TypeList ,
83+ Optional : true ,
84+ ForceNew : true ,
85+ Description : `Used when customer would like to encrypt data at rest. The customer-provided key will be used
86+ to encrypt the Subject, SubjectAltNames and PEM-encoded certificate fields. When unspecified,
87+ customer data will remain unencrypted.` ,
88+ MaxItems : 1 ,
89+ Elem : & schema.Resource {
90+ Schema : map [string ]* schema.Schema {
91+ "cloud_kms_key" : {
92+ Type : schema .TypeString ,
93+ Optional : true ,
94+ ForceNew : true ,
95+ Description : `The resource name for an existing Cloud KMS key in the format
96+ 'projects/*/locations/*/keyRings/*/cryptoKeys/*'.` ,
97+ },
98+ },
99+ },
100+ },
81101 "issuance_policy" : {
82102 Type : schema .TypeList ,
83103 Optional : true ,
@@ -659,6 +679,12 @@ func resourcePrivatecaCaPoolCreate(d *schema.ResourceData, meta interface{}) err
659679 } else if v , ok := d .GetOkExists ("publishing_options" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (publishingOptionsProp )) && (ok || ! reflect .DeepEqual (v , publishingOptionsProp )) {
660680 obj ["publishingOptions" ] = publishingOptionsProp
661681 }
682+ encryptionSpecProp , err := expandPrivatecaCaPoolEncryptionSpec (d .Get ("encryption_spec" ), d , config )
683+ if err != nil {
684+ return err
685+ } else if v , ok := d .GetOkExists ("encryption_spec" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (encryptionSpecProp )) && (ok || ! reflect .DeepEqual (v , encryptionSpecProp )) {
686+ obj ["encryptionSpec" ] = encryptionSpecProp
687+ }
662688 effectiveLabelsProp , err := expandPrivatecaCaPoolEffectiveLabels (d .Get ("effective_labels" ), d , config )
663689 if err != nil {
664690 return err
@@ -776,6 +802,9 @@ func resourcePrivatecaCaPoolRead(d *schema.ResourceData, meta interface{}) error
776802 if err := d .Set ("labels" , flattenPrivatecaCaPoolLabels (res ["labels" ], d , config )); err != nil {
777803 return fmt .Errorf ("Error reading CaPool: %s" , err )
778804 }
805+ if err := d .Set ("encryption_spec" , flattenPrivatecaCaPoolEncryptionSpec (res ["encryptionSpec" ], d , config )); err != nil {
806+ return fmt .Errorf ("Error reading CaPool: %s" , err )
807+ }
779808 if err := d .Set ("terraform_labels" , flattenPrivatecaCaPoolTerraformLabels (res ["labels" ], d , config )); err != nil {
780809 return fmt .Errorf ("Error reading CaPool: %s" , err )
781810 }
@@ -1201,6 +1230,23 @@ func flattenPrivatecaCaPoolLabels(v interface{}, d *schema.ResourceData, config
12011230 return transformed
12021231}
12031232
1233+ func flattenPrivatecaCaPoolEncryptionSpec (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1234+ if v == nil {
1235+ return nil
1236+ }
1237+ original := v .(map [string ]interface {})
1238+ if len (original ) == 0 {
1239+ return nil
1240+ }
1241+ transformed := make (map [string ]interface {})
1242+ transformed ["cloud_kms_key" ] =
1243+ flattenPrivatecaCaPoolEncryptionSpecCloudKmsKey (original ["cloudKmsKey" ], d , config )
1244+ return []interface {}{transformed }
1245+ }
1246+ func flattenPrivatecaCaPoolEncryptionSpecCloudKmsKey (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1247+ return v
1248+ }
1249+
12041250func flattenPrivatecaCaPoolTerraformLabels (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
12051251 if v == nil {
12061252 return v
@@ -1601,6 +1647,29 @@ func expandPrivatecaCaPoolPublishingOptionsEncodingFormat(v interface{}, d tpgre
16011647 return v , nil
16021648}
16031649
1650+ func expandPrivatecaCaPoolEncryptionSpec (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1651+ l := v .([]interface {})
1652+ if len (l ) == 0 || l [0 ] == nil {
1653+ return nil , nil
1654+ }
1655+ raw := l [0 ]
1656+ original := raw .(map [string ]interface {})
1657+ transformed := make (map [string ]interface {})
1658+
1659+ transformedCloudKmsKey , err := expandPrivatecaCaPoolEncryptionSpecCloudKmsKey (original ["cloud_kms_key" ], d , config )
1660+ if err != nil {
1661+ return nil , err
1662+ } else if val := reflect .ValueOf (transformedCloudKmsKey ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1663+ transformed ["cloudKmsKey" ] = transformedCloudKmsKey
1664+ }
1665+
1666+ return transformed , nil
1667+ }
1668+
1669+ func expandPrivatecaCaPoolEncryptionSpecCloudKmsKey (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1670+ return v , nil
1671+ }
1672+
16041673func expandPrivatecaCaPoolEffectiveLabels (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (map [string ]string , error ) {
16051674 if v == nil {
16061675 return map [string ]string {}, nil
0 commit comments