github.com/iaas-resource-provision/iaas-rpc@v1.0.7-0.20211021023331-ed21f798c408/website/docs/language/settings/index.html.md (about)

     1  ---
     2  layout: "language"
     3  page_title: "Terraform Settings - Configuration Language"
     4  sidebar_current: "docs-config-terraform"
     5  description: "The terraform block allows you to configure Terraform behavior, including the Terraform version, backend, and required providers."
     6  ---
     7  
     8  # Terraform Settings
     9  
    10  The special `terraform` configuration block type is used to configure some
    11  behaviors of Terraform itself, such as requiring a minimum Terraform version to
    12  apply your configuration.
    13  
    14  ## Terraform Block Syntax
    15  
    16  Terraform settings are gathered together into `terraform` blocks:
    17  
    18  ```hcl
    19  terraform {
    20    # ...
    21  }
    22  ```
    23  
    24  Each `terraform` block can contain a number of settings related to Terraform's
    25  behavior. Within a `terraform` block, only constant values can be used;
    26  arguments may not refer to named objects such as resources, input variables,
    27  etc, and may not use any of the Terraform language built-in functions.
    28  
    29  The various options supported within a `terraform` block are described in the
    30  following sections.
    31  
    32  ## Configuring a Terraform Backend
    33  
    34  The nested `backend` block configures which backend Terraform should use.
    35  
    36  The syntax and behavior of the `backend` block is described in [Backend
    37  Configuration](/docs/language/settings/backends/configuration.html).
    38  
    39  ## Specifying a Required Terraform Version
    40  
    41  The `required_version` setting accepts a [version constraint
    42  string,](/docs/language/expressions/version-constraints.html) which specifies which versions of Terraform
    43  can be used with your configuration.
    44  
    45  If the running version of Terraform doesn't match the constraints specified,
    46  Terraform will produce an error and exit without taking any further actions.
    47  
    48  When you use [child modules](/docs/language/modules/index.html), each module can specify its own
    49  version requirements. The requirements of all modules in the tree must be
    50  satisfied.
    51  
    52  Use Terraform version constraints in a collaborative environment to
    53  ensure that everyone is using a specific Terraform version, or using at least
    54  a minimum Terraform version that has behavior expected by the configuration.
    55  
    56  The `required_version` setting applies only to the version of Terraform CLI.
    57  Terraform's resource types are implemented by provider plugins,
    58  whose release cycles are independent of Terraform CLI and of each other.
    59  Use [the `required_providers` block](/docs/language/providers/requirements.html) to manage
    60  the expected versions for each provider you use.
    61  
    62  ## Specifying Provider Requirements
    63  
    64  [inpage-source]: #specifying-provider-requirements
    65  
    66  The `required_providers` block specifies all of the providers required by the
    67  current module, mapping each local provider name to a source address and a
    68  version constraint.
    69  
    70  ```hcl
    71  terraform {
    72    required_providers {
    73      aws = {
    74        version = ">= 2.7.0"
    75        source = "hashicorp/aws"
    76      }
    77    }
    78  }
    79  ```
    80  
    81  For more information, see [Provider Requirements](/docs/language/providers/requirements.html).
    82  
    83  ## Experimental Language Features
    84  
    85  The Terraform team will sometimes introduce new language features initially via
    86  an opt-in experiment, so that the community can try the new feature and give
    87  feedback on it prior to it becoming a backward-compatibility constraint.
    88  
    89  In releases where experimental features are available, you can enable them on
    90  a per-module basis by setting the `experiments` argument inside a `terraform`
    91  block:
    92  
    93  ```hcl
    94  terraform {
    95    experiments = [example]
    96  }
    97  ```
    98  
    99  The above would opt in to an experiment named `example`, assuming such an
   100  experiment were available in the current Terraform version.
   101  
   102  Experiments are subject to arbitrary changes in later releases and, depending on
   103  the outcome of the experiment, may change drastically before final release or
   104  may not be released in stable form at all. Such breaking changes may appear
   105  even in minor and patch releases. We do not recommend using experimental
   106  features in Terraform modules intended for production use.
   107  
   108  In order to make that explicit and to avoid module callers inadvertently
   109  depending on an experimental feature, any module with experiments enabled will
   110  generate a warning on every `terraform plan` or `terraform apply`. If you
   111  want to try experimental features in a shared module, we recommend enabling the
   112  experiment only in alpha or beta releases of the module.
   113  
   114  The introduction and completion of experiments is reported in
   115  [Terraform's changelog](https://github.com/hashicorp/terraform/blob/main/CHANGELOG.md),
   116  so you can watch the release notes there to discover which experiment keywords,
   117  if any, are available in a particular Terraform release.
   118  
   119  ## Passing Metadata to Providers
   120  
   121  The `terraform` block can have a nested `provider_meta` block for each
   122  provider a module is using, if the provider defines a schema for it. This
   123  allows the provider to receive module-specific information, and is primarily
   124  intended for modules distributed by the same vendor as the associated provider.
   125  
   126  For more information, see [Provider Metadata](/docs/internals/provider-meta.html).