hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager

Home Page:https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

New Resource: Consumption Budgets

philbal611 opened this issue Β· comments

Community Note

  • Please vote on this issue by adding a πŸ‘ reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

A new resource creates/manages budgets.

New or Affected Resource(s)

  • azurerm_consumption_budget

Potential Terraform Configuration

resource "azurerm_consumption_budget" "test" {
  name       = "test_budget"
  category   = "Cost"        // Cost, Usage
  amount     = 1000
  time_grain = "Monthly"     // Monthly, Quarterly, Annually

  filters {
    meters               = ["GUID"]         // required for `Usage` category
    resource_group_names = ["rg1", "rg2"]
    resources            = ["vm1", "vm2"]
  }

  notification {
    threshold      = 80                     // 0-1000
    operator       = "GreaterThanOrEqualTo" // EqualTo, GreaterThan, GreaterThanOrEqualTo
    contact_emails = ["email1", "email2"]
    action_groups  = ["ag1", "ag2"]
  }
}

References

@metacpp last month you started implementing this? Is it on the road-map for completion or can someone else pick up where you left off?

@mb290 Thanks for raising the question here.

Yes, we did the implementation, due to lack of "Enterprise Enrollments and Web Direct" subscriptions in that time, the validation was postponed.

We plan to do some validations firstly, then we should be able to share more info.

Just stay tuned for our next updates.

@metacpp thanks. If you'd like us to do some validations in our EA sub, can you point us to the direction of the branch? We can then custom fork it for our needs in the time being too.

What is the current state of this?

hi @mb290 @J0F3

After taking a look into this I believe this'd be best implemented as two resources (at this point in time):

  • azurerm_consumption_budget_subscription
  • azurerm_consumption_budget_resource_group

Unfortunately at this time I'm unable to provision a Consumption Budget within our (EA) subscription at this point in time - which means that I'm unable to validate if that's the right approach (but I believe it is). The flip side of that is that we'd be unable to run any tests for either of these resources at this time (which means we'd be unable to merge support for it until this is resolved).

I've gone through and requested permissions for this - but as I don't have a timeline for this unfortunately, and as such I'm going to assign this to the Blocked milestone for the moment. However in the interim it should be possible to use an ARM Template to deploy this, as in this example until this is natively supported.

Thanks,
Tom

@tombuildsstuff I'd probably focus on a single resource "azurerm_consumption_budget" as it's not necessarily about refining down to just sub or RG, but the documentation on the API has the same call, just with different filters.

If you look at the scope filter options it has the ability to refine at multiple different types of levels at the billing as well as resource:

'/subscriptions/{subscriptionId}/' for subscription scope,
'/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope,
'/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope,
'/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope,
'/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount scope,
'/providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope,
'/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile scope,
'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for invoiceSection scope.

As an aside, thanks for the offer of the Arm Template, however I'm good without it as last week I had to come up with a workaround as I couldn't wait any more unfortunately.

@tombuildsstuff
Is there a test/beta version some where which we may test? I have currently implemented the ARM template deployment. The drawback of it is however that the budget is not deleted when, for example the RG for wich the Budget was defined, is removed.

@tombuildsstuff any update on the access issue?

@tombuildsstuff I'm also closely monitoring this issue. We will heavily use this feature. Hopefully it will make it into v1.30.0!

@tombuildsstuff Please put me in the ring as someone highly interested in this. It would be appropriate to have this as an additional feature such that Terraform builds the Resource Group first then adds the budget during creation. During destroy, it removes the budget then deletes the Resource Group.

commented

Is there any update on this new ressource ?

@gwyss unfortunately we still have no means of testing this - so we're still blocked #2677 (comment)

commented

@tombuildsstuff Let me know if i can help with testing on my side. I am able to provision consumption budget.

@gwyss thanks for the offer, but we need to be able to run these tests nightly/on-demand - as such unfortunately it's something that needs Microsoft to assist us with; I've reached out to our contact there about this for an update.

Any updates on this? Would be an awesome feature...

Can i help escalate this to Mucrosoft ?
I have a few contact and hold a premier support account.

It would be great to have this

Any update on this?

Any Update on this issue at all ?

After a discussion with @tombuildsstuff in Slack #2677 (comment) is resolved and I'm starting work on the initial implementation of this at #9201. Subscriptions and Resource Groups will be in scope initially as independent resources

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.