Skip to content

Commit

Permalink
Add path on GCS targets in google_storage_transfer_job
Browse files Browse the repository at this point in the history
  • Loading branch information
bambuchaAdm committed Apr 16, 2021
1 parent 0c3db9b commit 03e7bc9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions google/resource_storage_transfer_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,13 @@ func gcsDataSchema() *schema.Resource {
Type: schema.TypeString,
Description: `Google Cloud Storage bucket name.`,
},
"path": {
Optional: true,
Type: schema.TypeString,
Description: `Google Cloud Storage path in bucket to transfer`,
Default: "",
ValidateFunc: validateRegexp("^[^/].*/$"),
},
},
}
}
Expand Down Expand Up @@ -697,12 +704,14 @@ func expandGcsData(gcsDatas []interface{}) *storagetransfer.GcsData {
gcsData := gcsDatas[0].(map[string]interface{})
return &storagetransfer.GcsData{
BucketName: gcsData["bucket_name"].(string),
Path: gcsData["path"].(string),
}
}

func flattenGcsData(gcsData *storagetransfer.GcsData) []map[string]interface{} {
data := map[string]interface{}{
"bucket_name": gcsData.BucketName,
"path": gcsData.Path,
}

return []map[string]interface{}{data}
Expand Down
2 changes: 2 additions & 0 deletions google/resource_storage_transfer_job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,11 @@ resource "google_storage_transfer_job" "transfer_job" {
transfer_spec {
gcs_data_source {
bucket_name = google_storage_bucket.data_source.name
path = "foo/bar/"
}
gcs_data_sink {
bucket_name = google_storage_bucket.data_sink.name
path = "fizz/buzz/"
}
}
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/storage_transfer_job.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,12 @@ The `transfer_options` block supports:
The `gcs_data_sink` block supports:

* `bucket_name` - (Required) Google Cloud Storage bucket name.
* `path` - (Optional) Root path to transfer objects. Must be an empty string or full path name that ends with a '/'. This field is treated as an object prefix. As such, it should generally not begin with a '/'.

The `gcs_data_source` block supports:

* `bucket_name` - (Required) Google Cloud Storage bucket name.
* `path` - (Optional) Root path to transfer objects. Must be an empty string or full path name that ends with a '/'. This field is treated as an object prefix. As such, it should generally not begin with a '/'.

The `aws_s3_data_source` block supports:

Expand Down

0 comments on commit 03e7bc9

Please sign in to comment.