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

     1  ---
     2  layout: "language"
     3  page_title: "Backend Type: local"
     4  sidebar_current: "docs-backends-types-enhanced-local"
     5  description: |-
     6    Terraform can store the state remotely, making it easier to version and work with in a team.
     7  ---
     8  
     9  # local
    10  
    11  **Kind: Enhanced**
    12  
    13  The local backend stores state on the local filesystem, locks that
    14  state using system APIs, and performs operations locally.
    15  
    16  ## Example Configuration
    17  
    18  ```hcl
    19  terraform {
    20    backend "local" {
    21      path = "relative/path/to/terraform.tfstate"
    22    }
    23  }
    24  ```
    25  
    26  ## Data Source Configuration
    27  
    28  ```hcl
    29  data "terraform_remote_state" "foo" {
    30    backend = "local"
    31  
    32    config = {
    33      path = "${path.module}/../../terraform.tfstate"
    34    }
    35  }
    36  ```
    37  
    38  ## Configuration variables
    39  
    40  The following configuration options are supported:
    41  
    42   * `path` - (Optional) The path to the `tfstate` file. This defaults to
    43     "terraform.tfstate" relative to the root module by default.
    44   * `workspace_dir` - (Optional) The path to non-default workspaces.
    45  
    46  ## Command Line Arguments
    47  
    48  ~> This section describes legacy features that we've preserved for backward
    49  compatibility but that we no longer recommend. See below for more details.
    50  
    51  For configurations that include a `backend "local"` block or that default to
    52  the local backend by not specifying a backend at all, most commands that either
    53  read or write state snapshots from the backend accept the following
    54  additional arguments:
    55  
    56  * `-state=FILENAME` - overrides the state filename when _reading_ the prior
    57    state snapshot.
    58  * `-state-out=FILENAME` - overrides the state filename when _writing_ new state
    59    snapshots.
    60  
    61      If you use `-state` without also using `-state-out` then Terraform will
    62      use the `-state` filename for both `-state` and `-state-out`, which means
    63      Terraform will overwrite the input file if it creates a new state snapshot.
    64  * `-backup=FILENAME` - overrides the default filename that the local backend
    65    would normally choose dynamically to create backup files when it writes new
    66    state.
    67  
    68      If you use `-state` without also using `-backup` then Terraform will use
    69      the `-state` filename as a filename prefix for generating a backup filename.
    70      You can use `-backup=-` (that is, set the filename to just the ASCII
    71      dash character) to disable the creation of backup files altogether.
    72  
    73  These three options are preserved for backward-compatibility with earlier
    74  workflows that predated the introduction of built-in remote state, where
    75  users would write wrapper scripts that fetch prior state before running
    76  Terraform and then save the new state after Terraform exits, in which case
    77  the three arguments would typically all be paths within a temporary
    78  directory used just for one operation.
    79  
    80  Because these old workflows predate the introduction of the possibility of
    81  [multiple workspaces](/docs/language/state/workspaces.html), setting them
    82  overrides Terraform's usual behavior of selecting a different state filename
    83  based on the selected workspace. If you use all three of these options then
    84  the selected workspace has no effect on which filenames Terraform will select
    85  for state files, and so you'll need to select different filenames yourself if
    86  you wish to keep workspace state files distinct from one another.
    87  
    88  These three options have no effect for configurations that have a different
    89  backend type selected.
    90  
    91  We do not recommend using these options in new systems, even if you are running
    92  Terraform in automation. Instead,
    93  [select a different backend which supports remote state](./) and configure it
    94  within your root module, which ensures that everyone working on your
    95  configuration will automatically retrieve and store state in the correct shared
    96  location without any special command line options.