hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.47k stars 4.55k forks source link

Support for MCA billing roles in azurerm_role_assignment #15211

Open keesvandenhoekict opened 2 years ago

keesvandenhoekict commented 2 years ago

Community Note

Description

This request is to add support in azurerm_role_assignment to support billing role assignment for MCA(Microsoft Customer Agreement) customers. The equivalent change for Enterprise Agreement customers (enrollment accounts) has been realised in #10547

New or Affected Resource(s)

Potential Terraform Configuration

resource "azurerm_role_assignment" "create_subscription_role_on_invoice_section" {
  scope                = "providers/Microsoft.Billing/billingAccounts/<SECRET1>/billingProfiles/<SECRET-2>/invoiceSections/<“SECRET-3>
  role_definition_name = "Azure subscription creator"
  principal_id         = azurerm_user_assigned_identity.example.principal_id
}

References

b-c-lucas commented 2 years ago

@jackofallops, would this be a matter of adding 3 levels of scoping to azurerm_role_assignment like done in #10890?

Scopes:

eastlondoner commented 2 years ago

Ran into this today. I wonder if the validation should be relaxed here. There is already a function: ParseAzureResourceIDWithoutSubscription - this could be sufficient validation for role assignments - rather than finding every case of resource ids without subscription and implementing separate role assignment validation for them.

An example of another entity that does not have a subscription but I think should support role assignment are tenants.

e.g. I think that this should work:

resource "azurerm_role_assignment" "create_global_admin_role_on_tenant" {
  scope                = "tenants/<TENANT ID>"
  role_definition_name = "Global administrator"
  principal_id         = azurerm_user_assigned_identity.example.principal_id
}
circa10a commented 5 months ago

Any thoughts on this issue? This is still a blocker today

circa10a commented 4 months ago

For anyone else reading this, I worked around the issue by creating a group with the appropriate billing permissions and added identities such as service principals to said group

omerfsen commented 4 months ago

For anyone else reading this, I worked around the issue by creating a group with the appropriate billing permissions and added identities such as service principals to said group

thoug not required adding a sample code for ur workaround would be nice

omerfsen commented 3 months ago

why not use azuread_directory_role_assignment instead of azurerm_role_assignment ? It seems azuread is better suited

FrancoisPoinsot commented 3 months ago

In case someone ends up on that issue while looking for a solution, here is a related issue with a workaround: https://github.com/Azure/terraform-provider-azapi/issues/400