Skip to content

Commit efeedf9

Browse files
committed
docs: consolidate User-Agent related sections
This brings together the provider-level and `provider_meta` module-scoped sections to provide a more complete picture of all the ways in which User-Agent headers can be extended.
1 parent 1b2c903 commit efeedf9

File tree

1 file changed

+53
-30
lines changed

1 file changed

+53
-30
lines changed

website/docs/index.html.markdown

Lines changed: 53 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -234,33 +234,6 @@ provider "aws" {
234234
credential_process = custom-process --username jdoe
235235
```
236236

237-
### Module-scoped User-Agent Information with `provider_meta`
238-
239-
The AWS provider supports sending provider metadata via the [`provider_meta` block](https://developer.hashicorp.com/terraform/internals/provider-meta).
240-
This block allows module authors to provide additional information in the `User-Agent` header, scoped only to resources defined in a given module.
241-
242-
For example, the following `terraform` block can be used to append additional User-Agent details.
243-
244-
```terraform
245-
terraform {
246-
required_providers {
247-
aws = {
248-
source = "hashicorp/aws"
249-
version = "~> 6.0"
250-
}
251-
}
252-
253-
provider_meta "aws" {
254-
user_agent = [
255-
"example-demo/0.0.1 (a demo module)"
256-
]
257-
}
258-
}
259-
```
260-
261-
Note that `provider_meta` is defined within the `terraform` block.
262-
The `provider` block is inherited from the root module.
263-
264237
## AWS Configuration Reference
265238

266239
|Setting|Provider|[Environment Variable][envvars]|[Shared Config][config]|
@@ -329,16 +302,66 @@ See the assume role documentation [section on web identities](https://docs.aws.a
329302
## Custom User-Agent Information
330303

331304
By default, the underlying AWS client used by the Terraform AWS Provider creates requests with User-Agent headers including information about Terraform and AWS SDK for Go versions.
332-
To provide additional information in the User-Agent headers, set the `TF_APPEND_USER_AGENT` environment variable, or use the `user_agent` block.
333305

334-
When using the environment variable, the value will be directly appended to the User-Agent header.
306+
There are three ways to provide additional User-Agent information.
307+
308+
1. The `user_agent` provider argument.
309+
1. The `TF_APPEND_USER_AGENT` environment variable.
310+
1. The [`provider_meta`](https://developer.hashicorp.com/terraform/internals/provider-meta) `user_agent` argument.
311+
312+
The first two options will apply the additional information to all resources, while `provider_meta` will be scoped only to the module in which it is configured.
313+
314+
### `user_agent` Provider Argument
315+
316+
When using the `user_agent` provider argument, the items will be appended to the User-Agent header in order.
317+
318+
For example,
319+
320+
~> The [`user_agent`](./functions/user_agent.html.markdown) provider-defined function can be used to format the name, version, and comment components.
321+
322+
```terraform
323+
provider "aws" {
324+
user_agent = [
325+
provider::aws::user_agent("example-demo", "0.0.1", "a comment"),
326+
]
327+
}
328+
```
329+
330+
### `TF_APPEND_USER_AGENT` Environment Variable
331+
332+
When using the environment variable, the provided value will be directly appended to the User-Agent header.
335333
For example,
336334

337335
```console
338336
% export TF_APPEND_USER_AGENT="JenkinsAgent/i-12345678 BuildID/1234 (Optional Extra Information)"
339337
```
340338

341-
When using the `user_agent` list attribute, the items will be appended to the User-Agent in order.
339+
### `provider_meta` `user_agent` Argument
340+
341+
The AWS provider supports sending provider metadata via the [`provider_meta` block](https://developer.hashicorp.com/terraform/internals/provider-meta).
342+
This block allows module authors to provide additional information in the `User-Agent` header, scoped only to resources defined in a given module.
343+
344+
For example,
345+
346+
~> In a module, `provider_meta` is defined within the `terraform` block.
347+
The `provider` block is inherited from the root module.
348+
349+
```terraform
350+
terraform {
351+
required_providers {
352+
aws = {
353+
source = "hashicorp/aws"
354+
version = "~> 6.0"
355+
}
356+
}
357+
358+
provider_meta "aws" {
359+
user_agent = [
360+
provider::aws::user_agent("example-demo", "0.0.1", "a comment"),
361+
]
362+
}
363+
}
364+
```
342365

343366
## Argument Reference
344367

0 commit comments

Comments
 (0)