Comments (7)
Are you using 23:00
or 6:00
as your start time? It looks inconsistent between your plan and config.
from terraform-google-vm.
Are you using
23:00
or6:00
as your start time? It looks inconsistent between your plan and config.
Good call, edited accordingly
from terraform-google-vm.
Which value are you actually using though? Because I notice that the plan was attempting to change 6:00
to 06:00` which might be the cause of your permadiff.
from terraform-google-vm.
Also it looks like an upstream issue: hashicorp/terraform-provider-google#8460
from terraform-google-vm.
Which value are you actually using though? Because I notice that the plan was attempting to change
6:00
to 06:00` which might be the cause of your permadiff.
I noticed that during testing as well and updated first to 06:00 and then to 23:00 where I still experienced the permadiff issues.
from terraform-google-vm.
I was able to resolve creating a module that uses the same snapshot_schedule variable format, but uses a different snapshot policy resource:
# Build the region into the proper format
locals {
region = "https://www.googleapis.com/compute/v1/projects/${var.project_id}/regions/${var.region}"
}
# Build the weekly_schedule variables from the weekly_snapshot_schedule variable if it contains a weekly schedule
locals {
weekly_schedule = var.snapshot_schedule.weekly_schedule != null
weekly_schedule_start_time = var.snapshot_schedule.weekly_schedule == null ? "" : var.snapshot_schedule.weekly_schedule.day_of_weeks["start_time"]
weekly_schedule_day = var.snapshot_schedule.weekly_schedule == null ? "" : var.snapshot_schedule.weekly_schedule.day_of_weeks["day"]
}
resource "null_resource" "module_depends_on" {
triggers = {
value = length(var.module_depends_on)
}
}
# If weekly_schedule is not needed, build the snapshot policy for day or hourly using dynamic blocks
resource "google_compute_resource_policy" "dynamic_snapshot_policy" {
count = local.weekly_schedule ? 0 : 1
name = "${var.name}-snapshot"
project = var.project_id
region = local.region
snapshot_schedule_policy {
retention_policy {
max_retention_days = var.snapshot_retention_policy.max_retention_days
on_source_disk_delete = var.snapshot_retention_policy.on_source_disk_delete
}
schedule {
dynamic "daily_schedule" {
for_each = var.snapshot_schedule.daily_schedule == null ? [] : [var.snapshot_schedule.daily_schedule]
content {
days_in_cycle = daily_schedule.value.days_in_cycle
start_time = daily_schedule.value.start_time
}
}
dynamic "hourly_schedule" {
for_each = var.snapshot_schedule.hourly_schedule == null ? [] : [var.snapshot_schedule.hourly_schedule]
content {
hours_in_cycle = hourly_schedule.value["hours_in_cycle"]
start_time = hourly_schedule.value["start_time"]
}
}
}
snapshot_properties {
labels = {
name = var.enable_vss ? "windows" : "linux"
}
storage_locations = ["us"]
guest_flush = var.enable_vss
}
}
depends_on = [null_resource.module_depends_on]
}
# If weekly schedule is declared, build the snapshot policy using the local weekly variables
resource "google_compute_resource_policy" "weekly_snapshot_policy" {
count = local.weekly_schedule ? 1 : 0
name = "${var.name}-snapshot"
project = var.project_id
region = local.region
snapshot_schedule_policy {
retention_policy {
max_retention_days = var.snapshot_retention_policy.max_retention_days
on_source_disk_delete = var.snapshot_retention_policy.on_source_disk_delete
}
schedule {
weekly_schedule {
day_of_weeks {
start_time = local.weekly_schedule_start_time
day = local.weekly_schedule_day
}
}
}
snapshot_properties {
labels = {
name = var.enable_vss ? "windows" : "linux"
}
storage_locations = ["us"]
guest_flush = var.enable_vss
}
}
depends_on = [null_resource.module_depends_on]
}
# Determine which schedule resource should drive the attachement
locals {
snapshot_policy_name = local.weekly_schedule ? google_compute_resource_policy.weekly_snapshot_policy[0].name : google_compute_resource_policy.dynamic_snapshot_policy[0].name
}
# Attach the policy to the disks from the disk variables
resource "google_compute_disk_resource_policy_attachment" "attachment" {
for_each = toset(var.disks)
name = local.snapshot_policy_name
project = element(split("/", each.key), index(split("/", each.key), "projects", ) + 1, )
disk = element(split("/", each.key), index(split("/", each.key), "disks", ) + 1, )
zone = element(split("/", each.key), index(split("/", each.key), "zones", ) + 1, )
depends_on = [null_resource.module_depends_on, google_compute_resource_policy.dynamic_snapshot_policy, google_compute_resource_policy.weekly_snapshot_policy ]
}
from terraform-google-vm.
Confirmed that improperly formatted time was the cause of the issues despite my best efforts at reading plan outputs - closing issue.
from terraform-google-vm.
Related Issues (20)
- Add IPv6 Support HOT 1
- Upgrading from 7.9.0 to 8.0.0 breaks existing google_compute_instance_template
- Error specifying source_image or source_image_family
- Error: project: required field is not set HOT 1
- managed instance group update_policy conflict on required variables HOT 2
- Instance Template creates pd-standard disk instead of pd-balanced HOT 1
- Please expose resource_policies as a variable for the instance_template HOT 2
- Autoscaling signal empty condition HOT 1
- modules/umig creates a group per instance if num_instances>1 HOT 1
- Module for `instance_template` fails `terraform validate` in `v9.0.0` release HOT 2
- Add secure tags (resource_manager_tags) on compute_instance module
- Link to project_services module broken HOT 1
- Add support for enable_display and allow_stopping_for_update to compute_instance HOT 1
- B
- Attaching the existing disk in Instance template HOT 1
- Optional object type attributes are experimental: instance_template/variables.tf line 169 HOT 2
- Property "static_ips" isn't use in compute instance HOT 2
- Usage examples missing HOT 1
- Add Support for the source_image field on additional_disks
- Support resource_manager_tags on instance_template module
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from terraform-google-vm.