Open ChrisTav424 opened 8 months ago
Noticed this yesterday too. It might be an Azure issue, in the activity log we see the Started event but never a completed event. I think the team was going to open a case with MS as well, will report back if they find anything.
Thanks @smokedlinq I will raise this with them too
I have been trying for a couple of days to make it work, and went through a couple of posts, just to find out this issue is marked as resolved. :smiling_face_with_tear:
Also tried changing the scope to RG but it failed.
When I try to create the resource it fails as mentioned before. The import fails too, saying that cannot import a non-existent remote object . Curious thing that the terraform apply
shows the resource ID that needs to be imported :thinking:
That's unusable for us at the moment.
1.5.7 1.6.3
3.79.0 3.70.0 3.65.0
terraform apply
Error: A resource with the ID "/subscriptions/---/---/---/xxx" already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for "azurerm_pim_eligible_role_assignment" for more information.
with azurerm_pim_eligible_role_assignment.test,
on elegible.tf line 15, in resource "azurerm_pim_eligible_role_assignment" "test":
15: resource "azurerm_pim_eligible_role_assignment" "test" {
A resource with the ID "/subscriptions/---/---/---/xxx" already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for "azurerm_pim_eligible_role_assignment" for more information.
terraform import
Error: Cannot import non-existent remote object
While attempting to import an existing object to
"azurerm_pim_eligible_role_assignment.test", the provider detected that no object exists with the given id. Only pre-existing objects can be imported; check that the id is correct and that it is associated with the provider's configured region or endpoint, or use "terraform apply" to create a new remote object for this resource.
I have been trying for a couple of days to make it work, and went through a couple of posts, just to find out this issue is marked as resolved. 🥲
Also tried changing the scope to RG but it failed.
When I try to create the resource it fails as mentioned before. The import fails too, saying that cannot import a non-existent remote object . Curious thing that the
terraform apply
shows the resource ID that needs to be imported 🤔That's unusable for us at the moment.
Terraform Versions
1.5.7 1.6.3
AzureRM Provider Versions
3.79.0 3.70.0 3.65.0
Output after
terraform apply
Error: A resource with the ID "/subscriptions/---/---/---/xxx" already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for "azurerm_pim_eligible_role_assignment" for more information. with azurerm_pim_eligible_role_assignment.test, on elegible.tf line 15, in resource "azurerm_pim_eligible_role_assignment" "test": 15: resource "azurerm_pim_eligible_role_assignment" "test" { A resource with the ID "/subscriptions/---/---/---/xxx" already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for "azurerm_pim_eligible_role_assignment" for more information.
Output after
terraform import
Error: Cannot import non-existent remote object While attempting to import an existing object to "azurerm_pim_eligible_role_assignment.test", the provider detected that no object exists with the given id. Only pre-existing objects can be imported; check that the id is correct and that it is associated with the provider's configured region or endpoint, or use "terraform apply" to create a new remote object for this resource.
I had the same issue. If you're using index keys and are working within Windows, you'd have to escape the index values like so. However, I ran into issues where the import claimed to be successful but didn't actually import into the state, so in the end I had to delete the existing PIM assignment from the portal and re-run it.
Try change your role_definition_id to /subscriptions/6918adf8---/providers/Microsoft.Authorization/roleDefinitions/ab8e14d6----
.
We had similar problem, but we are work with management group, it took us several days until we find what's wrong with it:
/providers/Microsoft.Authorization/roleDefinitions/ab8e14d6----
/subscriptions/6918adf8----/providers/Microsoft.Authorization/roleDefinitions/ab8e14d6----
Refer to section Example Usage (Subscription)
and Example Usage (Management Group)
in document of azurerm_pim_eligible_role_assignment
dupe of #23366
previously mentioned dupe is closed now, https://github.com/hashicorp/terraform-provider-azurerm/issues/23111 is open with active discussion (more about not-found errors than timeout tho)
@ChrisTav424, @smokedlinq, @jcframil, @MohnJadden are you still experiencing this error with the latest provider (currently v3.104.2)?
hi @manicminer , I have customer still got same issue after update to azureRM 3.104.2 It still states that the Resource with ID XXX already exists - to be managed via Terraform this resource needs to be imported into the State
Is it the case that the fix only works for PIM assignments created with the latest version of the provider and not pre-existing assignments?
Is there an existing issue for this?
Community Note
Terraform Version
1.6.3
AzureRM Provider Version
3.79.0
Affected Resource(s)/Data Source(s)
azurerm_pim_eligible_role_assignment
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
Apply successful
Actual Behaviour
The apply fails with the 'waiting for Role Management Policy to become ready: couldn't find resource (21 retries)'
The PIM roles have been created in the portal and when I run another terraform plan / apply it states that the resource needs to be imported into state.
This only seems to be a problem when you specify a scope at a subscription level
Steps to Reproduce
terraform apply
Important Factoids
No response
References
I have seen this referenced in a few places already but states that it is resolved
https://github.com/hashicorp/terraform-provider-azuread/issues/68 https://github.com/hashicorp/terraform-provider-azurerm/pull/22932