-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbackend.tf
More file actions
49 lines (42 loc) · 1.01 KB
/
backend.tf
File metadata and controls
49 lines (42 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Configure the AWS Provider
provider "aws" {
region = var.region
}
# Use S3 as Backend
terraform {
backend "s3" {
bucket = "lair-terraform"
key = "lair.tfstate"
region = "us-east-1"
dynamodb_table = "lair-terraform-state-lock"
}
}
# S3 Bucket for Storing TF State
resource "aws_s3_bucket" "tf_bucket" {
bucket = "${var.name}-terraform"
acl = "private"
versioning {
enabled = true
}
}
resource "aws_s3_bucket_public_access_block" "tf_bucket" {
bucket = aws_s3_bucket.tf_bucket.id
block_public_acls = true
block_public_policy = true
ignore_public_acls = true
restrict_public_buckets = true
}
# DynamoDB for State Locking
resource "aws_dynamodb_table" "dynamodb_tf_state_lock" {
name = "${var.name}-terraform-state-lock"
hash_key = "LockID"
read_capacity = 1
write_capacity = 1
attribute {
name = "LockID"
type = "S"
}
tags = {
Name = "DynamoDB Terraform State Lock Table"
}
}