-
Notifications
You must be signed in to change notification settings - Fork 1
/
backend.tf
47 lines (37 loc) · 978 Bytes
/
backend.tf
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
provider "aws" {}
variable "site" {
type = "string"
description = "A unique site name for allocation of resources"
}
# create an S3 bucket to store the state file in
resource "aws_s3_bucket" "terraform-state-storage-s3" {
bucket = "${var.site}-terraform-remote-state-storage-s3"
versioning {
enabled = true
}
lifecycle {
prevent_destroy = true
}
tags {
Name = "S3 Remote Terraform State Store"
}
}
# create a dynamodb table for locking the state file
resource "aws_dynamodb_table" "dynamodb-terraform-state-lock" {
name = "${var.site}-terraform-state-lock-dynamo"
hash_key = "LockID"
read_capacity = 20
write_capacity = 20
attribute {
name = "LockID"
type = "S"
}
tags {
Name = "DynamoDB Terraform State Lock Table"
}
depends_on = ["aws_s3_bucket.terraform-state-storage-s3"]
}
# create a KMS key for state encryption
resource "aws_kms_key" "terraform-kms" {
description = "terraform KMS key"
}