---
type: archive
area: archive
status: archived
date: 2026-05-03
created: 2026-05-03
updated: 1980-01-01
tags:
  - archive
---
Benefits of state
![[img-20240920-004844-2080bd2d.png]]
Default state is only stored locally

When working as a team it's important to only one person apply a configuration and not 2 persons applying simultaneously.

It's unsure by a feature called state locking when state is locked when 2 persons tries to update the state in the same time so that one of them will get an error.

A solution is to store state file in a remote backend and terraform will load the file in memory any time is needed 
#### Configuring a S3 bucket and DynamoDB as remote backend to state storing!

![[img-20240920-010551-6a52eb72.png]]

	S3 is used to store state file
	+
	Dynamo DB for state locking

This combination is used as remote state backend

Creating a demo state file locally with the wanted or some demo resources3
![[img-20240920-011944-4a399071.png]]

Defining Backend block with target **S3** bucket and **DynamoDB**
![[img-20240920-012000-3c4b12e7.png]]
Run terraform init and local state file will be passed to remote backend
![[img-20240920-012032-5a57ed95.png]]
delete local state file
#### Terraform state command
Template
```
terraform state <subcommand> [options] [args]
```
- terraform state show
- terraform state mv [args] source destination
#### how we view remote state
![[img-20240920-021031-0e1d9975.png]]
terraform state rm ADDRESS only removed from state not from real world infrastruture
