Remote State
Terraform allows us to keep the state of what's being deployed preserved. By default this is done locally. However, it is possible to keep the state saved in a remote backend as well. Currently there are two supported backends for this purpose,
AWS S3
Consuel
When working with multiple infrastructure instances with a team of developers, it is possible to get the states conflicted and also there could be sensitive information present in the state. Considering all that is it good to go with one of remote backends for keeping the state.
Frist step of configuring backend for keeping remote state is to provision an S3 bucket and then locally configure AWS CLI with configure command.
Once above it done, create a file with the name backend.tf
with below content,
In here I configure the backend to be an S3 setup. I have to specify a bucket name and a path along with the region it is located in.
Initialize the backend with below command,
Now the backend is ready to keep the state remotly stored. To further experiement I used the same content of 03-Output-Attributes.
Once we apply the changes, it should be possible to see our terraform state available in the S3 bucket.
Last updated