What are the minimum permissions required to create a budget?

Jonathan Share 6 Reputation points
2021-05-18T21:13:21.67+00:00

I'm trying to create a minimal CustomRole for running terraform on my hobby project. One of the first things I'm trying to automate is the creation of a Budget so that I can be sure I get alerted before spending too much money.

The terraform provider uses the following API https://learn.microsoft.com/en-us/rest/api/consumption/budgets/createorupdate

My role definition currently looks like the following

{  
   "assignableScopes": [  
      "/subscriptions/<redacted>"  
   ],  
   "description": "Perform only the actions necesary for running Terraform from GitLab CI",  
   "id": "/subscriptions/<redacted>/providers/Microsoft.Authorization/roleDefinitions/<redacted>",  
   "name": "<redacted>",  
   "permissions": [  
      {  
         "actions": [  
            "Microsoft.Consumption/budgets/read",  
            "Microsoft.Consumption/budgets/write",  
            "Microsoft.Resources/subscriptions/resourceGroups/read",  
            "Microsoft.Resources/subscriptions/resourceGroups/write",  
            "Microsoft.Web/serverfarms/Read",  
            "Microsoft.Web/serverfarms/Write",  
            "microsoft.insights/actionGroups/read",  
            "microsoft.insights/actionGroups/write",  
            "microsoft.web/register/action"  
         ],  
         "dataActions": [ ],  
         "notActions": [ ],  
         "notDataActions": [ ]  
      }  
   ],  
   "roleName": "my-ci-role",  
   "roleType": "CustomRole",  
   "type": "Microsoft.Authorization/roleDefinitions"  
}  
  

However terraform is still failing with the following error message

Service returned an error. Status=401 Code="401" Message="Unauthorized. Request ID: 9e51f598-886e-4d66-a037-b82660a72862"  

Some services give information on which permission is missing, unfortunately this one doesn't and I have no idea where to find this information.

Azure Cost Management
Azure Cost Management
A Microsoft offering that enables tracking of cloud usage and expenditures for Azure and other cloud providers.
3,557 questions
Azure Role-based access control
Azure Role-based access control
An Azure service that provides fine-grained access management for Azure resources, enabling you to grant users only the rights they need to perform their jobs.
950 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. olufemia-MSFT 2,861 Reputation points
    2021-05-20T00:19:32.347+00:00

    Hello @Jonathan Share , Thanks for the post. Per official ACM documentation, adding the built-in role: Cost Management Contributor should resolve this.

    98061-cmcontribtor.png

    Hope this helps but do let me know if you have any followup questions.

    Cheers.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.