Updates during testing of TF 1.0.1

This commit is contained in:
sid palas
2021-06-27 13:41:03 -07:00
parent 4afa2070b3
commit f21f709b51
8 changed files with 29 additions and 64 deletions

View File

@@ -1,11 +1,7 @@
Steps to initialize backend in AWS and manage it with Terraform:
1) Use config from `bootstrap` (init, plan, apply) to provision s3 bucket and dynamoDB table with local state
2) copy state file into import-bootstrap
1) cp terraform.tfstate ../import-bootstrap
3) Initialize within `import-bootstrap` using `terraform init`
4) Uncomment out s3 backend provider:
2) Uncomment the remote backend configuration
```
backend "s3" {
bucket = "devops-directive-tf-state"
@@ -16,7 +12,7 @@ Steps to initialize backend in AWS and manage it with Terraform:
}
```
4) Reinitialize with `terraform init`:
1) Reinitialize with `terraform init`:
```
Do you want to copy existing state to the new backend?

View File

@@ -1,47 +0,0 @@
terraform {
### UNCOMMENT THIS AFTER INITIALIZNG ###
# backend "s3" {
# bucket = "devops-directive-tf-state"
# key = "03-basics/import-bootstrap/terraform.tfstate"
# region = "us-east-1"
# dynamodb_table = "terraform-state-locking"
# encrypt = true
# }
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
}
}
}
provider "aws" {
region = "us-east-1"
}
resource "aws_s3_bucket" "terraform_state" {
bucket = "devops-directive-tf-state"
force_destroy = true
versioning {
enabled = true
}
server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}
}
resource "aws_dynamodb_table" "terraform_locks" {
name = "terraform-state-locking"
billing_mode = "PAY_PER_REQUEST"
hash_key = "LockID"
attribute {
name = "LockID"
type = "S"
}
}

View File

@@ -1,7 +1,11 @@
terraform {
# THIS BACKEND CONFIG GETS UNCOMMENTED IN IMPORT-BOOTSTRAP
#############################################################
## AFTER RUNNING TERRAFORM APPLY (WITH LOCAL BACKEND)
## YOU WILL UNCOMMENT THIS CODE THEN RERUN TERRAFORM INIT
## TO SWITCH FROM LOCAL BACKEND TO REMOTE AWS BACKEND
#############################################################
# backend "s3" {
# bucket = "devops-directive-tf-state"
# bucket = "devops-directive-tf-state" # REPLACE WITH YOUR BUCKET NAME
# key = "03-basics/import-bootstrap/terraform.tfstate"
# region = "us-east-1"
# dynamodb_table = "terraform-state-locking"
@@ -21,7 +25,7 @@ provider "aws" {
}
resource "aws_s3_bucket" "terraform_state" {
bucket = "devops-directive-tf-state"
bucket = "devops-directive-tf-state" # REPLACE WITH YOUR BUCKET NAME
force_destroy = true
versioning {
enabled = true