-
-
Notifications
You must be signed in to change notification settings - Fork 41
/
state_lock.tf_
33 lines (28 loc) · 1.3 KB
/
state_lock.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
///////////////////////////////////////////////////[ TERRAFORM STATE LOCK ]///////////////////////////////////////////////
# # ---------------------------------------------------------------------------------------------------------------------#
# Create S3 backend to keep terraform state lock
# # ---------------------------------------------------------------------------------------------------------------------#
terraform {
backend "s3" {
bucket = "state"
key = "${var.app["brand"]}/${data.aws_region.current.name}/terraform.tfstate"
region = data.aws_region.current.name
dynamodb_table = aws_dynamodb_table.lock.id
}
}
# # ---------------------------------------------------------------------------------------------------------------------#
# Create DynamoDB table to check terraform lock state
# # ---------------------------------------------------------------------------------------------------------------------#
resource "aws_dynamodb_table" "lock" {
name = "${var.app["brand"]}-terraform-state-lock"
read_capacity = 10
write_capacity = 10
hash_key = "LockID"
attribute {
name = "LockID"
type = "S"
}
tags = {
Name = "${var.app["brand"]} ${data.aws_region.current.name} terraform state lock"
}
}