---
description: >-
  The `tofu providers schema` command prints detailed schemas for the
  providers used

  in the current configuration.
---

# Command: providers schema

The `tofu providers schema` command is used to print detailed schemas for the providers used in the current configuration.

## Usage

Usage: `tofu providers schema [options]`

:::note
Use of variables in [module sources](../../../language/modules/sources.mdx#support-for-variable-and-local-evaluation),
[backend configuration](../../../language/settings/backends/configuration.mdx#variables-and-locals),
or [encryption block](../../../language/state/encryption.mdx#configuration)
requires [assigning values to root module variables](../../../language/values/variables.mdx#assigning-values-to-root-module-variables)
when running `tofu providers schema`.
:::

The following flags are available:

- `-json` - Displays the schemas in a machine-readable, JSON format.
  This command follows the [raw json specification](../../../internals/machine-readable-ui.mdx#raw-json-output).

- `-var 'NAME=VALUE'` - Sets a value for a single
  [input variable](../../../language/values/variables.mdx) declared in the
  root module of the configuration. Use this option multiple times to set
  more than one variable. Refer to
  [Input Variables on the Command Line](../plan.mdx#input-variables-on-the-command-line) for more information.

- `-var-file=FILENAME` - Sets values for potentially many
  [input variables](../../../language/values/variables.mdx) declared in the
  root module of the configuration, using definitions from a
  ["tfvars" file](../../../language/values/variables.mdx#variable-definitions-tfvars-files).
  Use this option multiple times to include values from more than one file.

There are several other ways to set values for input variables in the root
module, aside from the `-var` and `-var-file` options. Refer to
[Assigning Values to Root Module Variables](../../../language/values/variables.mdx#assigning-values-to-root-module-variables) for more information.

Please note that, at this time, the `-json` flag is a _required_ option. In future releases, this command will be extended to allow for additional options.

The output includes a `format_version` key, which has
value `"1.0"`. The semantics of this version are:

- We will increment the minor version, e.g. `"1.1"`, for backward-compatible
  changes or additions. Ignore any object properties with unrecognized names to
  remain forward-compatible with future minor versions.
- We will increment the major version, e.g. `"2.0"`, for changes that are not
  backward-compatible. Reject any input which reports an unsupported major
  version.

We will introduce new major versions only within the bounds of
[the OpenTofu 1.0 Compatibility Promises](../../../language/v1-compatibility-promises.mdx).

## Format Summary

The following sections describe the JSON output format by example, using a pseudo-JSON notation.
Important elements are described with comments, which are prefixed with //.
To avoid excessive repetition, we've split the complete format into several discrete sub-objects, described under separate headers. References wrapped in angle brackets (like `<block-representation>`) are placeholders which, in the real output, would be replaced by an instance of the specified sub-object.

The JSON output format consists of the following objects and sub-objects:

- [Providers Schema Representation](#providers-schema-representation) - the top-level object returned by `tofu providers schema -json`
- [Schema Representation](#schema-representation) - a sub-object of providers, resources, and data sources that describes their schema
- [Block Representation](#block-representation) - a sub-object of schemas that describes attributes and nested blocks
- [Resource Identity Schema Representation](#resource-identity-schema-representation) - a sub-object describing a resource type's identity schema

## Providers Schema Representation

```javascript
{
  "format_version": "1.0",

  // "provider_schemas" describes the provider schemas for all
  // providers throughout the configuration tree.
  "provider_schemas": {
    // keys in this map are the provider type, such as "random"
    "example_provider_name": {
      // "provider" is the schema for the provider configuration
      "provider": <schema-representation>,

      // "resource_schemas" map the resource type name to the resource's schema
      "resource_schemas": {
        "example_resource_name": <schema-representation>
      },

      // "data_source_schemas" map the data source type name to the
      // data source's schema
      "data_source_schemas": {
        "example_datasource_name": <schema-representation>,
      },

      // "resource_identity_schemas" map the resource type name to the
      // resource's identity schema, if it supports identity-based import.
      // Only resource types that define an identity schema are included.
      "resource_identity_schemas": {
        "example_resource_name": <resource-identity-schema-representation>
      }
    },
    "example_provider_two": { … }
  }
}
```

## Schema Representation

A schema representation pairs a provider or resource schema (in a "block") with that schema's version.

```javascript
{
  // "version" is the schema version, not the provider version
  "version": int64,
  "block": <block-representation>
}
```

## Block Representation

A block representation contains "attributes" and "block_types" (which represent nested blocks).

```javascript
{
  // "attributes" describes any attributes that appear directly inside the
  // block. Keys in this map are the attribute names.
  "attributes":  {
    "example_attribute_name": {
      // "type" is a representation of a type specification
      // that the attribute's value must conform to.
      "type": "string",

      // Some attributes use "nested_type" instead of "type",
      // describing an object type or a collection of an object type
      // in a similar way as for nested block types. This should take
      // priority over "type" if both are present, but for most
      // providers only one of the two attributes is returned.
      "nested_type": {
        // "nesting_mode" describes the nesting mode for the
        // attribute value, with the same values as for
        // the corresponding property in "block_types" below.
        "nesting_mode": "list",

        // "attributes" describes the attributes that are
        // expected for each nested object, using the same
        // structure as the top-level "attributes" property.
        "attributes": {
          // ...
        }
      },

      // "description" is an English-language description of
      // the purpose and usage of the attribute.
      "description": "string",

      // "required", if set to true, specifies that an
      // omitted or null value is not permitted.
      "required": bool,

      // "optional", if set to true, specifies that an
      // omitted or null value is permitted.
      "optional": bool,

      // "computed", if set to true, indicates that the
      // value comes from the provider rather than the
      // configuration.
      "computed": bool,

      // "sensitive", if set to true, indicates that the
      // attribute may contain sensitive information.
      "sensitive": bool

      // "deprecated", if set to true, indicates that the
      // attribute is deprecated
      "deprecated": bool

      // "deprecation_message" is the description provided
      // detailing why an attribute has been deprecated.
      "deprecation_message": "string"
    },
  },
  // "block_types" describes any nested blocks that appear directly
  // inside the block.
  // Keys in this map are the names of the block_type.
  "block_types": {
    "example_block_name": {
      // "nesting_mode" describes the nesting mode for the
      // child block, and can be one of the following:
      // 	single
      // 	list
      // 	set
      // 	map
    "nesting_mode": "list",
    "block": <block-representation>,

    // "min_items" and "max_items" set lower and upper
    // limits on the number of child blocks allowed for
    // the list and set modes. These are
    // omitted for other modes.
    "min_items": 1,
    "max_items": 3
  }

  // "deprecated", if set to true, indicates that the
  // attribute is deprecated
  "deprecated": bool

  // "deprecation_message" is the description provided
  // detailing why an attribute has been deprecated.
  "deprecation_message": "string"
}
```

## Resource Identity Schema Representation

A resource identity schema representation describes the attributes that uniquely identify a resource instance, used for identity-based import. Only resource types that support identity-based import have an entry in `resource_identity_schemas`.

```javascript
{
  // "version" is the version of the identity schema. OpenTofu uses this to
  // detect when stored identity data needs to be upgraded via the provider.
  "version": uint64,

  // "attributes" describes the attributes that together form the identity of
  // a resource instance. Keys in this map are the attribute names.
  "attributes": {
    "example_attribute_name": {
      // "type" is a representation of a type specification
      // that the attribute's value must conform to.
      "type": "string",

      // "description" is an English-language description of
      // the purpose and usage of the attribute.
      "description": "string",

      // "required_for_import", if set to true, specifies that this
      // attribute must be provided when performing an identity-based import.
      "required_for_import": bool,

      // "optional_for_import", if set to true, specifies that this
      // attribute may optionally be provided when performing an identity-based import.
      "optional_for_import": bool
    },
  },
}
```
