-
Notifications
You must be signed in to change notification settings - Fork 302
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_application_api_access not allowing flexibility when creating multiple permissions from MicrosoftGraph #1247
Comments
Hi @bdorplatt, thanks for raising this issue. You are correct, the locals {
my_roles = [
"Application.Read.All",
"Group.Read.All",
"User.Read.All",
]
my_scopes = [
"email",
"openid",
"User.ReadWrite",
]
}
data "azuread_application_published_app_ids" "well_known" {}
data "azuread_service_principal" "msgraph" {
client_id = data.azuread_application_published_app_ids.well_known.result["MicrosoftGraph"]
}
resource "azuread_application_registration" "example" {
display_name = "my-application-2n3hf4gQ"
}
resource "azuread_application_api_access" "example_msgraph" {
application_id = azuread_application_registration.example.id
api_client_id = data.azuread_application_published_app_ids.well_known.result["MicrosoftGraph"]
role_ids = [for v in local.my_roles: data.azuread_service_principal.msgraph.app_role_ids[v]]
scope_ids = [for v in local.my_scopes: data.azuread_service_principal.msgraph.oauth2_permission_scope_ids[v]]
} |
@manicminer Thank you for the clarification on this and the suggestion to use an inline Now we are trying to add an API access for a permission scope in the app itself and can't determine the syntax (or what to point to for referencing it correctly. The following is what we've tried and it doesn't work:
This results in: We had previously accomplished this as follows with provisioners but are moving away from that since the new resources are available:
|
After some trial and error, we were able to get this to work as expected using the following:
|
Great to hear! I hope this helps with usage of the new resources. Since there's no further action for maintainers, I'm going to go ahead and close this one out. If you need further assistance with the provider, I would recommend our community resources, as well as our Slack community to which you can find a link in the project readme. |
Community Note
Terraform (and AzureAD Provider) Version
Terraform: v1.3.7
Provider: v2.45.0
Affected Resource(s)
azuread_application_api_access
Terraform Configuration Files
Old method with resource_access blocks within azuread_application resource
Using the new separate resource azuread_application_api_access
We also tried this to pull from the separate lists into the same resource block but it is still trying to create multiple conflicting resources
Debug Output
Panic Output
Expected Behavior
Permissions are added while iterating through a list of needed permissions from a variable.
Actual Behavior
It seems that you can only have 1 resource created for MicrosoftGraph with all role_id and scope_id underneath it. This isn't allowing multiple azuread_application_api_access resources for the same API to be created. With the old nested resource_access block, we could iterate through two separate lists for the delegated and application permissions as in the above example.
Error: A resource with the ID "/applications/11111111-1111-1111-1111-111111111111/apiAccess/00000003-0000-0000-c000-000000000000" already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for "azuread_application_api_access" for more information.
Steps to Reproduce
terraform apply
Important Factoids
References
The text was updated successfully, but these errors were encountered: