github.com/hugorut/terraform@v1.1.3/website/docs/language/settings/backends/local.mdx (about)

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