Ver código fonte

Initial commit.

Gogs 6 anos atrás
pai
commit
04cdc92eaa
4 arquivos alterados com 56 adições e 1 exclusões
  1. 29 0
      .gitignore
  2. 3 1
      README.md
  3. 8 0
      backend.tf
  4. 16 0
      s3_bucket.tf

+ 29 - 0
.gitignore

@@ -0,0 +1,29 @@
+# Local .terraform directories
+**/.terraform/*
+
+# .tfstate files
+*.tfstate
+*.tfstate.*
+
+# Crash log files
+crash.log
+
+# Ignore any .tfvars files that are generated automatically for each Terraform run. Most
+# .tfvars files are managed as part of configuration and so should be included in
+# version control.
+#
+# example.tfvars
+
+# Ignore override files as they are usually used to override resources locally and so
+# are not checked in
+override.tf
+override.tf.json
+*_override.tf
+*_override.tf.json
+
+# Include override files you do wish to add to version control using negated pattern
+#
+# !example_override.tf
+
+# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
+# example: *tfplan*

+ 3 - 1
README.md

@@ -1,3 +1,5 @@
 # RemoteState
 
-Store terraform state in S3.
+Store terraform state in S3.
+
+To use in your project, just copy 'backend.tf' to your project, update the key, and run `terraform init`.

+ 8 - 0
backend.tf

@@ -0,0 +1,8 @@
+terraform {
+  backend "s3" {
+    bucket = "monkeybox-terraform-state" 
+    key    = "global/s3/terraform.tfstate"
+    region = "us-east-2"
+    encrypt = true
+  }
+}

+ 16 - 0
s3_bucket.tf

@@ -0,0 +1,16 @@
+provider "aws" {
+  region = "us-east-2"
+}
+
+resource "aws_s3_bucket" "terraform_state" {
+  bucket = "monkeybox-terraform-state"
+
+  versioning {
+    enabled = true
+  }
+
+  lifecycle {
+    prevent_destroy = true
+  }
+}
+