-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
azurerm_key_vault_{key|secret|certificate}
- Directly using key_vault_id
during read and delete
#20326
Conversation
…ult_id` during read and delete The `key_vault_id` is a required, force new property, which is always a constant in the state file if the resource is properly created/imported via Terraform. Especially, for import, this property is constructed by the importer and set to the state prior to calling the `Read` for all the affected 3 resources. Therefore, there is actually only one place that is required to transmute the key vault URI to its resource id: the importer. While for the others: - Create/Update: it is always available in the plan input - Read/Delete: it is always available in the state This PR removes the transmuation code in the read and delete, but directly use the `key_vault_id` from state.
hi @magodo Thanks for this PR. As mentioned previously (in I think #17536), unfortunately we can't rely on Instead, can we look to workaround the upstream API in a different manner - perhaps by extending the timeout here? Thanks! |
@jackofallops Unfortunately, extending the timeout doesn't help here since if the target ARM cache doesn't hold the record of the key vault at one point, there is no guarantee when the record will be synced eventually. I agree that during read, there is only the terraform-provider-azurerm/internal/services/keyvault/key_vault_key_resource.go Lines 38 to 41 in e3ae00c
Where in the importer, it always set the
Given this, it should be safe to get the Following is the evidence that this works as I said: The > github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*MultiLevelFieldReader).ReadFieldMerge() ./vendor/github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema/field_reader_multi.go:53 (PC: 0xe4a109)
48: "Error reading level %s: %s", l, err)
49: }
50:
51: // TODO: computed
52: if out.Exists {
=> 53: result = out
54: }
55: }
56:
57: if l == level {
58: break
(dlv) p l
"state" Which indicates that attribute is read from the |
@magodo however this isn't guaranteed to work where the config has been removed and a user runs Since we can't rely on Once we're fully migrated over to I'm wondering if there's a means of working around this API issue in the interim by invalidating the cache using an ever changing filter, for example, rather than doing:
if we were instead to do check the name equals the exact value, and that it doesn't equal the current time in ticks:
WDYT? Thanks! |
@tombuildsstuff My above debug session has been tested for both direct I'm not sure how/whether After all, please reconsider evaluate this PR, as the issue has been really a pain for a long while and this PR can almost fix that (except for the import case). I think we shall review and merge this, then revert the change once we migrate to |
A small update about the actual source that reads the |
@tombuildsstuff Since our provider is still using v5 protocol, it has the same definition as v6 that the read request won't be able to read from config: Can we revisit this PR? |
@magodo we've closed multiple variations of this PR stating that we can't use this approach - and we continue to have no plans to support using Since unfortunately we're unable to take this approach and we've closed multiple variations of this PR - I'm going to have to lock this PR for the moment - whilst we're open to other ways of solving this issue (to workaround the API issue), unfortunately we can't use Thanks! |
The
key_vault_id
is a required, force new property, which is always a constant in the state file if the resource is properly created/imported via Terraform. Especially, for import, this property is constructed by the importer and set to the state prior to calling theRead
for all the affected 3 resources. Therefore, there is actually only one place that is required to transmute the key vault URI to its resource id: the importer. While for the others:This PR removes the transmuation code in the read and delete, but directly use the
key_vault_id
from state.This is a follow up of #17536.
(Finally) Fix #11059.
I've verified that for a terraform workspace that only contains
azurerm_key_vault_key
, aterraform plan
andterraform destroy
won't call the resource LIST API.