Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add path on GCS targets in google_storage_transfer_job #8931

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion 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,
Computed: true,
Type: schema.TypeString,
Description: `Google Cloud Storage path in bucket to transfer`,
ValidateFunc: validateRegexp("^[^/].*/$"),
},
},
}
}
Expand Down Expand Up @@ -695,14 +702,23 @@ func expandGcsData(gcsDatas []interface{}) *storagetransfer.GcsData {
}

gcsData := gcsDatas[0].(map[string]interface{})
return &storagetransfer.GcsData{

var apiData = &storagetransfer.GcsData{
BucketName: gcsData["bucket_name"].(string),
}
var path = gcsData["path"].(string)

if len(path) != 0 {
apiData.Path = path
}

return apiData
}

func flattenGcsData(gcsData *storagetransfer.GcsData) []map[string]interface{} {
data := map[string]interface{}{
"bucket_name": gcsData.BucketName,
"path": gcsData.Path,
bambuchaAdm marked this conversation as resolved.
Show resolved Hide resolved
}

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