@@ -66,6 +66,21 @@ func ResourceCertificateManagerTrustConfig() *schema.Resource {
66
66
ForceNew : true ,
67
67
Description : `A user-defined name of the trust config. Trust config names must be unique globally.` ,
68
68
},
69
+ "allowlisted_certificates" : {
70
+ Type : schema .TypeList ,
71
+ Optional : true ,
72
+ Description : `Allowlisted PEM-encoded certificates. A certificate matching an allowlisted certificate is always considered valid as long as
73
+ the certificate is parseable, proof of private key possession is established, and constraints on the certificate's SAN field are met.` ,
74
+ Elem : & schema.Resource {
75
+ Schema : map [string ]* schema.Schema {
76
+ "pem_certificate" : {
77
+ Type : schema .TypeString ,
78
+ Required : true ,
79
+ Description : `PEM certificate that is allowlisted. The certificate can be up to 5k bytes, and must be a parseable X.509 certificate.` ,
80
+ },
81
+ },
82
+ },
83
+ },
69
84
"description" : {
70
85
Type : schema .TypeString ,
71
86
Optional : true ,
@@ -134,7 +149,6 @@ Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".`,
134
149
"effective_labels" : {
135
150
Type : schema .TypeMap ,
136
151
Computed : true ,
137
- ForceNew : true ,
138
152
Description : `All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.` ,
139
153
Elem : & schema.Schema {Type : schema .TypeString },
140
154
},
@@ -184,6 +198,12 @@ func resourceCertificateManagerTrustConfigCreate(d *schema.ResourceData, meta in
184
198
} else if v , ok := d .GetOkExists ("trust_stores" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (trustStoresProp )) && (ok || ! reflect .DeepEqual (v , trustStoresProp )) {
185
199
obj ["trustStores" ] = trustStoresProp
186
200
}
201
+ allowlistedCertificatesProp , err := expandCertificateManagerTrustConfigAllowlistedCertificates (d .Get ("allowlisted_certificates" ), d , config )
202
+ if err != nil {
203
+ return err
204
+ } else if v , ok := d .GetOkExists ("allowlisted_certificates" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (allowlistedCertificatesProp )) && (ok || ! reflect .DeepEqual (v , allowlistedCertificatesProp )) {
205
+ obj ["allowlistedCertificates" ] = allowlistedCertificatesProp
206
+ }
187
207
labelsProp , err := expandCertificateManagerTrustConfigEffectiveLabels (d .Get ("effective_labels" ), d , config )
188
208
if err != nil {
189
209
return err
@@ -304,6 +324,9 @@ func resourceCertificateManagerTrustConfigRead(d *schema.ResourceData, meta inte
304
324
if err := d .Set ("trust_stores" , flattenCertificateManagerTrustConfigTrustStores (res ["trustStores" ], d , config )); err != nil {
305
325
return fmt .Errorf ("Error reading TrustConfig: %s" , err )
306
326
}
327
+ if err := d .Set ("allowlisted_certificates" , flattenCertificateManagerTrustConfigAllowlistedCertificates (res ["allowlistedCertificates" ], d , config )); err != nil {
328
+ return fmt .Errorf ("Error reading TrustConfig: %s" , err )
329
+ }
307
330
if err := d .Set ("terraform_labels" , flattenCertificateManagerTrustConfigTerraformLabels (res ["labels" ], d , config )); err != nil {
308
331
return fmt .Errorf ("Error reading TrustConfig: %s" , err )
309
332
}
@@ -342,6 +365,18 @@ func resourceCertificateManagerTrustConfigUpdate(d *schema.ResourceData, meta in
342
365
} else if v , ok := d .GetOkExists ("trust_stores" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , trustStoresProp )) {
343
366
obj ["trustStores" ] = trustStoresProp
344
367
}
368
+ allowlistedCertificatesProp , err := expandCertificateManagerTrustConfigAllowlistedCertificates (d .Get ("allowlisted_certificates" ), d , config )
369
+ if err != nil {
370
+ return err
371
+ } else if v , ok := d .GetOkExists ("allowlisted_certificates" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , allowlistedCertificatesProp )) {
372
+ obj ["allowlistedCertificates" ] = allowlistedCertificatesProp
373
+ }
374
+ labelsProp , err := expandCertificateManagerTrustConfigEffectiveLabels (d .Get ("effective_labels" ), d , config )
375
+ if err != nil {
376
+ return err
377
+ } else if v , ok := d .GetOkExists ("effective_labels" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , labelsProp )) {
378
+ obj ["labels" ] = labelsProp
379
+ }
345
380
346
381
url , err := tpgresource .ReplaceVars (d , config , "{{CertificateManagerBasePath}}projects/{{project}}/locations/{{location}}/trustConfigs/{{name}}" )
347
382
if err != nil {
@@ -350,10 +385,6 @@ func resourceCertificateManagerTrustConfigUpdate(d *schema.ResourceData, meta in
350
385
351
386
log .Printf ("[DEBUG] Updating TrustConfig %q: %#v" , d .Id (), obj )
352
387
headers := make (http.Header )
353
- url , err = transport_tpg .AddQueryParams (url , map [string ]string {"updateMask" : "*" })
354
- if err != nil {
355
- return err
356
- }
357
388
358
389
// err == nil indicates that the billing_project value was found
359
390
if bp , err := tpgresource .GetBillingProject (d , config ); err == nil {
@@ -554,6 +585,28 @@ func flattenCertificateManagerTrustConfigTrustStoresIntermediateCasPemCertificat
554
585
return v
555
586
}
556
587
588
+ func flattenCertificateManagerTrustConfigAllowlistedCertificates (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
589
+ if v == nil {
590
+ return v
591
+ }
592
+ l := v .([]interface {})
593
+ transformed := make ([]interface {}, 0 , len (l ))
594
+ for _ , raw := range l {
595
+ original := raw .(map [string ]interface {})
596
+ if len (original ) < 1 {
597
+ // Do not include empty json objects coming back from the api
598
+ continue
599
+ }
600
+ transformed = append (transformed , map [string ]interface {}{
601
+ "pem_certificate" : flattenCertificateManagerTrustConfigAllowlistedCertificatesPemCertificate (original ["pemCertificate" ], d , config ),
602
+ })
603
+ }
604
+ return transformed
605
+ }
606
+ func flattenCertificateManagerTrustConfigAllowlistedCertificatesPemCertificate (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
607
+ return v
608
+ }
609
+
557
610
func flattenCertificateManagerTrustConfigTerraformLabels (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
558
611
if v == nil {
559
612
return v
@@ -658,6 +711,32 @@ func expandCertificateManagerTrustConfigTrustStoresIntermediateCasPemCertificate
658
711
return v , nil
659
712
}
660
713
714
+ func expandCertificateManagerTrustConfigAllowlistedCertificates (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
715
+ l := v .([]interface {})
716
+ req := make ([]interface {}, 0 , len (l ))
717
+ for _ , raw := range l {
718
+ if raw == nil {
719
+ continue
720
+ }
721
+ original := raw .(map [string ]interface {})
722
+ transformed := make (map [string ]interface {})
723
+
724
+ transformedPemCertificate , err := expandCertificateManagerTrustConfigAllowlistedCertificatesPemCertificate (original ["pem_certificate" ], d , config )
725
+ if err != nil {
726
+ return nil , err
727
+ } else if val := reflect .ValueOf (transformedPemCertificate ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
728
+ transformed ["pemCertificate" ] = transformedPemCertificate
729
+ }
730
+
731
+ req = append (req , transformed )
732
+ }
733
+ return req , nil
734
+ }
735
+
736
+ func expandCertificateManagerTrustConfigAllowlistedCertificatesPemCertificate (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
737
+ return v , nil
738
+ }
739
+
661
740
func expandCertificateManagerTrustConfigEffectiveLabels (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (map [string ]string , error ) {
662
741
if v == nil {
663
742
return map [string ]string {}, nil
0 commit comments