Skip to content

Bug: Fix Compute Disk Snapshot Schedule #476

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
52 changes: 26 additions & 26 deletions modules/compute_disk_snapshot/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,34 +103,34 @@ spec:
)
required: true
- name: snapshot_schedule
description: The scheduled to be used by the snapshot policy. For more details see https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_resource_policy#schedule
description: 'The schedule to be used by the snapshot policy. Exactly one of daily_schedule, hourly_schedule, or weekly_schedule must be provided. For more details see [the official documentation](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_resource_policy#schedule).'
varType: |-
object(
{
daily_schedule = object(
{
days_in_cycle = number
start_time = string
}
)
hourly_schedule = object(
{
hours_in_cycle = number
start_time = string
}
)
weekly_schedule = object(
{
day_of_weeks = set(object(
{
day = string
start_time = string
}
))
}
)
}
)
{
daily_schedule = optional(object(
{
days_in_cycle = number
start_time = string
}
))
hourly_schedule = optional(object(
{
hours_in_cycle = number
start_time = string
}
))
weekly_schedule = optional(object(
{
day_of_weeks = set(object(
{
day = string
start_time = string
}
))
}
))
}
)
required: true
- name: snapshot_properties
description: The properties of the schedule policy. For more details see https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_resource_policy#snapshot_properties
Expand Down
22 changes: 15 additions & 7 deletions modules/compute_disk_snapshot/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,22 @@ variable "snapshot_retention_policy" {
}

variable "snapshot_schedule" {
description = "The scheduled to be used by the snapshot policy. For more details see https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_resource_policy#schedule"
description = "The schedule to be used by the snapshot policy. For more details see https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_resource_policy#schedule"
type = object(
{
daily_schedule = object(
daily_schedule = optional(object(
{
days_in_cycle = number
start_time = string
}
)
hourly_schedule = object(
))
hourly_schedule = optional(object(
{
hours_in_cycle = number
start_time = string
}
)
weekly_schedule = object(
))
weekly_schedule = optional(object(
{
day_of_weeks = set(object(
{
Expand All @@ -64,9 +64,17 @@ variable "snapshot_schedule" {
}
))
}
)
))
}
)
validation {
condition = (
(var.snapshot_schedule.daily_schedule != null && var.snapshot_schedule.hourly_schedule == null && var.snapshot_schedule.weekly_schedule == null) ||
(var.snapshot_schedule.daily_schedule == null && var.snapshot_schedule.hourly_schedule != null && var.snapshot_schedule.weekly_schedule == null) ||
(var.snapshot_schedule.daily_schedule == null && var.snapshot_schedule.hourly_schedule == null && var.snapshot_schedule.weekly_schedule != null)
)
error_message = "Exactly one of daily_schedule, hourly_schedule, or weekly_schedule must be provided."
}
}

variable "snapshot_properties" {
Expand Down