Skip to content

Conversation

@shlomimatichin
Copy link
Contributor

referencing env0/terratag#17

look at the example below: google_billing_budget resource
comes from google-beta provider. previously, code assumed
the provider name is the first part by underscore, e.g., google.

data "google_billing_account" "account" {
  provider = google-beta
  billing_account = "000000-0000000-0000000-000000"
}

resource "google_billing_budget" "budget" {
  provider = google-beta
  billing_account = data.google_billing_account.account.id
  display_name = "Example Billing Budget"

  budget_filter {
    projects = ["projects/my-project-name"]
    credit_types_treatment = "EXCLUDE_ALL_CREDITS"
    services = ["services/24E6-581D-38E5"] # Bigquery
  }

  amount {
    specified_amount {
      currency_code = "USD"
      units = "100000"
    }
  }

  threshold_rules {
    threshold_percent = 0.5
  }
  threshold_rules {
    threshold_percent = 0.9
    spend_basis = "FORECASTED_SPEND"
  }
}

referencing env0/terratag#17

look at the example below: `google_billing_budget` resource
comes from `google-beta` provider. previously, code assumed
the provider name is the first part by underscore, e.g., `google`.

```
data "google_billing_account" "account" {
  provider = google-beta
  billing_account = "000000-0000000-0000000-000000"
}

resource "google_billing_budget" "budget" {
  provider = google-beta
  billing_account = data.google_billing_account.account.id
  display_name = "Example Billing Budget"

  budget_filter {
    projects = ["projects/my-project-name"]
    credit_types_treatment = "EXCLUDE_ALL_CREDITS"
    services = ["services/24E6-581D-38E5"] # Bigquery
  }

  amount {
    specified_amount {
      currency_code = "USD"
      units = "100000"
    }
  }

  threshold_rules {
    threshold_percent = 0.5
  }
  threshold_rules {
    threshold_percent = 0.9
    spend_basis = "FORECASTED_SPEND"
  }
}
```
@minamijoyo
Copy link
Owner

@shlomimatichin Good point! It's true that the google-beta provider has an irregular naming.

However, not only google and google-beta provider use google_ prefix, strictly speaking, but also any forks such as registry.terraform.io/foo/google can use google_ because Terraform v0.13 introduced a hierarchical namespace for providers. This means that we cannot strictly detect provider binary only from a resource name.

In this case, I think it's better to allow users to pass a fully qualified provider source rather than a local provider name.
https://www.terraform.io/docs/configuration/provider-requirements.html

$ tfschema resource show -source registry.terraform.io/hashicorp/google-beta google_billing_budget

If we omit the registry hostname, it's reasonable to implicitly assume registry.terraform.io by default, just like Terraform. So a shorthand version can be the following:

$ tfschema resource show -source hashicorp/google-beta google_billing_budget

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants