@@ -321,6 +321,13 @@ is set to MANUAL_ONLY.`,
321321Defaults to 1200s if not set.` ,
322322 Default : 1200 ,
323323 },
324+ "tcp_time_wait_timeout_sec" : {
325+ Type : schema .TypeInt ,
326+ Optional : true ,
327+ Description : `Timeout (in seconds) for TCP connections that are in TIME_WAIT state.
328+ Defaults to 120s if not set.` ,
329+ Default : 120 ,
330+ },
324331 "tcp_transitory_idle_timeout_sec" : {
325332 Type : schema .TypeInt ,
326333 Optional : true ,
@@ -540,6 +547,12 @@ func resourceComputeRouterNatCreate(d *schema.ResourceData, meta interface{}) er
540547 } else if v , ok := d .GetOkExists ("tcp_transitory_idle_timeout_sec" ); ! isEmptyValue (reflect .ValueOf (tcpTransitoryIdleTimeoutSecProp )) && (ok || ! reflect .DeepEqual (v , tcpTransitoryIdleTimeoutSecProp )) {
541548 obj ["tcpTransitoryIdleTimeoutSec" ] = tcpTransitoryIdleTimeoutSecProp
542549 }
550+ tcpTimeWaitTimeoutSecProp , err := expandNestedComputeRouterNatTcpTimeWaitTimeoutSec (d .Get ("tcp_time_wait_timeout_sec" ), d , config )
551+ if err != nil {
552+ return err
553+ } else if v , ok := d .GetOkExists ("tcp_time_wait_timeout_sec" ); ! isEmptyValue (reflect .ValueOf (tcpTimeWaitTimeoutSecProp )) && (ok || ! reflect .DeepEqual (v , tcpTimeWaitTimeoutSecProp )) {
554+ obj ["tcpTimeWaitTimeoutSec" ] = tcpTimeWaitTimeoutSecProp
555+ }
543556 logConfigProp , err := expandNestedComputeRouterNatLogConfig (d .Get ("log_config" ), d , config )
544557 if err != nil {
545558 return err
@@ -702,6 +715,9 @@ func resourceComputeRouterNatRead(d *schema.ResourceData, meta interface{}) erro
702715 if err := d .Set ("tcp_transitory_idle_timeout_sec" , flattenNestedComputeRouterNatTcpTransitoryIdleTimeoutSec (res ["tcpTransitoryIdleTimeoutSec" ], d , config )); err != nil {
703716 return fmt .Errorf ("Error reading RouterNat: %s" , err )
704717 }
718+ if err := d .Set ("tcp_time_wait_timeout_sec" , flattenNestedComputeRouterNatTcpTimeWaitTimeoutSec (res ["tcpTimeWaitTimeoutSec" ], d , config )); err != nil {
719+ return fmt .Errorf ("Error reading RouterNat: %s" , err )
720+ }
705721 if err := d .Set ("log_config" , flattenNestedComputeRouterNatLogConfig (res ["logConfig" ], d , config )); err != nil {
706722 return fmt .Errorf ("Error reading RouterNat: %s" , err )
707723 }
@@ -803,6 +819,12 @@ func resourceComputeRouterNatUpdate(d *schema.ResourceData, meta interface{}) er
803819 } else if v , ok := d .GetOkExists ("tcp_transitory_idle_timeout_sec" ); ! isEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , tcpTransitoryIdleTimeoutSecProp )) {
804820 obj ["tcpTransitoryIdleTimeoutSec" ] = tcpTransitoryIdleTimeoutSecProp
805821 }
822+ tcpTimeWaitTimeoutSecProp , err := expandNestedComputeRouterNatTcpTimeWaitTimeoutSec (d .Get ("tcp_time_wait_timeout_sec" ), d , config )
823+ if err != nil {
824+ return err
825+ } else if v , ok := d .GetOkExists ("tcp_time_wait_timeout_sec" ); ! isEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , tcpTimeWaitTimeoutSecProp )) {
826+ obj ["tcpTimeWaitTimeoutSec" ] = tcpTimeWaitTimeoutSecProp
827+ }
806828 logConfigProp , err := expandNestedComputeRouterNatLogConfig (d .Get ("log_config" ), d , config )
807829 if err != nil {
808830 return err
@@ -1104,6 +1126,20 @@ func flattenNestedComputeRouterNatTcpTransitoryIdleTimeoutSec(v interface{}, d *
11041126 return v
11051127}
11061128
1129+ func flattenNestedComputeRouterNatTcpTimeWaitTimeoutSec (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
1130+ if v == nil || isEmptyValue (reflect .ValueOf (v )) {
1131+ return 120
1132+ }
1133+ // Handles the string fixed64 format
1134+ if strVal , ok := v .(string ); ok {
1135+ if intVal , err := stringToFixed64 (strVal ); err == nil {
1136+ return intVal
1137+ } // let terraform core handle it if we can't convert the string to an int.
1138+ }
1139+
1140+ return v
1141+ }
1142+
11071143func flattenNestedComputeRouterNatLogConfig (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
11081144 if v == nil {
11091145 return nil
@@ -1335,6 +1371,10 @@ func expandNestedComputeRouterNatTcpTransitoryIdleTimeoutSec(v interface{}, d Te
13351371 return v , nil
13361372}
13371373
1374+ func expandNestedComputeRouterNatTcpTimeWaitTimeoutSec (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
1375+ return v , nil
1376+ }
1377+
13381378func expandNestedComputeRouterNatLogConfig (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
13391379 l := v .([]interface {})
13401380 if len (l ) == 0 || l [0 ] == nil {
0 commit comments