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 repeat interval to Storage Transfer Job resource #4144

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/5811.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
storagetransfer: added `repeat_interval` field to `google_storage_transfer_job` resource
```
18 changes: 15 additions & 3 deletions google-beta/resource_storage_transfer_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,13 @@ func resourceStorageTransferJob() *schema.Resource {
DiffSuppressFunc: diffSuppressEmptyStartTimeOfDay,
Description: `The time in UTC at which the transfer will be scheduled to start in a day. Transfers may start later than this time. If not specified, recurring and one-time transfers that are scheduled to run today will run immediately; recurring transfers that are scheduled to run on a future date will start at approximately midnight UTC on that date. Note that when configuring a transfer with the Cloud Platform Console, the transfer's start time in a day is specified in your local timezone.`,
},
"repeat_interval": {
Type: schema.TypeString,
ValidateFunc: validateDuration(),
Optional: true,
Description: `Interval between the start of each scheduled transfer. If unspecified, the default value is 24 hours. This value may not be less than 1 hour. A duration in seconds with up to nine fractional digits, terminated by 's'. Example: "3.5s".`,
Default: "86400s",
},
},
},
Description: `Schedule specification defining when the Transfer Job should be scheduled to start, end and what time to run.`,
Expand Down Expand Up @@ -774,15 +781,16 @@ func expandTransferSchedules(transferSchedules []interface{}) *storagetransfer.S
ScheduleStartDate: expandDates(schedule["schedule_start_date"].([]interface{})),
ScheduleEndDate: expandDates(schedule["schedule_end_date"].([]interface{})),
StartTimeOfDay: expandTimeOfDays(schedule["start_time_of_day"].([]interface{})),
RepeatInterval: schedule["repeat_interval"].(string),
}
}

func flattenTransferSchedule(transferSchedule *storagetransfer.Schedule) []map[string][]map[string]interface{} {
func flattenTransferSchedule(transferSchedule *storagetransfer.Schedule) []map[string]interface{} {
if reflect.DeepEqual(transferSchedule, &storagetransfer.Schedule{}) {
return nil
}

data := map[string][]map[string]interface{}{
data := map[string]interface{}{
"schedule_start_date": flattenDate(transferSchedule.ScheduleStartDate),
}

Expand All @@ -794,7 +802,11 @@ func flattenTransferSchedule(transferSchedule *storagetransfer.Schedule) []map[s
data["start_time_of_day"] = flattenTimeOfDay(transferSchedule.StartTimeOfDay)
}

return []map[string][]map[string]interface{}{data}
if transferSchedule.RepeatInterval != "" {
data["repeat_interval"] = transferSchedule.RepeatInterval
}

return []map[string]interface{}{data}
}

func expandGcsData(gcsDatas []interface{}) *storagetransfer.GcsData {
Expand Down
1 change: 1 addition & 0 deletions google-beta/resource_storage_transfer_job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ resource "google_storage_transfer_job" "transfer_job" {
seconds = 0
nanos = 0
}
repeat_interval = "604800s"
}

depends_on = [
Expand Down
3 changes: 3 additions & 0 deletions website/docs/r/storage_transfer_job.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ resource "google_storage_transfer_job" "s3-bucket-nightly-backup" {
seconds = 0
nanos = 0
}
repeat_interval = "604800s"
}

depends_on = [google_storage_bucket_iam_member.s3-backup-bucket]
Expand Down Expand Up @@ -136,6 +137,8 @@ The following arguments are supported:

* `start_time_of_day` - (Optional) The time in UTC at which the transfer will be scheduled to start in a day. Transfers may start later than this time. If not specified, recurring and one-time transfers that are scheduled to run today will run immediately; recurring transfers that are scheduled to run on a future date will start at approximately midnight UTC on that date. Note that when configuring a transfer with the Cloud Platform Console, the transfer's start time in a day is specified in your local timezone. Structure [documented below](#nested_start_time_of_day).

* `repeat_interval` - (Optional) Interval between the start of each scheduled transfer. If unspecified, the default value is 24 hours. This value may not be less than 1 hour. A duration in seconds with up to nine fractional digits, terminated by 's'. Example: "3.5s".

<a name="nested_object_conditions"></a>The `object_conditions` block supports:

* `max_time_elapsed_since_last_modification` - (Optional) A duration in seconds with up to nine fractional digits, terminated by 's'. Example: "3.5s".
Expand Down