Skip to content

Latest commit

 

History

History
136 lines (102 loc) · 3.8 KB

File metadata and controls

136 lines (102 loc) · 3.8 KB

tfpluginschema

CLI tool for querying Terraform/OpenTofu provider schemas directly from the registry. Retrieves schemas for resources, data sources, ephemeral resources, functions, and provider configuration without needing a local Terraform init.

Source: https://github.com/matt-FFFFFF/tfpluginschema

Installation

Download the latest release and extract the binary:

# Linux (amd64)
curl -sSfL https://github.com/matt-FFFFFF/tfpluginschema/releases/latest/download/tfpluginschema_0.8.0_linux_amd64.tar.gz | tar -xz -C /usr/local/bin tfpluginschema

# macOS (Apple Silicon)
curl -sSfL https://github.com/matt-FFFFFF/tfpluginschema/releases/latest/download/tfpluginschema_0.8.0_darwin_arm64.tar.gz | tar -xz -C /usr/local/bin tfpluginschema

# macOS (Intel)
curl -sSfL https://github.com/matt-FFFFFF/tfpluginschema/releases/latest/download/tfpluginschema_0.8.0_darwin_amd64.tar.gz | tar -xz -C /usr/local/bin tfpluginschema
# Windows (amd64)
$url = "https://github.com/matt-FFFFFF/tfpluginschema/releases/latest/download/tfpluginschema_0.8.0_windows_amd64.zip"
$dest = Join-Path $HOME ".tfpluginschema"
New-Item -ItemType Directory -Path $dest -Force | Out-Null
Invoke-WebRequest -Uri $url -OutFile (Join-Path $dest "tfpluginschema.zip")
Expand-Archive -Path (Join-Path $dest "tfpluginschema.zip") -DestinationPath $dest -Force
Remove-Item (Join-Path $dest "tfpluginschema.zip")
# Add to PATH if not already present
if ($env:PATH -notlike "*$dest*") { $env:PATH += ";$dest" }

Check latest version at: https://github.com/matt-FFFFFF/tfpluginschema/releases

Global Options

Flag Short Description
--namespace -n Provider namespace (e.g., Azure, hashicorp)
--name -p Provider name (e.g., azapi, azurerm, aws)
--provider-version --pv Version or constraint (e.g., 2.5.0, ~>2.4). Empty for latest
--registry -r Registry: opentofu (default) or terraform

Commands

List available provider versions

tfpluginschema -n Azure -p azapi version list

List resources, data sources, functions, or ephemeral resources

tfpluginschema -n Azure -p azapi resource list
tfpluginschema -n Azure -p azapi datasource list
tfpluginschema -n Azure -p azapi function list
tfpluginschema -n Azure -p azapi ephemeral list

Get a resource schema

tfpluginschema -n Azure -p azapi resource schema azapi_resource

Get a data source schema

tfpluginschema -n Azure -p azapi datasource schema azapi_client_config

Get a function schema

tfpluginschema -n Azure -p azapi function schema build_resource_id

Get an ephemeral resource schema

tfpluginschema -n Azure -p azapi ephemeral schema azapi_resource_action

Get the provider configuration schema

tfpluginschema -n Azure -p azapi provider schema

Pin to a specific provider version

tfpluginschema -n Azure -p azapi --pv 2.5.0 resource schema azapi_resource

Use a version constraint

tfpluginschema -n hashicorp -p azurerm --pv "~>4.0" resource list

Output Format

Output is JSON matching the Terraform plugin schema format. Key fields for resource/data source schemas:

{
  "version": 2,
  "block": {
    "attributes": {
      "<name>": {
        "type": "<type>",
        "description": "<description>",
        "required": true,
        "optional": true,
        "computed": true
      }
    },
    "block_types": {
      "<name>": {
        "nesting_mode": "list|set|single|map",
        "block": { ... },
        "min_items": 0,
        "max_items": 1
      }
    }
  }
}
  • required: Must be set by the user
  • optional: May be set by the user
  • computed: Set by the provider (read-only if not also optional)
  • optional + computed: Can be set by user, has a provider default