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

Add an optional provider level label "goog-terraform-provisioned" #17170

Conversation

modular-magician
Copy link
Collaborator

The intention of this change is to make it easy to identify GCP resources that are managed by Terraform when using other clients like Cloud Console. Overall, this builds on and behaves much the same as provider default labels from #8670, but instead of free form labels it adds a single specific structured label, goog-terraform-provisioned = "true" when enabled. That is:

provider "google" {
  skip_terraform_attribution_label = false
}

Is roughly equivalent to:

provider "google" {
  default_labels = {
    goog-terraform-provisioned = "true"
  }
}

The change is documented in provider_reference.html.markdown. In short, this is a no-op change for users that do not opt in to the feature. For users that do opt in (by setting skip_terraform_attribution_label = false in the provider configuration), there are two modes of operation configured with the optional terraform_attribution_label_addition_strategy field:

  • CREATION_ONLY The goog-terraform-provisioned label will only be added to newly created resources. This is the default value.
  • PROACTIVE The label will be added to all resources during subsequent terraform apply runs.

Tests are included for a handful of resources, including MMv1, DCL, and handwritten resources.

I'm creating this as a draft PR to gather early feedback (and because as I'm writing this description I thought of some tests changes to make 🤔)

Release Note Template for Downstream PRs (will be copied)

provider: added an optional provider level label `goog-terraform-provisioned` to identify resources that were created by Terraform when viewing/editing these resources in other tools.

Derived from GoogleCloudPlatform/magic-modules#9808

…shicorp#9808)

* Add an optional provider level label indicating a resource was provisioned by Terraform

* Fix TestAccComputeAddress_withAttributionRemoved to reflect actual behavior

* Fix a bad merge

* Skip tests that change provider config when running under VCR

* Fix some tabs that should have been spaces

* Update mmv1/third_party/terraform/website/docs/guides/provider_reference.html.markdown

Co-authored-by: Riley Karson <rileykarson@google.com>

* Update mmv1/third_party/terraform/website/docs/guides/provider_reference.html.markdown

Co-authored-by: Riley Karson <rileykarson@google.com>

* Change skip_terraform_attribution_label to add_terraform_attribution_label

* Fix a test that was missed in the change to add_terraform_attribution_label

---------

Co-authored-by: Riley Karson <rileykarson@google.com>

[upstream:b5225df5b0deeeca07dfe08a5b538d1b54ee1200]

Signed-off-by: Modular Magician <magic-modules@google.com>
@modular-magician modular-magician merged commit a6719af into hashicorp:main Feb 2, 2024
4 checks passed
Copy link

github-actions bot commented Mar 4, 2024

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 issues.
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 Mar 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant