github.com/hugorut/terraform@v1.1.3/website/docs/language/state/remote.mdx (about)

     1  ---
     2  page_title: 'State: Remote Storage'
     3  description: >-
     4    Terraform can store the state remotely, making it easier to version and work
     5    with in a team.
     6  ---
     7  
     8  # Remote State
     9  
    10  By default, Terraform stores state locally in a file named `terraform.tfstate`.
    11  When working with Terraform in a team, use of a local file makes Terraform
    12  usage complicated because each user must make sure they always have the latest
    13  state data before running Terraform and make sure that nobody else runs
    14  Terraform at the same time.
    15  
    16  With _remote_ state, Terraform writes the state data to a remote data store,
    17  which can then be shared between all members of a team. Terraform supports
    18  storing state in [Terraform Cloud](https://www.hashicorp.com/products/terraform/),
    19  [HashiCorp Consul](https://www.consul.io/), Amazon S3, Azure Blob Storage, Google Cloud Storage, Alibaba Cloud OSS, and more.
    20  
    21  Remote state is implemented by a [backend](/language/settings/backends) or by
    22  Terraform Cloud, both of which you can configure in your configuration's root module.
    23  
    24  ## Delegation and Teamwork
    25  
    26  Remote state allows you to share
    27  [output values](/language/values/outputs) with other configurations.
    28  This allows your infrastructure to be decomposed into smaller components.
    29  
    30  Put another way, remote state also allows teams to share infrastructure
    31  resources in a read-only way without relying on any additional configuration
    32  store.
    33  
    34  For example, a core infrastructure team can handle building the core
    35  machines, networking, etc. and can expose some information to other
    36  teams to run their own infrastructure. As a more specific example with AWS:
    37  you can expose things such as VPC IDs, subnets, NAT instance IDs, etc. through
    38  remote state and have other Terraform states consume that.
    39  
    40  For example usage, see
    41  [the `terraform_remote_state` data source](/language/state/remote-state-data).
    42  
    43  While remote state can be a convenient, built-in mechanism for sharing data
    44  between configurations, you may prefer to use more general stores to
    45  pass settings both to other configurations and to other consumers. For example,
    46  if your environment has [HashiCorp Consul](https://www.consul.io/) then you
    47  can have one Terraform configuration that writes to Consul using
    48  [`consul_key_prefix`](https://registry.terraform.io/providers/hashicorp/consul/latest/docs/resources/key_prefix) and then
    49  another that consumes those values using
    50  [the `consul_keys` data source](https://registry.terraform.io/providers/hashicorp/consul/latest/docs/data-sources/keys).
    51  
    52  ## Locking and Teamwork
    53  
    54  For fully-featured remote backends, Terraform can also use
    55  [state locking](/language/state/locking) to prevent concurrent runs of
    56  Terraform against the same state.
    57  
    58  [Terraform Cloud by HashiCorp](https://www.hashicorp.com/products/terraform/)
    59  is a commercial offering that supports an even stronger locking concept that
    60  can also detect attempts to create a new plan when an existing plan is already
    61  awaiting approval, by queuing Terraform operations in a central location.
    62  This allows teams to more easily coordinate and communicate about changes to
    63  infrastructure.