/
main.tf
50 lines (39 loc) · 1.01 KB
/
main.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
48
49
50
variable "infrastructure_region" {}
variable "aws_s3_bucket_name" {}
variable "aws_dynamodb_lock_table_name" {}
provider "aws" {
region = var.infrastructure_region
}
terraform {
backend "local" {}
}
resource "aws_s3_bucket" "terraform_state" {
bucket = var.aws_s3_bucket_name
lifecycle {
prevent_destroy = true
}
}
resource "aws_s3_bucket_versioning" "terraform_state" {
bucket = aws_s3_bucket.terraform_state.id
versioning_configuration {
status = "Enabled"
}
}
resource "aws_dynamodb_table" "terraform_state_lock" {
name = var.aws_dynamodb_lock_table_name
read_capacity = 1
write_capacity = 1
hash_key = "LockID"
attribute {
name = "LockID"
type = "S"
}
}
output "state_bucket" {
value = aws_s3_bucket.terraform_state.bucket
description = "use this as the bucket for your state configuration"
}
output "lock_table" {
value = aws_dynamodb_table.terraform_state_lock.name
description = "use this as the lockTable for your state configuration"
}