Terraform Version
terraform version
Terraform v1.15.7
on darwin_arm64
+ provider registry.terraform.io/hashicorp/aws v6.53.0
Use Cases
Tooling that generates or validates Terraform configuration programmatically - code generators, language servers, linters, module scaffolding tools - discovers what a provider supports by reading terraform providers schema -json. That's how these tools learn about resources, data sources, ephemeral resources, functions, and the provider's own configuration schema today.
The AWS provider recently added support for terraform { provider_meta "aws" { user_agent = [...] } } (hashicorp/terraform-provider-aws#45464), letting modules tag their own attribution string onto the AWS provider's User-Agent header — used for example by terraform-aws-modules/terraform-aws-rds (terraform-aws-modules/terraform-aws-rds#615) to replace a static resource tag with proper request-level attribution.
Tooling that wants to generate a typed, validated provider_meta block for a given provider (the same way it already generates typed bindings for that provider's resources, data sources, and functions) has no schema to generate against — provider_meta is invisible to terraform providers schema -json, even for providers that implement it. This makes provider_meta the one schema-driven Terraform capability that can't be discovered the same way everything else can.
Attempted Solutions
Ran terraform providers schema -json against the AWS provider (6.53.0, which implements provider_meta "aws" { user_agent = [...] }) and inspected the full output:
- The per-provider schema object exposes exactly these top-level keys:
provider, resource_schemas, data_source_schemas, ephemeral_resource_schemas, functions, list_resource_schemas, action_schemas, resource_identity_schemas. No provider_meta key is present.
- Searched the entire captured JSON file (~19 MB) for the literal string
provider_meta. It appears exactly once, and only inside the human-readable description text of the functions.user_agent entry ("...for use with the user_agent argument in the provider or provider_meta block") - not as a structured schema entry.
- Cross-checked this against the documented output fields on the terraform providers schema CLI reference page, which lists
provider, resource_schemas, data_source_schemas, ephemeral_resource_schemas, and functions - provider_meta isn't documented as an output field either.
- Confirmed the plugin protocol itself already carries this data: docs/plugin-protocol/tfplugin6.proto's
GetProviderSchema.Response defines Schema provider_meta = 5;, a sibling field to Schema provider = 1;. So the provider genuinely returns a real schema for its provider_meta block over gRPC (that's how terraform init/validate type-check the user_agent argument's shape at parse time) — the JSON serialization in terraform providers schema -json just doesn't surface that field.
Without this, tools are left to either hardcode per-provider assumptions about provider_meta block contents, or fall back to an untyped escape hatch - unlike every other schema-driven capability the JSON output already supports.
Proposal
Add a provider_meta key to the per-provider object in terraform providers schema -json output, as a sibling to the existing provider key, sourced directly from the GetProviderSchema.Response.provider_meta field the plugin protocol already returns. Suggested shape - the same block/attributes schema representation already used for provider:
{
"format_version": "1.0",
"provider_schemas": {
"registry.terraform.io/hashicorp/aws": {
"provider": { "version": 0, "block": { "...": "..." } },
"provider_meta": {
"version": 0,
"block": {
"attributes": {
"user_agent": {
"type": ["list", "string"],
"description_kind": "plain",
"optional": true
}
}
}
},
"resource_schemas": { "...": "..." }
}
}
}
When a provider defines no provider_meta schema, this key would presumably be omitted for that provider, consistent with how other optional schema sections already behave.
References
Terraform Version
Use Cases
Tooling that generates or validates Terraform configuration programmatically - code generators, language servers, linters, module scaffolding tools - discovers what a provider supports by reading
terraform providers schema -json. That's how these tools learn about resources, data sources, ephemeral resources, functions, and the provider's own configuration schema today.The AWS provider recently added support for
terraform { provider_meta "aws" { user_agent = [...] } }(hashicorp/terraform-provider-aws#45464), letting modules tag their own attribution string onto the AWS provider's User-Agent header — used for example byterraform-aws-modules/terraform-aws-rds(terraform-aws-modules/terraform-aws-rds#615) to replace a static resource tag with proper request-level attribution.Tooling that wants to generate a typed, validated
provider_metablock for a given provider (the same way it already generates typed bindings for that provider's resources, data sources, and functions) has no schema to generate against —provider_metais invisible toterraform providers schema -json, even for providers that implement it. This makesprovider_metathe one schema-driven Terraform capability that can't be discovered the same way everything else can.Attempted Solutions
Ran
terraform providers schema -jsonagainst the AWS provider (6.53.0, which implementsprovider_meta "aws" { user_agent = [...] })and inspected the full output:provider,resource_schemas,data_source_schemas,ephemeral_resource_schemas,functions,list_resource_schemas,action_schemas,resource_identity_schemas. Noprovider_metakey is present.provider_meta. It appears exactly once, and only inside the human-readable description text of thefunctions.user_agent entry ("...for use with the user_agent argument in the provider or provider_meta block")- not as a structured schema entry.provider,resource_schemas,data_source_schemas,ephemeral_resource_schemas, and functions -provider_metaisn't documented as an output field either.GetProviderSchema.ResponsedefinesSchema provider_meta = 5;, a sibling field toSchema provider = 1;. So the provider genuinely returns a real schema for itsprovider_metablock over gRPC (that's howterraform init/validatetype-check theuser_agentargument's shape at parse time) — the JSON serialization interraform providers schema -jsonjust doesn't surface that field.Without this, tools are left to either hardcode per-provider assumptions about
provider_metablock contents, or fall back to an untyped escape hatch - unlike every other schema-driven capability the JSON output already supports.Proposal
Add a
provider_metakey to the per-provider object interraform providers schema -jsonoutput, as a sibling to the existingproviderkey, sourced directly from theGetProviderSchema.Response.provider_metafield the plugin protocol already returns. Suggested shape - the same block/attributes schema representation already used for provider:{ "format_version": "1.0", "provider_schemas": { "registry.terraform.io/hashicorp/aws": { "provider": { "version": 0, "block": { "...": "..." } }, "provider_meta": { "version": 0, "block": { "attributes": { "user_agent": { "type": ["list", "string"], "description_kind": "plain", "optional": true } } } }, "resource_schemas": { "...": "..." } } } }When a provider defines no provider_meta schema, this key would presumably be omitted for that provider, consistent with how other optional schema sections already behave.
References
provider_metasupport terraform-provider-aws#45464 - adds theprovider_meta "aws" { user_agent = [...] }argument and theprovider::aws::user_agent(...)function this schema would describe.provider_meta "aws" { user_agent = [...] }for attribution.