@@ -30,6 +30,7 @@ import (
3030
3131 "github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource"
3232 transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport"
33+ "github.com/hashicorp/terraform-provider-google-beta/google-beta/verify"
3334)
3435
3536func ResourceNetworkSecurityTlsInspectionPolicy () * schema.Resource {
@@ -64,6 +65,14 @@ func ResourceNetworkSecurityTlsInspectionPolicy() *schema.Resource {
6465 Required : true ,
6566 Description : `Short name of the TlsInspectionPolicy resource to be created.` ,
6667 },
68+ "custom_tls_features" : {
69+ Type : schema .TypeList ,
70+ Optional : true ,
71+ Description : `List of custom TLS cipher suites selected. This field is valid only if the selected tls_feature_profile is CUSTOM. The compute.SslPoliciesService.ListAvailableFeatures method returns the set of features that can be specified in this list. Note that Secure Web Proxy does not yet honor this field.` ,
72+ Elem : & schema.Schema {
73+ Type : schema .TypeString ,
74+ },
75+ },
6776 "description" : {
6877 Type : schema .TypeString ,
6978 Optional : true ,
@@ -79,6 +88,24 @@ func ResourceNetworkSecurityTlsInspectionPolicy() *schema.Resource {
7988 Optional : true ,
8089 Description : `The location of the tls inspection policy.` ,
8190 },
91+ "min_tls_version" : {
92+ Type : schema .TypeString ,
93+ Optional : true ,
94+ ValidateFunc : verify .ValidateEnum ([]string {"TLS_VERSION_UNSPECIFIED" , "TLS_1_0" , "TLS_1_1" , "TLS_1_2" , "TLS_1_3" , "" }),
95+ Description : `Minimum TLS version that the firewall should use when negotiating connections with both clients and servers. If this is not set, then the default value is to allow the broadest set of clients and servers (TLS 1.0 or higher). Setting this to more restrictive values may improve security, but may also prevent the firewall from connecting to some clients or servers. Note that Secure Web Proxy does not yet honor this field. Possible values: ["TLS_VERSION_UNSPECIFIED", "TLS_1_0", "TLS_1_1", "TLS_1_2", "TLS_1_3"]` ,
96+ },
97+ "tls_feature_profile" : {
98+ Type : schema .TypeString ,
99+ Optional : true ,
100+ ValidateFunc : verify .ValidateEnum ([]string {"PROFILE_UNSPECIFIED" , "PROFILE_COMPATIBLE" , "PROFILE_MODERN" , "PROFILE_RESTRICTED" , "PROFILE_CUSTOM" , "" }),
101+ Description : `The selected Profile. If this is not set, then the default value is to allow the broadest set of clients and servers (\"PROFILE_COMPATIBLE\"). Setting this to more restrictive values may improve security, but may also prevent the TLS inspection proxy from connecting to some clients or servers. Note that Secure Web Proxy does not yet honor this field. Possible values: ["PROFILE_UNSPECIFIED", "PROFILE_COMPATIBLE", "PROFILE_MODERN", "PROFILE_RESTRICTED", "PROFILE_CUSTOM"]` ,
102+ },
103+ "trust_config" : {
104+ Type : schema .TypeString ,
105+ Optional : true ,
106+ DiffSuppressFunc : tpgresource .ProjectNumberDiffSuppress ,
107+ Description : `A TrustConfig resource used when making a connection to the TLS server. This is a relative resource path following the form \"projects/{project}/locations/{location}/trustConfigs/{trust_config}\". This is necessary to intercept TLS connections to servers with certificates signed by a private CA or self-signed certificates. Trust config and the TLS inspection policy must be in the same region. Note that Secure Web Proxy does not yet honor this field.` ,
108+ },
82109 "create_time" : {
83110 Type : schema .TypeString ,
84111 Computed : true ,
@@ -120,6 +147,30 @@ func resourceNetworkSecurityTlsInspectionPolicyCreate(d *schema.ResourceData, me
120147 } else if v , ok := d .GetOkExists ("ca_pool" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (caPoolProp )) && (ok || ! reflect .DeepEqual (v , caPoolProp )) {
121148 obj ["caPool" ] = caPoolProp
122149 }
150+ trustConfigProp , err := expandNetworkSecurityTlsInspectionPolicyTrustConfig (d .Get ("trust_config" ), d , config )
151+ if err != nil {
152+ return err
153+ } else if v , ok := d .GetOkExists ("trust_config" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (trustConfigProp )) && (ok || ! reflect .DeepEqual (v , trustConfigProp )) {
154+ obj ["trustConfig" ] = trustConfigProp
155+ }
156+ minTlsVersionProp , err := expandNetworkSecurityTlsInspectionPolicyMinTlsVersion (d .Get ("min_tls_version" ), d , config )
157+ if err != nil {
158+ return err
159+ } else if v , ok := d .GetOkExists ("min_tls_version" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (minTlsVersionProp )) && (ok || ! reflect .DeepEqual (v , minTlsVersionProp )) {
160+ obj ["minTlsVersion" ] = minTlsVersionProp
161+ }
162+ tlsFeatureProfileProp , err := expandNetworkSecurityTlsInspectionPolicyTlsFeatureProfile (d .Get ("tls_feature_profile" ), d , config )
163+ if err != nil {
164+ return err
165+ } else if v , ok := d .GetOkExists ("tls_feature_profile" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (tlsFeatureProfileProp )) && (ok || ! reflect .DeepEqual (v , tlsFeatureProfileProp )) {
166+ obj ["tlsFeatureProfile" ] = tlsFeatureProfileProp
167+ }
168+ customTlsFeaturesProp , err := expandNetworkSecurityTlsInspectionPolicyCustomTlsFeatures (d .Get ("custom_tls_features" ), d , config )
169+ if err != nil {
170+ return err
171+ } else if v , ok := d .GetOkExists ("custom_tls_features" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (customTlsFeaturesProp )) && (ok || ! reflect .DeepEqual (v , customTlsFeaturesProp )) {
172+ obj ["customTlsFeatures" ] = customTlsFeaturesProp
173+ }
123174 excludePublicCaSetProp , err := expandNetworkSecurityTlsInspectionPolicyExcludePublicCaSet (d .Get ("exclude_public_ca_set" ), d , config )
124175 if err != nil {
125176 return err
@@ -237,6 +288,18 @@ func resourceNetworkSecurityTlsInspectionPolicyRead(d *schema.ResourceData, meta
237288 if err := d .Set ("ca_pool" , flattenNetworkSecurityTlsInspectionPolicyCaPool (res ["caPool" ], d , config )); err != nil {
238289 return fmt .Errorf ("Error reading TlsInspectionPolicy: %s" , err )
239290 }
291+ if err := d .Set ("trust_config" , flattenNetworkSecurityTlsInspectionPolicyTrustConfig (res ["trustConfig" ], d , config )); err != nil {
292+ return fmt .Errorf ("Error reading TlsInspectionPolicy: %s" , err )
293+ }
294+ if err := d .Set ("min_tls_version" , flattenNetworkSecurityTlsInspectionPolicyMinTlsVersion (res ["minTlsVersion" ], d , config )); err != nil {
295+ return fmt .Errorf ("Error reading TlsInspectionPolicy: %s" , err )
296+ }
297+ if err := d .Set ("tls_feature_profile" , flattenNetworkSecurityTlsInspectionPolicyTlsFeatureProfile (res ["tlsFeatureProfile" ], d , config )); err != nil {
298+ return fmt .Errorf ("Error reading TlsInspectionPolicy: %s" , err )
299+ }
300+ if err := d .Set ("custom_tls_features" , flattenNetworkSecurityTlsInspectionPolicyCustomTlsFeatures (res ["customTlsFeatures" ], d , config )); err != nil {
301+ return fmt .Errorf ("Error reading TlsInspectionPolicy: %s" , err )
302+ }
240303 if err := d .Set ("exclude_public_ca_set" , flattenNetworkSecurityTlsInspectionPolicyExcludePublicCaSet (res ["excludePublicCaSet" ], d , config )); err != nil {
241304 return fmt .Errorf ("Error reading TlsInspectionPolicy: %s" , err )
242305 }
@@ -272,6 +335,30 @@ func resourceNetworkSecurityTlsInspectionPolicyUpdate(d *schema.ResourceData, me
272335 } else if v , ok := d .GetOkExists ("ca_pool" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , caPoolProp )) {
273336 obj ["caPool" ] = caPoolProp
274337 }
338+ trustConfigProp , err := expandNetworkSecurityTlsInspectionPolicyTrustConfig (d .Get ("trust_config" ), d , config )
339+ if err != nil {
340+ return err
341+ } else if v , ok := d .GetOkExists ("trust_config" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , trustConfigProp )) {
342+ obj ["trustConfig" ] = trustConfigProp
343+ }
344+ minTlsVersionProp , err := expandNetworkSecurityTlsInspectionPolicyMinTlsVersion (d .Get ("min_tls_version" ), d , config )
345+ if err != nil {
346+ return err
347+ } else if v , ok := d .GetOkExists ("min_tls_version" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , minTlsVersionProp )) {
348+ obj ["minTlsVersion" ] = minTlsVersionProp
349+ }
350+ tlsFeatureProfileProp , err := expandNetworkSecurityTlsInspectionPolicyTlsFeatureProfile (d .Get ("tls_feature_profile" ), d , config )
351+ if err != nil {
352+ return err
353+ } else if v , ok := d .GetOkExists ("tls_feature_profile" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , tlsFeatureProfileProp )) {
354+ obj ["tlsFeatureProfile" ] = tlsFeatureProfileProp
355+ }
356+ customTlsFeaturesProp , err := expandNetworkSecurityTlsInspectionPolicyCustomTlsFeatures (d .Get ("custom_tls_features" ), d , config )
357+ if err != nil {
358+ return err
359+ } else if v , ok := d .GetOkExists ("custom_tls_features" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , customTlsFeaturesProp )) {
360+ obj ["customTlsFeatures" ] = customTlsFeaturesProp
361+ }
275362 excludePublicCaSetProp , err := expandNetworkSecurityTlsInspectionPolicyExcludePublicCaSet (d .Get ("exclude_public_ca_set" ), d , config )
276363 if err != nil {
277364 return err
@@ -296,6 +383,22 @@ func resourceNetworkSecurityTlsInspectionPolicyUpdate(d *schema.ResourceData, me
296383 updateMask = append (updateMask , "caPool" )
297384 }
298385
386+ if d .HasChange ("trust_config" ) {
387+ updateMask = append (updateMask , "trustConfig" )
388+ }
389+
390+ if d .HasChange ("min_tls_version" ) {
391+ updateMask = append (updateMask , "minTlsVersion" )
392+ }
393+
394+ if d .HasChange ("tls_feature_profile" ) {
395+ updateMask = append (updateMask , "tlsFeatureProfile" )
396+ }
397+
398+ if d .HasChange ("custom_tls_features" ) {
399+ updateMask = append (updateMask , "customTlsFeatures" )
400+ }
401+
299402 if d .HasChange ("exclude_public_ca_set" ) {
300403 updateMask = append (updateMask , "excludePublicCaSet" )
301404 }
@@ -434,6 +537,22 @@ func flattenNetworkSecurityTlsInspectionPolicyCaPool(v interface{}, d *schema.Re
434537 return v
435538}
436539
540+ func flattenNetworkSecurityTlsInspectionPolicyTrustConfig (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
541+ return v
542+ }
543+
544+ func flattenNetworkSecurityTlsInspectionPolicyMinTlsVersion (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
545+ return v
546+ }
547+
548+ func flattenNetworkSecurityTlsInspectionPolicyTlsFeatureProfile (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
549+ return v
550+ }
551+
552+ func flattenNetworkSecurityTlsInspectionPolicyCustomTlsFeatures (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
553+ return v
554+ }
555+
437556func flattenNetworkSecurityTlsInspectionPolicyExcludePublicCaSet (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
438557 return v
439558}
@@ -446,6 +565,22 @@ func expandNetworkSecurityTlsInspectionPolicyCaPool(v interface{}, d tpgresource
446565 return v , nil
447566}
448567
568+ func expandNetworkSecurityTlsInspectionPolicyTrustConfig (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
569+ return v , nil
570+ }
571+
572+ func expandNetworkSecurityTlsInspectionPolicyMinTlsVersion (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
573+ return v , nil
574+ }
575+
576+ func expandNetworkSecurityTlsInspectionPolicyTlsFeatureProfile (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
577+ return v , nil
578+ }
579+
580+ func expandNetworkSecurityTlsInspectionPolicyCustomTlsFeatures (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
581+ return v , nil
582+ }
583+
449584func expandNetworkSecurityTlsInspectionPolicyExcludePublicCaSet (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
450585 return v , nil
451586}
0 commit comments