-
Notifications
You must be signed in to change notification settings - Fork 35
/
main.tf
77 lines (59 loc) · 1.75 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#
# Terraform state bucket
#
locals {
state_bucket = "${var.account_alias}-${var.bucket_purpose}-${var.region}"
logging_bucket = "${var.account_alias}-${var.bucket_purpose}-${var.log_name}-${var.region}"
}
resource "aws_iam_account_alias" "alias" {
count = var.manage_account_alias ? 1 : 0
account_alias = var.account_alias
}
module "terraform_state_bucket" {
source = "trussworks/s3-private-bucket/aws"
version = "~> 7.1.0"
bucket = local.state_bucket
logging_bucket = local.logging_bucket
use_account_alias_prefix = false
bucket_key_enabled = var.bucket_key_enabled
kms_master_key_id = var.kms_master_key_id
enable_s3_public_access_block = var.enable_s3_public_access_block
tags = var.state_bucket_tags
depends_on = [
module.terraform_state_bucket_logs
]
}
#
# Terraform state bucket logging
#
module "terraform_state_bucket_logs" {
source = "trussworks/logs/aws"
version = "~> 16.2.0"
s3_bucket_name = local.logging_bucket
default_allow = false
s3_log_bucket_retention = var.log_retention
versioning_status = var.log_bucket_versioning
tags = var.log_bucket_tags
}
#
# Terraform state locking
#
# Ignore warnings about point-in-time recovery since this table holds no data
# The terraform state lock is meant to be ephemeral and does not need recovery
#tfsec:ignore:AWS086
resource "aws_dynamodb_table" "terraform_state_lock" {
name = var.dynamodb_table_name
hash_key = "LockID"
billing_mode = "PAY_PER_REQUEST"
server_side_encryption {
enabled = true
}
attribute {
name = "LockID"
type = "S"
}
point_in_time_recovery {
enabled = var.dynamodb_point_in_time_recovery
}
tags = var.dynamodb_table_tags
}