Skip to content
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

azuread_service_principal_delegated_permission_grant when a grant already exists #681

Closed
Andrei-Predoiu opened this issue Nov 26, 2021 · 5 comments · Fixed by #685
Closed

Comments

@Andrei-Predoiu
Copy link

Andrei-Predoiu commented Nov 26, 2021

Regarding the new feature here
#676

Currently, i am using a null resource that calls az ad app permission grant as a workaround. I would like to use the new resource
azuread_service_principal_delegated_permission_grant.

I have over 50 applications in my state and it seems like i have to import the existing grants, otherwise i will get the following error:
DelegatedPermissionGrantsClient.BaseClient.Post(): unexpected status 409 with OData error: Request_MultipleObjectsWithSameKeyValue: Permission entry already exists.

I have no idea on how to even get the id's of the grants so that i can import them.

Any advice on this @manicminer

@manicminer
Copy link
Contributor

manicminer commented Nov 26, 2021

Hi @Andrei-Predoiu, thanks for opening this issue. I believe the grant details can be retrieved with az ad app permission list-grants, it looks like the objectId field here contains the ID you need when importing. This can be filtered by app ID as needed.

You should be able to script something around this if you have a lot of grants that you'd like to import into Terraform - both to generate some Terraform configuration and to build the actual terraform import commands. Hope this helps!

@Andrei-Predoiu
Copy link
Author

Hi @manicminer thanks! The command seems to give me what i need : az ad app permission list-grants --id <appID> but when i try to import it i get

azuread_service_principal_delegated_permission_grant.default_admin_grant: Importing from ID "kDloYbLmikGW-fJG7g0OHUdSGa-rgFtPmfN73tteQRA"...
╷
│ Error: resource azuread_service_principal_delegated_permission_grant doesn't support import

Obviously, import should be possible, even according to the docs. Is this a bug or am i missing something?

@manicminer
Copy link
Contributor

@Andrei-Predoiu It looks like this is a bug! Sorry about this, I'll work on a fix to be included in next week's release.

@github-actions
Copy link

github-actions bot commented Dec 3, 2021

This functionality has been released in v2.12.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!

@github-actions
Copy link

github-actions bot commented Jan 2, 2022

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.