How to Store Terraform State in AWS S3


Storing Terraform states files locally is not recommended. Instead you should use a backend such as as S3 from AWS.

To do this, you just need to add the following backend information in a terraform block in your code:

terraform {
  backend "s3" {
    bucket = "mybucket"
    key    = "path/to/my/key"
    region = "eu-west-1"
  }
}