@@ -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,
@@ -698,6 +734,7 @@ func resourceStorageTransferJobCreate(d *schema.ResourceData, meta interface{})
698
734
EventStream: expandEventStream(d.Get("event_stream").([]interface{})),
699
735
TransferSpec: expandTransferSpecs(d.Get("transfer_spec").([]interface{})),
700
736
ReplicationSpec: expandReplicationSpecs(d.Get("replication_spec").([]interface{})),
737
+ LoggingConfig: expandTransferJobLoggingConfig(d.Get("logging_config").([]interface{})),
701
738
NotificationConfig: expandTransferJobNotificationConfig(d.Get("notification_config").([]interface{})),
702
739
}
703
740
@@ -792,6 +829,11 @@ func resourceStorageTransferJobRead(d *schema.ResourceData, meta interface{}) er
792
829
return err
793
830
}
794
831
832
+ err = d.Set("logging_config", flattenTransferJobLoggingConfig(res.LoggingConfig))
833
+ if err != nil {
834
+ return err
835
+ }
836
+
795
837
return nil
796
838
}
797
839
@@ -861,6 +903,15 @@ func resourceStorageTransferJobUpdate(d *schema.ResourceData, meta interface{})
861
903
}
862
904
}
863
905
906
+ if d.HasChange("logging_config") {
907
+ fieldMask = append(fieldMask, "logging_config")
908
+ if v, ok := d.GetOk("logging_config"); ok {
909
+ transferJob.LoggingConfig = expandTransferJobLoggingConfig(v.([]interface{}))
910
+ } else {
911
+ transferJob.LoggingConfig = nil
912
+ }
913
+ }
914
+
864
915
if len(fieldMask) == 0 {
865
916
return nil
866
917
}
@@ -1466,3 +1517,32 @@ func flattenReplicationSpec(replicationSpec *storagetransfer.ReplicationSpec) []
1466
1517
}
1467
1518
return []map[string]interface{}{data}
1468
1519
}
1520
+
1521
+ func expandTransferJobLoggingConfig(loggingConfigs []interface{}) *storagetransfer.LoggingConfig {
1522
+ if len(loggingConfigs) == 0 || loggingConfigs[0] == nil {
1523
+ return nil
1524
+ }
1525
+
1526
+ loggingConfig := loggingConfigs[0].(map[string]interface{})
1527
+ var apiData = &storagetransfer.LoggingConfig{
1528
+ LogActions: tpgresource.ConvertStringArr(loggingConfig["log_actions"].([]interface{})),
1529
+ LogActionStates: tpgresource.ConvertStringArr(loggingConfig["log_action_states"].([]interface{})),
1530
+ EnableOnpremGcsTransferLogs: loggingConfig["enable_on_prem_gcs_transfer_logs"].(bool),
1531
+ }
1532
+
1533
+ return apiData
1534
+ }
1535
+
1536
+ func flattenTransferJobLoggingConfig(loggingConfig *storagetransfer.LoggingConfig) []map[string]interface{} {
1537
+ if loggingConfig == nil {
1538
+ return nil
1539
+ }
1540
+
1541
+ data := map[string]interface{}{
1542
+ "log_actions": loggingConfig.LogActions,
1543
+ "log_action_states": loggingConfig.LogActionStates,
1544
+ "enable_on_prem_gcs_transfer_logs": loggingConfig.EnableOnpremGcsTransferLogs,
1545
+ }
1546
+
1547
+ return []map[string]interface{}{data}
1548
+ }
0 commit comments