Open andyroyle opened 2 years ago
A ~dirty hack~ workaround is to use time_static
to hold the value of time_rotating
. This value will then be modified when time_rotating
is recreated:
resource "time_rotating" "rotate" {
rotation_minutes = 1
}
resource "time_static" "rotate" {
rfc3339 = time_rotating.rotate.rfc3339
}
resource "local_file" "test" {
filename = "${path.module}/file.txt"
content = "foo"
lifecycle {
replace_triggered_by = [
time_static.rotate
]
}
}
Hi @andyroyle thanks for raising this issue, fixing this issue requires a significant rewrite in the resource's logic and will result in a breaking change for practitioners. We will consider this issue as part of a larger effort for a Time Provider major release in the future but we do not have a timeline for this at the moment.
Community Note
Terraform Version
v1.2.7
Affected Resource(s)
Terraform Configuration Files
Debug Output
debug output
Expected Behavior
The
local_file
resource should be replaced whentime_rotating.rotate
expires.Actual Behavior
When using
time_rotating
in thereplace_triggered_by
field of another resource (in this case, alocal_file
) the downstream resource is not replaced.The
time_rotating
resource is replaced without replacing the downstream resource.The terraform plan shows a
create
for thetime_rotating
resource, even though it is areplace
. This seems to be caused by the fact that when the time inrotation_rfc3339
has passed, theread
operation removes the resource from state.This is seen in the debug output:
This causes terraform to view the operation as a
create
instead of areplace
and so thereplace_triggered_by
for the downstream resource isn't triggered.Steps to Reproduce
terraform init
terraform apply --auto-approve
sleep 60
(wait 1 minute for the time_rotating to expire)terraform apply --auto-approve
References