github.com/rstandt/terraform@v0.12.32-0.20230710220336-b1063613405c/website/docs/commands/providers/schema.html.md (about)

     1  ---
     2  layout: "commands-providers"
     3  page_title: "Command: providers schema"
     4  sidebar_current: "docs-commands-providers-schema"
     5  description: |-
     6    The `terraform providers schema` command prints detailed schemas for the providers used
     7    in the current configuration.
     8  ---
     9  
    10  # Command: terraform providers schema
    11  
    12  The `terraform providers schema` command is used to print detailed schemas for the providers used in the current configuration.
    13  
    14  -> `terraform providers schema` requires **Terraform v0.12 or later**.
    15  
    16  ## Usage
    17  
    18  Usage: `terraform providers schema [options]`
    19  
    20  The list of available flags are:
    21  
    22  * `-json` - Displays the schemas in a machine-readable, JSON format.
    23  
    24  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.
    25  
    26  -> **Note:** The output includes a `format_version` key, which currently has major version zero to indicate that the format is experimental and subject to change. A future version will assign a non-zero major version and make stronger promises about compatibility. We do not anticipate any significant breaking changes to the format before its first major version, however.
    27  
    28  ## Format Summary
    29  
    30  The following sections describe the JSON output format by example, using a pseudo-JSON notation.
    31  Important elements are described with comments, which are prefixed with //.
    32  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.
    33  
    34  The JSON output format consists of the following objects and sub-objects:
    35  
    36  - [Providers Schema Representation](#providers-schema-representation) - the top-level object returned by `terraform providers schema -json`
    37  - [Schema Representation](#schema-representation) - a sub-object of providers, resources, and data sources that describes their schema
    38  - [Block Representation](#block-representation) - a sub-object of schemas that describes attributes and nested blocks
    39  
    40  ## Providers Schema Representation
    41  
    42  ```javascript
    43  {
    44    "format_version": "0.1",
    45  
    46    // "provider_schemas" describes the provider schemas for all
    47    // providers throughout the configuration tree.
    48    "provider_schemas": {
    49      // keys in this map are the provider type, such as "random"
    50      "example_provider_name": {
    51        // "provider" is the schema for the provider configuration
    52        "provider": <schema-representation>,
    53  
    54        // "resource_schemas" map the resource type name to the resource's schema
    55        "resource_schemas": {
    56          "example_resource_name": <schema-representation>
    57        },
    58  
    59        // "data_source_schemas" map the data source type name to the
    60        // data source's schema
    61        "data_source_schemas": {
    62          "example_datasource_name": <schema-representation>,
    63        }
    64      },
    65      "example_provider_two": { … }
    66    }
    67  }
    68  ```
    69  
    70  ## Schema Representation
    71  
    72  A schema representation pairs a provider or resource schema (in a "block") with that schema's version.
    73  
    74  ```javascript
    75  {
    76    // "version" is the schema version, not the provider version
    77    "version": int64,
    78    "block": <block-representation>
    79  }
    80  ```
    81  
    82  ## Block Representation
    83  
    84  A block representation contains "attributes" and "block_types" (which represent nested blocks).
    85  
    86  ```javascript
    87  {
    88    // "attributes" describes any attributes that appear directly inside the
    89    // block. Keys in this map are the attribute names.
    90    "attributes":  {
    91      "example_attribute_name": {
    92        // "type" is a representation of a type specification
    93        // that the attribute's value must conform to.
    94        "type": "string",
    95  
    96        // "description" is an English-language description of
    97        // the purpose and usage of the attribute.
    98        "description": "string",
    99  
   100        // "required", if set to true, specifies that an
   101        // omitted or null value is not permitted.
   102        "required": bool,
   103  
   104        // "optional", if set to true, specifies that an
   105        // omitted or null value is permitted.
   106        "optional": bool,
   107  
   108        // "computed", if set to true, indicates that the
   109        // value comes from the provider rather than the
   110        // configuration.
   111        "computed": bool,
   112  
   113        // "sensitive", if set to true, indicates that the
   114        // attribute may contain sensitive information.
   115        "sensitive": bool
   116      },
   117    },
   118    // "block_types" describes any nested blocks that appear directly
   119    // inside the block.
   120    // Keys in this map are the names of the block_type.
   121    "block_types": {
   122      "example_block_name": {
   123        // "nesting_mode" describes the nesting mode for the
   124        // child block, and can be one of the following:
   125        // 	single
   126        // 	list
   127        // 	set
   128        // 	map
   129      "nesting_mode": "list",
   130      "block": <block-representation>,
   131  
   132      // "min_items" and "max_items" set lower and upper
   133      // limits on the number of child blocks allowed for
   134      // the list and set modes. These are
   135      // omitted for other modes.
   136      "min_items": 1,
   137      "max_items": 3
   138    }
   139  }
   140  ```