Please vote on this issue by adding a :thumbsup: reaction to the original issue to help the community and maintainers prioritize this request
Please do not leave comments along the lines of "+1", "me too" or "any updates", they generate extra noise for issue followers and do not help prioritize the request
If you are interested in working on this issue or have submitted a pull request, please leave a comment and review the contribution guide to help.
╷
│ Error: retrieving Token (Subscription: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
│ Resource Group Name: "acrrecreationtest"
│ Registry Name: "acrrecreationtest"
│ Token Name: "cicdpushpulltoken"): unexpected status 404 (404 Not Found) with error: ResourceNotFound: The resource cicdpushpulltoken could not be found.
│
│ with azurerm_container_registry_token_password.acr_push_pull_token_passwords,
│ on main.tf line 49, in resource "azurerm_container_registry_token_password" "acr_push_pull_token_passwords":
│ 49: resource "azurerm_container_registry_token_password" "acr_push_pull_token_passwords" {
│
│ retrieving Token (Subscription: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
│ Resource Group Name: "acrrecreationtest"
│ Registry Name: "acrrecreationtest"
│ Token Name: "cicdpushpulltoken"): unexpected status 404 (404 Not Found) with error: ResourceNotFound: The resource cicdpushpulltoken
│ could not be found.
During the recreation of the Container Registry, the resources azurerm_container_registry_scope_map, azurerm_container_registry_token and azurerm_container_registry_token_password should have been planned to be recreated.
Actual Behaviour
The recreation of the Container Registry happened without also flagging the resources azurerm_container_registry_scope_map, azurerm_container_registry_token and azurerm_container_registry_token_password to be recreated.
After the recreation of the Container Registry has been done successfully, subsequent plans fail as the azurerm_container_registry_token cannot be found anymore, as it was silently deleted together with the Container Registry.
A workaround that helped me to get over this is to use a lifecycle block like the following to force recreation of the resources in question together with the recreation of the Container Registry:
terraform taint azurerm_container_registry.container_registry simulating a recreation of the Container Registry, e.g. due to changes to some fields that requires recreation
terraform apply for the recreation of the Container Registry
terraform plan or terraform apply for seeing the error
Is there an existing issue for this?
Community Note
Terraform Version
1.8.2
AzureRM Provider Version
3.116.0
Affected Resource(s)/Data Source(s)
azurerm_container_registry_token, azurerm_container_registry_scope_map
Terraform Configuration Files
Debug Output/Panic Output
https://gist.github.com/HontoNoRoger/5913efb4a2d213b9d2d218a3ae0af30a
Expected Behaviour
During the recreation of the Container Registry, the resources
azurerm_container_registry_scope_map
,azurerm_container_registry_token
andazurerm_container_registry_token_password
should have been planned to be recreated.Actual Behaviour
The recreation of the Container Registry happened without also flagging the resources
azurerm_container_registry_scope_map
,azurerm_container_registry_token
andazurerm_container_registry_token_password
to be recreated.After the recreation of the Container Registry has been done successfully, subsequent plans fail as the
azurerm_container_registry_token
cannot be found anymore, as it was silently deleted together with the Container Registry.A workaround that helped me to get over this is to use a lifecycle block like the following to force recreation of the resources in question together with the recreation of the Container Registry:
Steps to Reproduce
terraform apply
for the first rolloutterraform taint azurerm_container_registry.container_registry
simulating a recreation of the Container Registry, e.g. due to changes to some fields that requires recreationterraform apply
for the recreation of the Container Registryterraform plan
orterraform apply
for seeing the errorImportant Factoids
No response
References
No response