github.com/muratcelep/terraform@v1.1.0-beta2-not-internal-4/website/docs/language/state/remote.html.md (about)

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