Closed aweingarten closed 2 months ago
Hi @aweingarten ,
Thank you for raising this issue. It's under investigation now. We will get back to you when we know more.
Regards, Marcin
@aweingarten,
We've managed to reproduce this situation. This is a known limitation of terraform, which can be overcome by running the terraform refresh
command.
We'll improve the documentation on our end to better describe this situation.
Please try to use terraform refresh
and let us know if this solves your issue.
Regards, Marcin
Hey @mstojanowski My understanding is that terraform refresh is deprecated and not recommended based on the official docs: https://developer.hashicorp.com/terraform/cli/commands/refresh
Warning: This command is deprecated, because its default behavior is unsafe if you have misconfigured credentials for any of your providers. See below for more information and recommended alternatives.
I can try to do terraform apply -refresh-only -auto-approve
after each run as a temp work around outside a production setting, but that seems to be highly discouraged by the docs. I don't think its a real solution as it would mask config drift.
Running TF apply should result in stable TF state. If its not then that's breaking the TF model. This is a feature of TF not a limitation.
Hello @aweingarten
Sorry for recommending deprecated solution. Based on https://developer.hashicorp.com/terraform/cli/commands/refresh Hashicorp currently suggest to use terraform apply -refresh-only
as it gives a way to review changes that will be set into state.
The problem with staging_version
and production_version
fields is that they actually are not part of property itself but a property activation - after property is modified we do not know if they will got new value after activation (as activation is done by differet resource that is dependent by property). We see this as Terraform limitation because Terraform sets value for fields only after given resource has been processed, not once whole config has been processed. As a result, those fields are not updated. From perspective of property resurce and those fields we are actually facing a drift here and that's why we suggest to do state refresh.
As a result we have no way to fix the issue that you mention. If you think it's better to don't have this fields at all in property resource rather then to have them with current behavior, please let us know.
Edit:
Alternatively, if you simply need to know what are current values of staging_version
and production_version
after activation, you can add a datasource akamai_property
(which also has those two fields) with explicite depends_on pointing to both activation resource. It should have correct values because it'll be executed after activations.
Best regards, Wojciech
yeah I empathize with the complexities here. My 2c is to remove the versions from the property resource and let them be managed by the activation resource instead. That should provide a much cleaner separation of concerns and make TF happy.
Hello @aweingarten Dropping those two fields is problematic from our perspective. Can you please write full use-case that you have, where those two fields values before refresh are causing problems?
Best regards, Wojciech
Hi there,
Affected Resource(s)
Please list the resources as a list, for example:
Terraform Configuration Files
When I run this my property's state is not updated
In subsequent runs I get the following in TF plan:
I have reproduced this from a CI-based build so I KNOW the state is not being manipulated by a person. When I checked the statefile I saw which suggests to me that at the end of that apply version 19 was activated.
However, when I look at my property in the state file I see that its still set to 18
Expected Behavior
The activation should be updating the staging version in the state but for some reason is not.
Actual Behavior
Because TF thinks that the state is being manually edited its forcing un-necessary resource changes slowing down my builds.
Steps to Reproduce
Please list the steps required to reproduce the issue, for example: you can see the build/ TF plans here: https://github.com/akamai-consulting/akamai-starterkit/actions/runs/9492787184/job/26199517994
Code is here: https://github.com/akamai-consulting/akamai-starterkit