github.com/muratcelep/terraform@v1.1.0-beta2-not-internal-4/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  > **Hands-on:** Try the [Manage Terraform Versions](https://learn.hashicorp.com/tutorials/terraform/versions?in=terraform/configuration-language)  or [Manage Terraform Versions in Terraform Cloud](https://learn.hashicorp.com/tutorials/terraform/cloud-versions?in=terraform/cloud) tutorials on HashiCorp Learn.
    42  
    43  The `required_version` setting accepts a [version constraint
    44  string,](/docs/language/expressions/version-constraints.html) which specifies which versions of Terraform
    45  can be used with your configuration.
    46  
    47  If the running version of Terraform doesn't match the constraints specified,
    48  Terraform will produce an error and exit without taking any further actions.
    49  
    50  When you use [child modules](/docs/language/modules/index.html), each module can specify its own
    51  version requirements. The requirements of all modules in the tree must be
    52  satisfied.
    53  
    54  Use Terraform version constraints in a collaborative environment to
    55  ensure that everyone is using a specific Terraform version, or using at least
    56  a minimum Terraform version that has behavior expected by the configuration.
    57  
    58  The `required_version` setting applies only to the version of Terraform CLI.
    59  Terraform's resource types are implemented by provider plugins,
    60  whose release cycles are independent of Terraform CLI and of each other.
    61  Use [the `required_providers` block](/docs/language/providers/requirements.html) to manage
    62  the expected versions for each provider you use.
    63  
    64  ## Specifying Provider Requirements
    65  
    66  [inpage-source]: #specifying-provider-requirements
    67  
    68  The `required_providers` block specifies all of the providers required by the
    69  current module, mapping each local provider name to a source address and a
    70  version constraint.
    71  
    72  ```hcl
    73  terraform {
    74    required_providers {
    75      aws = {
    76        version = ">= 2.7.0"
    77        source = "hashicorp/aws"
    78      }
    79    }
    80  }
    81  ```
    82  
    83  For more information, see [Provider Requirements](/docs/language/providers/requirements.html).
    84  
    85  ## Experimental Language Features
    86  
    87  The Terraform team will sometimes introduce new language features initially via
    88  an opt-in experiment, so that the community can try the new feature and give
    89  feedback on it prior to it becoming a backward-compatibility constraint.
    90  
    91  In releases where experimental features are available, you can enable them on
    92  a per-module basis by setting the `experiments` argument inside a `terraform`
    93  block:
    94  
    95  ```hcl
    96  terraform {
    97    experiments = [example]
    98  }
    99  ```
   100  
   101  The above would opt in to an experiment named `example`, assuming such an
   102  experiment were available in the current Terraform version.
   103  
   104  Experiments are subject to arbitrary changes in later releases and, depending on
   105  the outcome of the experiment, may change drastically before final release or
   106  may not be released in stable form at all. Such breaking changes may appear
   107  even in minor and patch releases. We do not recommend using experimental
   108  features in Terraform modules intended for production use.
   109  
   110  In order to make that explicit and to avoid module callers inadvertently
   111  depending on an experimental feature, any module with experiments enabled will
   112  generate a warning on every `terraform plan` or `terraform apply`. If you
   113  want to try experimental features in a shared module, we recommend enabling the
   114  experiment only in alpha or beta releases of the module.
   115  
   116  The introduction and completion of experiments is reported in
   117  [Terraform's changelog](https://github.com/muratcelep/terraform/blob/main/CHANGELOG.md),
   118  so you can watch the release notes there to discover which experiment keywords,
   119  if any, are available in a particular Terraform release.
   120  
   121  ## Passing Metadata to Providers
   122  
   123  The `terraform` block can have a nested `provider_meta` block for each
   124  provider a module is using, if the provider defines a schema for it. This
   125  allows the provider to receive module-specific information, and is primarily
   126  intended for modules distributed by the same vendor as the associated provider.
   127  
   128  For more information, see [Provider Metadata](/docs/internals/provider-meta.html).