mirror of
https://github.com/sidpalas/devops-directive-terraform-course.git
synced 2025-12-14 06:41:14 +00:00
Updates during testing of TF 1.0.1
This commit is contained in:
51
03-basics/aws-backend/main.tf
Normal file
51
03-basics/aws-backend/main.tf
Normal file
@@ -0,0 +1,51 @@
|
||||
terraform {
|
||||
#############################################################
|
||||
## 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" # REPLACE WITH YOUR BUCKET NAME
|
||||
# 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" # REPLACE WITH YOUR BUCKET NAME
|
||||
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"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user