-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
Allow replace_triggered_by to trigger on containing instance (self) properties #31702
Comments
Hi @azrdev, Thanks for filing the issue. I understand the need to to try and workaround the problem with the provider in this case, but the if there is some external data you can retrieve to detect the desired point of replacement, you could store that data in a |
I'm trying to implement just that (since the provider fixed the issue and now has a timestamp field for expiration date): resource "vra_deployment" "vm" {
name = var.name
...
lifecycle {
replace_triggered_by = [ null_resource.expiration_marker ]
}
}
data "vra_deployment" "this" {
name = var.name
}
resource "null_resource" "expiration_marker" {
triggers = {
is_expired = timecmp(try(data.vra_deployment.vm.lease_expire_at, timestamp()), timestamp()) < 0
}
} but this fails when the vm is not yet present, the data source returns "not found". Guarding it with a count would introduce a depedency cycle (and prevent use of count). I'm raising an issue with the provider for proper filtering of expired VMs, in the meantime: any more suggestions for a workaround? |
Hi @azrdev, This type of configuration would be expected to fail for the reason given, the |
Thanks @jbardin for your assessment! Then I'll hope provider will move forward with a fix. |
@azrdev, based on your comment I am going to close this issue in lieu of the provider issue (vmware/terraform-provider-vra#473) - please let me know if I am mistaken and I can re-open this issue. It sounds like everything is working as designed on the Terraform core side, however. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Terraform Version
Use Cases
We're ordering VMs from a private vmWare vRealize Automation (vRA) version 8. An existing VM will be expired by vRA after some weeks, that is powered off and scheduled for deletion. When that happens, the vRA API still returns the VM, and thus does terraform. IMHO the provider should make it easy to identify expired deployments. There is a expiration date property which is incorrectly exported: vmware/terraform-provider-vra#436
And there is the
last_request
that happened inside vRA, which is the expiration action in my case, and could be used to recognize that state, by terraform.So as a workaround for my provider (and maybe also useful for other use cases) I want terraform to recreate my resource whenever the
last_request
property contains an expiration event.But adding
results in the following error on refresh/plan on an existing, expired deployment, instead of the desired action:
Attempted Solutions
Currently I'm able to at least abort further processing of expired VMs with
But this still requires manual interaction (removal of the VM to force a new creation).
Proposal
Make
replace_triggered_by
able to reference properties ofself
i.e. the containing resource.References
The text was updated successfully, but these errors were encountered: