@@ -256,63 +256,6 @@ is set to MANUAL_ONLY.`,
256256 DiffSuppressFunc : compareSelfLinkOrResourceName ,
257257 Description : `Region where the router and NAT reside.` ,
258258 },
259- "rules" : {
260- Type : schema .TypeList ,
261- Optional : true ,
262- Description : `A list of rules associated with this NAT.` ,
263- Elem : & schema.Resource {
264- Schema : map [string ]* schema.Schema {
265- "action" : {
266- Type : schema .TypeList ,
267- Required : true ,
268- Description : `The action to be enforced for traffic that matches this rule.` ,
269- MaxItems : 1 ,
270- Elem : & schema.Resource {
271- Schema : map [string ]* schema.Schema {
272- "source_nat_active_ips" : {
273- Type : schema .TypeList ,
274- Optional : true ,
275- Description : `A list of URLs of the IP resources used for this NAT rule. These IP addresses must be valid static external IP addresses assigned to the project. This field is used for public NAT.` ,
276- Elem : & schema.Schema {
277- Type : schema .TypeString ,
278- DiffSuppressFunc : compareSelfLinkOrResourceName ,
279- },
280- },
281- "source_nat_drain_ips" : {
282- Type : schema .TypeList ,
283- Optional : true ,
284- Description : `A list of URLs of the IP resources to be drained. These IPs must be valid static external IPs that have been assigned to the NAT. These IPs should be used for updating/patching a NAT rule only. This field is used for public NAT.` ,
285- Elem : & schema.Schema {
286- Type : schema .TypeString ,
287- DiffSuppressFunc : compareSelfLinkOrResourceName ,
288- },
289- },
290- },
291- },
292- },
293- "match" : {
294- Type : schema .TypeString ,
295- Required : true ,
296- Description : `CEL expression that specifies the match condition that egress traffic from a VM is evaluated against. If it evaluates to true, the corresponding action is enforced.
297- The following examples are valid match expressions for public NAT:
298- "inIpRange(destination.ip, '1.1.0.0/16') || inIpRange(destination.ip, '2.2.0.0/16')"
299- "destination.ip == '1.1.0.1' || destination.ip == '8.8.8.8'"
300- The following example is a valid match expression for private NAT:
301- "nexthop.hub == 'https://networkconnectivity.googleapis.com/v1alpha1/projects/my-project/global/hub/hub-1'"` ,
302- },
303- "rule_number" : {
304- Type : schema .TypeInt ,
305- Required : true ,
306- Description : `An integer uniquely identifying a rule in the list. The rule number must be a positive value between 0 and 65000, and must be unique among rules within a NAT.` ,
307- },
308- "description" : {
309- Type : schema .TypeString ,
310- Optional : true ,
311- Description : `An optional description of this rule.` ,
312- },
313- },
314- },
315- },
316259 "subnetwork" : {
317260 Type : schema .TypeSet ,
318261 Optional : true ,
@@ -328,12 +271,6 @@ The following example is a valid match expression for private NAT:
328271Defaults to 1200s if not set.` ,
329272 Default : 1200 ,
330273 },
331- "tcp_time_wait_timeout_sec" : {
332- Type : schema .TypeInt ,
333- Optional : true ,
334- Description : `Timeout (in seconds) for TCP connections that are in TIME_WAIT state. Defaults to 120s if not set.` ,
335- Default : 120 ,
336- },
337274 "tcp_transitory_idle_timeout_sec" : {
338275 Type : schema .TypeInt ,
339276 Optional : true ,
@@ -482,24 +419,12 @@ func resourceComputeRouterNatCreate(d *schema.ResourceData, meta interface{}) er
482419 } else if v , ok := d .GetOkExists ("tcp_transitory_idle_timeout_sec" ); ! isEmptyValue (reflect .ValueOf (tcpTransitoryIdleTimeoutSecProp )) && (ok || ! reflect .DeepEqual (v , tcpTransitoryIdleTimeoutSecProp )) {
483420 obj ["tcpTransitoryIdleTimeoutSec" ] = tcpTransitoryIdleTimeoutSecProp
484421 }
485- tcpTimeWaitTimeoutSecProp , err := expandNestedComputeRouterNatTcpTimeWaitTimeoutSec (d .Get ("tcp_time_wait_timeout_sec" ), d , config )
486- if err != nil {
487- return err
488- } else if v , ok := d .GetOkExists ("tcp_time_wait_timeout_sec" ); ! isEmptyValue (reflect .ValueOf (tcpTimeWaitTimeoutSecProp )) && (ok || ! reflect .DeepEqual (v , tcpTimeWaitTimeoutSecProp )) {
489- obj ["tcpTimeWaitTimeoutSec" ] = tcpTimeWaitTimeoutSecProp
490- }
491422 logConfigProp , err := expandNestedComputeRouterNatLogConfig (d .Get ("log_config" ), d , config )
492423 if err != nil {
493424 return err
494425 } else if v , ok := d .GetOkExists ("log_config" ); ok || ! reflect .DeepEqual (v , logConfigProp ) {
495426 obj ["logConfig" ] = logConfigProp
496427 }
497- rulesProp , err := expandNestedComputeRouterNatRules (d .Get ("rules" ), d , config )
498- if err != nil {
499- return err
500- } else if v , ok := d .GetOkExists ("rules" ); ok || ! reflect .DeepEqual (v , rulesProp ) {
501- obj ["rules" ] = rulesProp
502- }
503428 enableEndpointIndependentMappingProp , err := expandNestedComputeRouterNatEnableEndpointIndependentMapping (d .Get ("enable_endpoint_independent_mapping" ), d , config )
504429 if err != nil {
505430 return err
@@ -650,15 +575,9 @@ func resourceComputeRouterNatRead(d *schema.ResourceData, meta interface{}) erro
650575 if err := d .Set ("tcp_transitory_idle_timeout_sec" , flattenNestedComputeRouterNatTcpTransitoryIdleTimeoutSec (res ["tcpTransitoryIdleTimeoutSec" ], d , config )); err != nil {
651576 return fmt .Errorf ("Error reading RouterNat: %s" , err )
652577 }
653- if err := d .Set ("tcp_time_wait_timeout_sec" , flattenNestedComputeRouterNatTcpTimeWaitTimeoutSec (res ["tcpTimeWaitTimeoutSec" ], d , config )); err != nil {
654- return fmt .Errorf ("Error reading RouterNat: %s" , err )
655- }
656578 if err := d .Set ("log_config" , flattenNestedComputeRouterNatLogConfig (res ["logConfig" ], d , config )); err != nil {
657579 return fmt .Errorf ("Error reading RouterNat: %s" , err )
658580 }
659- if err := d .Set ("rules" , flattenNestedComputeRouterNatRules (res ["rules" ], d , config )); err != nil {
660- return fmt .Errorf ("Error reading RouterNat: %s" , err )
661- }
662581 if err := d .Set ("enable_endpoint_independent_mapping" , flattenNestedComputeRouterNatEnableEndpointIndependentMapping (res ["enableEndpointIndependentMapping" ], d , config )); err != nil {
663582 return fmt .Errorf ("Error reading RouterNat: %s" , err )
664583 }
@@ -754,24 +673,12 @@ func resourceComputeRouterNatUpdate(d *schema.ResourceData, meta interface{}) er
754673 } else if v , ok := d .GetOkExists ("tcp_transitory_idle_timeout_sec" ); ! isEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , tcpTransitoryIdleTimeoutSecProp )) {
755674 obj ["tcpTransitoryIdleTimeoutSec" ] = tcpTransitoryIdleTimeoutSecProp
756675 }
757- tcpTimeWaitTimeoutSecProp , err := expandNestedComputeRouterNatTcpTimeWaitTimeoutSec (d .Get ("tcp_time_wait_timeout_sec" ), d , config )
758- if err != nil {
759- return err
760- } else if v , ok := d .GetOkExists ("tcp_time_wait_timeout_sec" ); ! isEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , tcpTimeWaitTimeoutSecProp )) {
761- obj ["tcpTimeWaitTimeoutSec" ] = tcpTimeWaitTimeoutSecProp
762- }
763676 logConfigProp , err := expandNestedComputeRouterNatLogConfig (d .Get ("log_config" ), d , config )
764677 if err != nil {
765678 return err
766679 } else if v , ok := d .GetOkExists ("log_config" ); ok || ! reflect .DeepEqual (v , logConfigProp ) {
767680 obj ["logConfig" ] = logConfigProp
768681 }
769- rulesProp , err := expandNestedComputeRouterNatRules (d .Get ("rules" ), d , config )
770- if err != nil {
771- return err
772- } else if v , ok := d .GetOkExists ("rules" ); ok || ! reflect .DeepEqual (v , rulesProp ) {
773- obj ["rules" ] = rulesProp
774- }
775682 enableEndpointIndependentMappingProp , err := expandNestedComputeRouterNatEnableEndpointIndependentMapping (d .Get ("enable_endpoint_independent_mapping" ), d , config )
776683 if err != nil {
777684 return err
@@ -1061,23 +968,6 @@ func flattenNestedComputeRouterNatTcpTransitoryIdleTimeoutSec(v interface{}, d *
1061968 return v
1062969}
1063970
1064- func flattenNestedComputeRouterNatTcpTimeWaitTimeoutSec (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
1065- // Handles the string fixed64 format
1066- if strVal , ok := v .(string ); ok {
1067- if intVal , err := stringToFixed64 (strVal ); err == nil {
1068- return intVal
1069- }
1070- }
1071-
1072- // number values are represented as float64
1073- if floatVal , ok := v .(float64 ); ok {
1074- intVal := int (floatVal )
1075- return intVal
1076- }
1077-
1078- return v // let terraform core handle it otherwise
1079- }
1080-
1081971func flattenNestedComputeRouterNatLogConfig (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
1082972 if v == nil {
1083973 return nil
@@ -1101,81 +991,6 @@ func flattenNestedComputeRouterNatLogConfigFilter(v interface{}, d *schema.Resou
1101991 return v
1102992}
1103993
1104- func flattenNestedComputeRouterNatRules (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
1105- if v == nil {
1106- return v
1107- }
1108- l := v .([]interface {})
1109- transformed := make ([]interface {}, 0 , len (l ))
1110- for _ , raw := range l {
1111- original := raw .(map [string ]interface {})
1112- if len (original ) < 1 {
1113- // Do not include empty json objects coming back from the api
1114- continue
1115- }
1116- transformed = append (transformed , map [string ]interface {}{
1117- "rule_number" : flattenNestedComputeRouterNatRulesRuleNumber (original ["ruleNumber" ], d , config ),
1118- "description" : flattenNestedComputeRouterNatRulesDescription (original ["description" ], d , config ),
1119- "match" : flattenNestedComputeRouterNatRulesMatch (original ["match" ], d , config ),
1120- "action" : flattenNestedComputeRouterNatRulesAction (original ["action" ], d , config ),
1121- })
1122- }
1123- return transformed
1124- }
1125- func flattenNestedComputeRouterNatRulesRuleNumber (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
1126- // Handles the string fixed64 format
1127- if strVal , ok := v .(string ); ok {
1128- if intVal , err := stringToFixed64 (strVal ); err == nil {
1129- return intVal
1130- }
1131- }
1132-
1133- // number values are represented as float64
1134- if floatVal , ok := v .(float64 ); ok {
1135- intVal := int (floatVal )
1136- return intVal
1137- }
1138-
1139- return v // let terraform core handle it otherwise
1140- }
1141-
1142- func flattenNestedComputeRouterNatRulesDescription (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
1143- return v
1144- }
1145-
1146- func flattenNestedComputeRouterNatRulesMatch (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
1147- return v
1148- }
1149-
1150- func flattenNestedComputeRouterNatRulesAction (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
1151- if v == nil {
1152- return nil
1153- }
1154- original := v .(map [string ]interface {})
1155- if len (original ) == 0 {
1156- return nil
1157- }
1158- transformed := make (map [string ]interface {})
1159- transformed ["source_nat_active_ips" ] =
1160- flattenNestedComputeRouterNatRulesActionSourceNatActiveIps (original ["sourceNatActiveIps" ], d , config )
1161- transformed ["source_nat_drain_ips" ] =
1162- flattenNestedComputeRouterNatRulesActionSourceNatDrainIps (original ["sourceNatDrainIps" ], d , config )
1163- return []interface {}{transformed }
1164- }
1165- func flattenNestedComputeRouterNatRulesActionSourceNatActiveIps (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
1166- if v == nil {
1167- return v
1168- }
1169- return convertAndMapStringArr (v .([]interface {}), ConvertSelfLinkToV1 )
1170- }
1171-
1172- func flattenNestedComputeRouterNatRulesActionSourceNatDrainIps (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
1173- if v == nil {
1174- return v
1175- }
1176- return convertAndMapStringArr (v .([]interface {}), ConvertSelfLinkToV1 )
1177- }
1178-
1179994func flattenNestedComputeRouterNatEnableEndpointIndependentMapping (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
1180995 return v
1181996}
@@ -1309,10 +1124,6 @@ func expandNestedComputeRouterNatTcpTransitoryIdleTimeoutSec(v interface{}, d Te
13091124 return v , nil
13101125}
13111126
1312- func expandNestedComputeRouterNatTcpTimeWaitTimeoutSec (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
1313- return v , nil
1314- }
1315-
13161127func expandNestedComputeRouterNatLogConfig (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
13171128 l := v .([]interface {})
13181129 if len (l ) == 0 || l [0 ] == nil {
@@ -1347,119 +1158,6 @@ func expandNestedComputeRouterNatLogConfigFilter(v interface{}, d TerraformResou
13471158 return v , nil
13481159}
13491160
1350- func expandNestedComputeRouterNatRules (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
1351- l := v .([]interface {})
1352- req := make ([]interface {}, 0 , len (l ))
1353- for _ , raw := range l {
1354- if raw == nil {
1355- continue
1356- }
1357- original := raw .(map [string ]interface {})
1358- transformed := make (map [string ]interface {})
1359-
1360- transformedRuleNumber , err := expandNestedComputeRouterNatRulesRuleNumber (original ["rule_number" ], d , config )
1361- if err != nil {
1362- return nil , err
1363- } else if val := reflect .ValueOf (transformedRuleNumber ); val .IsValid () && ! isEmptyValue (val ) {
1364- transformed ["ruleNumber" ] = transformedRuleNumber
1365- }
1366-
1367- transformedDescription , err := expandNestedComputeRouterNatRulesDescription (original ["description" ], d , config )
1368- if err != nil {
1369- return nil , err
1370- } else if val := reflect .ValueOf (transformedDescription ); val .IsValid () && ! isEmptyValue (val ) {
1371- transformed ["description" ] = transformedDescription
1372- }
1373-
1374- transformedMatch , err := expandNestedComputeRouterNatRulesMatch (original ["match" ], d , config )
1375- if err != nil {
1376- return nil , err
1377- } else if val := reflect .ValueOf (transformedMatch ); val .IsValid () && ! isEmptyValue (val ) {
1378- transformed ["match" ] = transformedMatch
1379- }
1380-
1381- transformedAction , err := expandNestedComputeRouterNatRulesAction (original ["action" ], d , config )
1382- if err != nil {
1383- return nil , err
1384- } else if val := reflect .ValueOf (transformedAction ); val .IsValid () && ! isEmptyValue (val ) {
1385- transformed ["action" ] = transformedAction
1386- }
1387-
1388- req = append (req , transformed )
1389- }
1390- return req , nil
1391- }
1392-
1393- func expandNestedComputeRouterNatRulesRuleNumber (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
1394- return v , nil
1395- }
1396-
1397- func expandNestedComputeRouterNatRulesDescription (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
1398- return v , nil
1399- }
1400-
1401- func expandNestedComputeRouterNatRulesMatch (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
1402- return v , nil
1403- }
1404-
1405- func expandNestedComputeRouterNatRulesAction (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
1406- l := v .([]interface {})
1407- if len (l ) == 0 || l [0 ] == nil {
1408- return nil , nil
1409- }
1410- raw := l [0 ]
1411- original := raw .(map [string ]interface {})
1412- transformed := make (map [string ]interface {})
1413-
1414- transformedSourceNatActiveIps , err := expandNestedComputeRouterNatRulesActionSourceNatActiveIps (original ["source_nat_active_ips" ], d , config )
1415- if err != nil {
1416- return nil , err
1417- } else if val := reflect .ValueOf (transformedSourceNatActiveIps ); val .IsValid () && ! isEmptyValue (val ) {
1418- transformed ["sourceNatActiveIps" ] = transformedSourceNatActiveIps
1419- }
1420-
1421- transformedSourceNatDrainIps , err := expandNestedComputeRouterNatRulesActionSourceNatDrainIps (original ["source_nat_drain_ips" ], d , config )
1422- if err != nil {
1423- return nil , err
1424- } else if val := reflect .ValueOf (transformedSourceNatDrainIps ); val .IsValid () && ! isEmptyValue (val ) {
1425- transformed ["sourceNatDrainIps" ] = transformedSourceNatDrainIps
1426- }
1427-
1428- return transformed , nil
1429- }
1430-
1431- func expandNestedComputeRouterNatRulesActionSourceNatActiveIps (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
1432- l := v .([]interface {})
1433- req := make ([]interface {}, 0 , len (l ))
1434- for _ , raw := range l {
1435- if raw == nil {
1436- return nil , fmt .Errorf ("Invalid value for source_nat_active_ips: nil" )
1437- }
1438- f , err := parseRegionalFieldValue ("addresses" , raw .(string ), "project" , "region" , "zone" , d , config , true )
1439- if err != nil {
1440- return nil , fmt .Errorf ("Invalid value for source_nat_active_ips: %s" , err )
1441- }
1442- req = append (req , f .RelativeLink ())
1443- }
1444- return req , nil
1445- }
1446-
1447- func expandNestedComputeRouterNatRulesActionSourceNatDrainIps (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
1448- l := v .([]interface {})
1449- req := make ([]interface {}, 0 , len (l ))
1450- for _ , raw := range l {
1451- if raw == nil {
1452- return nil , fmt .Errorf ("Invalid value for source_nat_drain_ips: nil" )
1453- }
1454- f , err := parseRegionalFieldValue ("addresses" , raw .(string ), "project" , "region" , "zone" , d , config , true )
1455- if err != nil {
1456- return nil , fmt .Errorf ("Invalid value for source_nat_drain_ips: %s" , err )
1457- }
1458- req = append (req , f .RelativeLink ())
1459- }
1460- return req , nil
1461- }
1462-
14631161func expandNestedComputeRouterNatEnableEndpointIndependentMapping (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
14641162 return v , nil
14651163}
0 commit comments