hashicorp / terraform-provider-google

Terraform Provider for Google Cloud Platform
https://registry.terraform.io/providers/hashicorp/google/latest/docs
Mozilla Public License 2.0
2.34k stars 1.74k forks source link

Official support of custom User Agent Info #17351

Open nathanzanon opened 8 months ago

nathanzanon commented 8 months ago

Community Note

Description

The provider appears to support including custom User Agent info through the use of the environment variable TF_APPEND_USER_AGENT -- current config, also as far back as v2.0.0 (I didn't look further back).

This environment variable seems to be a defacto standard adopted by certain providers.

There is no documentation about it for the google provider(s) (or in Terraform itself), so it seems somewhat un-official.

If this is "officially" supported, could use of the TF_APPEND_USER_AGENT environment variable please be documented.

New or Affected Resource(s)

Potential Terraform Configuration

export TF_APPEND_USER_AGENT="Build/65d6ca037bb7af1b41960551"
terraform init
terraform plan

References

melinath commented 8 months ago

@nathanzanon we'll have to look into this in more detail, and may consider removing this environment variable. could you elaborate on your use case? Is it already met by GOOGLE_TERRAFORM_USERAGENT_EXTENSION?

SarahFrench commented 8 months ago

I took a look about the origins of TF_APPEND_USER_AGENT:

This ENV has been here a long time and is currently in use for both SDK/plugin-framework parts of the provider.

nathanzanon commented 8 months ago

Hi @melinath,

I didn't actually know about the GOOGLE_TERRAFORM_USERAGENT_EXTENSION feature (I clearly need to RTFM ... again), I was only looking for the TF_APPEND_USER_AGENT variable that I'd seen used before.

Using GOOGLE_TERRAFORM_USERAGENT_EXTENSION would mostly satisfy our use case, noting that it appears this functionality was added in version 3.60.0.

Although TF_APPEND_USER_AGENT has the benefit that it's picked-up by Terraform and used in calls to a gcs backend, but if set for the init it has the potential downside that it's sent to registries.

@SarahFrench's investigation got me curious as to the exact releases the functionality was added. From my looking through the changelogs they don't mention them, so from my looking through history it appears:

A bit ashamed to admit we will have configs using providers older than 3.60.0, so GOOGLE_TERRAFORM_USERAGENT_EXTENSION wouldn't fully cover our usage.

BBBmau commented 5 months ago

From triage: we'll want to document using the newer environment variable GOOGLE_TERRAFORM_USERAGENT_EXTENSION over the older TF_APPEND_USER_AGENT variable.

Figure out how to add support for this into the GCS backend.