-
Notifications
You must be signed in to change notification settings - Fork 301
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
Error: Deleting access package resource and catalog association #1091
Comments
Hello @manicminer, @alexwilcox9 |
291│ {ResourceName} can not be deleted because there are active I have had this error myself but I don't believe it's a bug in the provider. I was unable to delete the resource because there were users with active entitlements on those access packages. Mine was a bit weird though because the portal did not show any active assignments. Hope that helps |
Having all deployment failing because of 1 manual assignement makes using these features a bit perilous. |
Hello I am also able to confirm that the access package resource and catalog association throw an error without active entitlements when trying to delete a brand new / never used access package... For information, I am using the version 2.37.0 of the provider. Do you think the 2.39.0 would be more stable on that field ? |
Always worth using the latest version, although I don't see anything in the changelog that would suggest any changes to this behaviour. The message about active entitlements come from Azure and Terraform is just presenting them to you. Are you able to delete the unused access package/catalog from the poral or do you get the same error? |
I have updated the provider to 2.39. remove the local state. Clean all resource on the portal. Apply / Destroy and same error. I have 2 errors ╷ |
I too am having this problem. When developing it's a bit annoying as I'm having to manually remove the entries in the state file, and manually remove in the portal before deploying again. I know this isn't a helpful comment, I can supply logs if you like, but it's been covered above. I'm using Service Principal with "EntitlementManagement.ReadWrite.All". It seems to be a problem in the order the resources are deleted in. |
The order of the resource deletion seems correct unfortunately. The issue is a missing msgraph API Endpoint for access_package_resource_package_association_resource "DELETE". That's why only the state is being/can be removed. As you cannot remove a resource catalog association when it is still associated with an access package, terraform fails... There is a hint in the go provider resource @pmatthews05 It is enough to delete the resource association to the access package and run terraform afterwards. We'll have to wait for Microsoft to update the MSGraph beta i think or someone finds a workaround utilizing the API triggered when manually deleting associations in the portal to be used within a null resource. https://elm.iga.azure.com/api/v1/accessPackages('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx')/accessPackageResourceRoleScopes |
Thanks all, since this is surfacing these errors I think we'll look to add a warning note to the provider docs in the meantime. |
Hello and thanks @gittyNico, |
Hello, here's the answer of Microsoft support on the ticket I open few hours ago : • Indeed, for you to be able to Delete an Access Package you need first to guarantee that there are no active assignments. Thanks |
@cedrox The issue is about associations not about assignments. There is a method already implemented to Delete "Catalog Resource Associations", but this does not exist for Access Package Resource Associations: |
@manicminer, it seems that this is not be a limitation of graph API. If we delete access package, maybe we don't need to delete the association that come with it ? Thanks |
@cedrox that is correct, removing the access package does not require the associations being removed. But breaking the order of terraform resource creating and deletion is not really what you want to have in your code. |
Thanks for you answer. Can you clarify ? Do you mean that we cannot do full CRUD operations on access package ? You accept that the delete operation is not supported ? Then the workaround is the only way to delete my access package ? |
Sorry if I may have confused you. I do not accept the not working CRUD operation on access packages including resource associations, neither am I working at MS or hashicorp. I am just adding details to this issue, so that when MS brings in an update to their msgraph beta API, this can quickly be implemented in the provider. Maybe you can update your support request and ask for associations not assignments, but other than that I have no workaround apart from manually deleting the associations or maybe hijacking the GUI API:
|
Hello @gittyNico, I ask the support to understand why this method is not in the graph: https://elm.iga.azure.com/api/v1/accessPackages('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx')/accessPackageResourceRoleScopes |
Hello, here's the answer of the MS support regarding this endpoint that could confirm that we have MSGraph endpoints available to remove resources from catalogs. To get to these endpoints we can first check the relationship that exists between “AccessPackageCatalog” and “AccessPackageResource”. • Afterwards you can successfully remove the intended resource: |
Additionally, to be able to Delete an Access Package you need first to guarantee that there are no active assignments. It would be a great improvement for the future Hope that help |
Hey, would any of you be able to see if the solution in my draft PR works for you? I've given it a go in my environment and seem to be able delete pretty reliably |
Hi @alexwilcox9, I was able to test it in our environment and successfully deleted access package and catalog associations without assignments! Thank you for your contribution! |
This functionality has been released in v2.41.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
Context
When we try to delete our access package
Terraform (and AzureAD Provider) Version
2.37
Affected Resource(s)
azuread_access_package_resource_package_association
Terraform Configuration Files
Debug Output
│ Error: Deleting access package resource and catalog association with resource "GUID"@"AadGroup" and catalog id "GUID".
288│
289│ AccessPackageResourceRequestClient.BaseClient.Post(): unexpected status 400
290│ with OData error: InvalidDeleteResourceHasEntitlements: The resource:
291│ {ResourceName} can not be deleted because there are active
292│ entitlements.
Expected Behavior
terraform destroy all the resources
Actual Behavior
When resources are deleted, we have a 400 on the delation of the object azuread_access_package_resource_package_association
Steps to Reproduce
with code below do :
terraform apply
terraform destroy
Important Factoids
Azure public cloud
Proper permission with role and permission
References
#903
The text was updated successfully, but these errors were encountered: