Browse Source

Added backend.tf for remote config.

Fred Damstra (Macbook 2015) 2 years ago
parent
commit
2bc0b45a92
2 changed files with 23 additions and 3 deletions
  1. 14 3
      README.md
  2. 9 0
      backend.tf

+ 14 - 3
README.md

@@ -19,11 +19,22 @@ If this is your first time using this module, remove the `backend.tf` file, then
 terraform apply
 ```
 
-Save the output as `backend.tf` (replacing the key with a unique string), and run `terraform apply` again to migrate the state of this module back to S3.
+1. Save the output config as `backend.tf`
+1. Edit `backend.tf` and copy the `bucket` name to the `key` name.
+1. Run `terraform init`. Answer YES to whether to copy the backend.tf
+1. If it was successful, run `rm terraform.tfstate*`
+1. Run a final `terraform apply`
 
-You can use the output again in other projects.
 
-If you wish to recreate, do _not_ update the config. You must `terraform destroy`, remove `backend.tf`, make changes, then `terraform apply`
+### Later usage
+
+Run `terraform output` to get the config, and copy it as a `backend.tf` in your other projects. Be careful not to reuse the key.
+
+
+### Making Changes
+
+Once you've migrated the backend to s3, you probably do not want to make changes. Do so at your own risk.
+
 
 <!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
 ## Requirements

+ 9 - 0
backend.tf

@@ -0,0 +1,9 @@
+terraform {
+  backend "s3" {
+    bucket  = "terraform-remote-state-20221017144428493300000001"
+    key     = "terraform-remote-state-20221017144428493300000001"
+    region  = "us-east-2"
+    encrypt = true
+    profile = "default"
+  }
+}