@@ -295,6 +295,42 @@ func ResourceStorageTransferJob() *schema.Resource {
295
295
},
296
296
Description : `Notification configuration.` ,
297
297
},
298
+ "logging_config" : {
299
+ Type : schema .TypeList ,
300
+ Optional : true ,
301
+ MaxItems : 1 ,
302
+ Elem : & schema.Resource {
303
+ Schema : map [string ]* schema.Schema {
304
+ "log_actions" : {
305
+ Type : schema .TypeList ,
306
+ Optional : true ,
307
+ AtLeastOneOf : []string {"logging_config.0.enable_on_prem_gcs_transfer_logs" , "logging_config.0.log_actions" , "logging_config.0.log_action_states" },
308
+ Elem : & schema.Schema {
309
+ Type : schema .TypeString ,
310
+ ValidateFunc : validation .StringInSlice ([]string {"FIND" , "DELETE" , "COPY" }, false ),
311
+ },
312
+ Description : `Specifies the actions to be logged. Not supported for transfers with PosifxFilesystem data sources; use enable_on_prem_gcs_transfer_logs instead.` ,
313
+ },
314
+ "log_action_states" : {
315
+ Type : schema .TypeList ,
316
+ Optional : true ,
317
+ AtLeastOneOf : []string {"logging_config.0.enable_on_prem_gcs_transfer_logs" , "logging_config.0.log_actions" , "logging_config.0.log_action_states" },
318
+ Elem : & schema.Schema {
319
+ Type : schema .TypeString ,
320
+ ValidateFunc : validation .StringInSlice ([]string {"SUCCEEDED" , "FAILED" }, false ),
321
+ },
322
+ Description : `States in which logActions are logged. Not supported for transfers with PosifxFilesystem data sources; use enable_on_prem_gcs_transfer_logs instead.` ,
323
+ },
324
+ "enable_on_prem_gcs_transfer_logs" : {
325
+ Type : schema .TypeBool ,
326
+ Optional : true ,
327
+ AtLeastOneOf : []string {"logging_config.0.enable_on_prem_gcs_transfer_logs" , "logging_config.0.log_actions" , "logging_config.0.log_action_states" },
328
+ Description : `For transfers with a PosixFilesystem source, this option enables the Cloud Storage transfer logs for this transfer.` ,
329
+ },
330
+ },
331
+ },
332
+ Description : `Logging configuration.` ,
333
+ },
298
334
"schedule" : {
299
335
Type : schema .TypeList ,
300
336
Optional : true ,
@@ -692,6 +728,7 @@ func resourceStorageTransferJobCreate(d *schema.ResourceData, meta interface{})
692
728
EventStream : expandEventStream (d .Get ("event_stream" ).([]interface {})),
693
729
TransferSpec : expandTransferSpecs (d .Get ("transfer_spec" ).([]interface {})),
694
730
ReplicationSpec : expandReplicationSpecs (d .Get ("replication_spec" ).([]interface {})),
731
+ LoggingConfig : expandTransferJobLoggingConfig (d .Get ("logging_config" ).([]interface {})),
695
732
NotificationConfig : expandTransferJobNotificationConfig (d .Get ("notification_config" ).([]interface {})),
696
733
}
697
734
@@ -786,6 +823,11 @@ func resourceStorageTransferJobRead(d *schema.ResourceData, meta interface{}) er
786
823
return err
787
824
}
788
825
826
+ err = d .Set ("logging_config" , flattenTransferJobLoggingConfig (res .LoggingConfig ))
827
+ if err != nil {
828
+ return err
829
+ }
830
+
789
831
return nil
790
832
}
791
833
@@ -855,6 +897,15 @@ func resourceStorageTransferJobUpdate(d *schema.ResourceData, meta interface{})
855
897
}
856
898
}
857
899
900
+ if d .HasChange ("logging_config" ) {
901
+ fieldMask = append (fieldMask , "logging_config" )
902
+ if v , ok := d .GetOk ("logging_config" ); ok {
903
+ transferJob .LoggingConfig = expandTransferJobLoggingConfig (v .([]interface {}))
904
+ } else {
905
+ transferJob .LoggingConfig = nil
906
+ }
907
+ }
908
+
858
909
if len (fieldMask ) == 0 {
859
910
return nil
860
911
}
@@ -1454,3 +1505,32 @@ func flattenReplicationSpec(replicationSpec *storagetransfer.ReplicationSpec) []
1454
1505
}
1455
1506
return []map [string ]interface {}{data }
1456
1507
}
1508
+
1509
+ func expandTransferJobLoggingConfig (loggingConfigs []interface {}) * storagetransfer.LoggingConfig {
1510
+ if len (loggingConfigs ) == 0 || loggingConfigs [0 ] == nil {
1511
+ return nil
1512
+ }
1513
+
1514
+ loggingConfig := loggingConfigs [0 ].(map [string ]interface {})
1515
+ var apiData = & storagetransfer.LoggingConfig {
1516
+ LogActions : tpgresource .ConvertStringArr (loggingConfig ["log_actions" ].([]interface {})),
1517
+ LogActionStates : tpgresource .ConvertStringArr (loggingConfig ["log_action_states" ].([]interface {})),
1518
+ EnableOnpremGcsTransferLogs : loggingConfig ["enable_on_prem_gcs_transfer_logs" ].(bool ),
1519
+ }
1520
+
1521
+ return apiData
1522
+ }
1523
+
1524
+ func flattenTransferJobLoggingConfig (loggingConfig * storagetransfer.LoggingConfig ) []map [string ]interface {} {
1525
+ if loggingConfig == nil {
1526
+ return nil
1527
+ }
1528
+
1529
+ data := map [string ]interface {}{
1530
+ "log_actions" : loggingConfig .LogActions ,
1531
+ "log_action_states" : loggingConfig .LogActionStates ,
1532
+ "enable_on_prem_gcs_transfer_logs" : loggingConfig .EnableOnpremGcsTransferLogs ,
1533
+ }
1534
+
1535
+ return []map [string ]interface {}{data }
1536
+ }
0 commit comments