-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
AzureRM Provider - Creating Management Grp/Associating to Subscription - Errors- Can not parse "parent_management_group_id" AND Can not parse "management_group_id" AND "expected 2 segments within the Resource ID but got 1" #21441
Comments
Poor Terraform Azure RM provider documentation, after spending 2 full days and checking permissions as well(app registration vs users--both allowed to create mgmt groups by default unless a toggle on root mgmt group is turned on for "Require write permissions for creating new management groups") the issue is related to how the input for management group id/root management group id is given-DONT JUST MENTION THE ID BUT GIVE A PATH LIKE THIS:
REPLACED BY And,this will not be visible to you in the portal though terraform creates it.One needs to elevate oneself to User Access Admin role(even if Global Admin) on the Tenant(Directory) Level as described here. Same logic applies for subscription id (THOUGH PATH SEEMS VERY DIFFERENT/NO PROPER INFO AVAILABLE ONLINE): by |
Further,it may be noted that if attempting to modify/read/write existing management groups,the above run may need additional permissions as mentioned here:
To move a management group or subscription to be a child of another management group, three rules need to be evaluated as true. If you're doing the move action, you need: 2-Management group write access on the target parent management group. 3-Management group write access on the existing parent management group. Exception: If the target or the existing parent management group is the root management group, the permissions requirements don't apply. Since the root management group is the default landing spot for all new management groups and subscriptions, you don't need permissions on it to move an item. If the Owner role on the subscription is inherited from the current management group, your move targets are limited. You can only move the subscription to another management group where you have the Owner role. You can't move it to a management group where you're a Contributor because you would lose ownership of the subscription. If you're directly assigned to the Owner role for the subscription (not inherited from the management group), you can move it to any management group where you're assigned the Contributor role. =========== Management group built in roles have been covered in same article here. Further,moving subscription from one mgmt group to other requires OWNER access given to terraform app registration at the SUBSCRIPTION Scope(Subscription being moved). This is in addition to previous 2 permissions described. NOTE:Azure Resource Manager caches management group hierarchy details for up to 30 minutes. As a result, moving a management group may not immediately be reflected in the Azure portal. Regards, |
hi @adi-garg Thanks for opening this issue here. Taking a look through here, it appears that we're referencing the Resource ID in the Example Usage, rather than the Management Group and Subscription UUID's, so this looks correct to me: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/management_group_subscription_association#example-usage Where a UUID is required we explicitly call that out as a UUID in the documentation, however a Resource ID is called out as Since it appears that we're calling this out as a Resource ID ( We're working on improving the error message returned from the Resource ID parsers so that this is clearer, however this since isn't specific to a single Resource ID Parser, I'm going to close this issue in favour of hashicorp/go-azure-helpers#155 where this work is being scoped out. Thanks! |
Hello @tombuildsstuff ,
Which should ideally be this in context of Azure to work:
Similarly,the article here should ideally have an explicit 2nd example clarifying things for the way management group id and subscription id are used:
|
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. |
Is there an existing issue for this?
Community Note
Terraform Version
v1.4.5
AzureRM Provider Version
3.52.0
Affected Resource(s)/Data Source(s)
azurerm_management_group,azurerm_management_group_subscription_association
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
1.Expected creation of a new management group under a parent management group(pre existing).
2.Expected tieing up of a pre-existing subscription to a Management Group ID.
Actual Behaviour
The listed 3 errors get generated.
It works fine if just Management group is created without mentioning the parent /without having subscription to management link resource.
Steps to Reproduce
1.terraform init
2.terraform plan
Important Factoids
No response
References
No response
The text was updated successfully, but these errors were encountered: