terraform-provider-google icon indicating copy to clipboard operation
terraform-provider-google copied to clipboard

default labels on provider

Open marengaz opened this issue 4 years ago • 3 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. If the issue is assigned to the "modular-magician" user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If the issue is assigned to a user, that user is claiming responsibility for the issue. If the issue is assigned to "hashibot", a community member has claimed the issue already.

Description

it would be awesome to define a default set of labels on the provider to be applied to all resources using that provider

New or Affected Resource(s)

  • the provider itself
  • potentially all resources with settable labels?

Potential Terraform Configuration

provider "google" {
  project     = "my-project-id"
  region      = "us-central1"
  default_labels = {
    owner = "my-team",
    dept = "my-dept"
  }
}

resource "google_pubsub_topic" "example1" {
  name = "example-topic1"

  labels = {
    foo = "bar",
    owner = "special-team"
  }
}

resource "google_pubsub_topic" "example2" {
  name = "example-topic2"
}

when deploying the resources above, the labels would be merged like merge(provider.default_labels, resource.labels) resulting in the resources having the following labels when deployed:

example1:

  • foo = "bar"
  • owner = "special-team"
  • dept = "my-dept"

example2:

  • owner = "my-team"
  • dept = "my-dept"

References

  • Tracking issue: http://b/235080729

marengaz avatar Sep 22 '20 10:09 marengaz

For a reference implementation, here's how it is done on the AWS provider with the default_tags parameter at the provider level:

  • https://github.com/hashicorp/terraform-provider-aws/pull/17974
  • https://github.com/hashicorp/terraform-provider-aws/pull/18730
  • https://github.com/hashicorp/terraform-provider-aws/pull/19006
  • https://github.com/hashicorp/terraform-provider-aws/pull/19084

And those are also exposed by a datasource:

  • https://github.com/hashicorp/terraform-provider-aws/pull/19391

PS: I'm not trolling, it's just that this works pretty well.

pdecat avatar Dec 02 '21 10:12 pdecat

Bringing in updated sizing from https://github.com/hashicorp/terraform-provider-google/issues/9067

rileykarson avatar Jun 06 '22 16:06 rileykarson

Note: This hit a threshold for prioritization, and we're going to investigate what the change might look like in detail. There's a moderate amount of scoping work to be done.

rileykarson avatar Jun 06 '22 17:06 rileykarson

will be awesome, aws-like

korenlev avatar Aug 22 '22 20:08 korenlev

+1

enchorb avatar Nov 30 '22 17:11 enchorb

+1

hostmit avatar Dec 11 '22 21:12 hostmit

+1

srinath-prabhu avatar Feb 06 '23 09:02 srinath-prabhu

+1

nyc3-bwong avatar Feb 22 '23 14:02 nyc3-bwong

+1

zosoabi avatar Feb 28 '23 07:02 zosoabi

+1

RyanDV01 avatar Mar 02 '23 17:03 RyanDV01

+1

vitordeap avatar Jun 21 '23 21:06 vitordeap

+1

hronix avatar Jun 26 '23 09:06 hronix

+1

alessandro-hc avatar Jul 28 '23 20:07 alessandro-hc

Support for default labels have been merged into the 5.0.0 major release feature branch with https://github.com/GoogleCloudPlatform/magic-modules/pull/8670

This will release with v5.0.0. Check https://github.com/hashicorp/terraform-provider-google/issues/15582 for more details on the major release.

Closing this issue for tracking purposes.

c2thorn avatar Sep 11 '23 19:09 c2thorn

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.

github-actions[bot] avatar Oct 12 '23 02:10 github-actions[bot]