Skip to content
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

New Resource - azurerm_cost_management_export #11612

Closed
wants to merge 14 commits into from

Conversation

MattiasAng
Copy link
Contributor

@MattiasAng MattiasAng commented May 7, 2021

Fixes #11598.

Changes:

  • Updated costmanagement SDK to 2020-06-01
  • Added parsers and validation for Billing resource IDs.
  • Handle multiple providers in resource ID in ParseAzureResourceIDWithoutSubscription.

The parsing it quite ugly here but I couldn't come up with a better idea since ID always starts with the scope which creates a lot of different variations. Any feedback is welcome.

I haven't been able to run TestAccCostManagementExport_managementgroup due to requirement of EA subscription which I don't have access to at the moment.

This resource will also supersed azurerm_cost_management_export_resource_group so let me know if we should add a note there.

@mikeeq
Copy link

mikeeq commented Aug 24, 2021

Guys any progress on this one?

@upegnasrame
Copy link

any chances of getting this feature added to new release ?

Copy link
Member

@stephybun stephybun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR and your patience @MattiasAng. This is a great start! I've left some suggestions and it would be great if the merge conflicts could also be resolved.

@tombuildsstuff
Copy link
Contributor

hey @MattiasAng

Thanks for this PR / apologies for the delayed review here.

Within the Azure Provider we're moving away from generic resources which support a scope field in favour of separate resources for each scope (where possible). This is primarily for UX reasons given how the Azure API behaves when an invalid scope is specified, or when a scope is specified that doesn't exist which leads to the API returning unclear error messages. Historically this has also been a source of user confusion at import time, when importing a resource from an invalid scope (or with a typo) and getting an "API Version {some version} doesn't exist" error.

Although the new generic resource in this PR works, to be able to ship this and workaround the problems mentioned above we'd need to split this into a number of sub-resources. Whilst that initially sounds like a lot of code, we can use the technique used in the Policy Assignment resources to be able to split this out with minimal code, that involves:

  1. A base resource e.g. ./internal/services/policy/assignment_base_resource.go
  2. A resource (and tests) for each scope e.g. internal/services/policy/assignment_management_group_resource.go

Whilst that's a little more work within the Provider, ultimately that means that we can avoid these issues for users (who'll have less context about these issues) which is a worthwhile trade-off.

As such whilst I'd like to thank you for this contribution (and apologies for the delay giving this feedback) - since we're going to have to take a different approach here (which is quite a bit more work) I'm going to suggest that @stephybun takes a look into splitting this into a base resource - at which point it's possible to add these other resources pretty easily.

Thanks!

@stephybun
Copy link
Member

There is an open PR which contains the cost management export base resource as well as resources for the scopes subscription and resource group, as such I am going to close this in favour of #14140.

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement cost management export for all scopes, not just resource group
7 participants