forked from nozaq/terraform-aws-secure-baseline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
74 lines (50 loc) · 2.47 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
data "aws_region" "current" {}
# --------------------------------------------------------------------------------------------------
# Enable SecurityHub
# --------------------------------------------------------------------------------------------------
resource "aws_securityhub_account" "main" {
}
resource "aws_securityhub_finding_aggregator" "main" {
count = var.aggregate_findings && var.master_account_id == "" ? 1 : 0
linking_mode = "ALL_REGIONS"
depends_on = [aws_securityhub_account.main]
}
# --------------------------------------------------------------------------------------------------
# Add member accounts
# --------------------------------------------------------------------------------------------------
resource "aws_securityhub_member" "members" {
count = length(var.member_accounts)
depends_on = [aws_securityhub_account.main]
account_id = var.member_accounts[count.index].account_id
email = var.member_accounts[count.index].email
invite = true
}
resource "aws_securityhub_invite_accepter" "invitee" {
count = var.master_account_id != "" ? 1 : 0
master_id = var.master_account_id
depends_on = [aws_securityhub_account.main]
}
# --------------------------------------------------------------------------------------------------
# Subscribe standards
# --------------------------------------------------------------------------------------------------
resource "aws_securityhub_standards_subscription" "cis" {
count = var.enable_cis_standard ? 1 : 0
standards_arn = "arn:aws:securityhub:${data.aws_region.current.name}::standards/cis-aws-foundations-benchmark/v/1.4.0"
depends_on = [aws_securityhub_account.main]
}
resource "aws_securityhub_standards_subscription" "aws_foundational" {
count = var.enable_aws_foundational_standard ? 1 : 0
standards_arn = "arn:aws:securityhub:${data.aws_region.current.name}::standards/aws-foundational-security-best-practices/v/1.0.0"
depends_on = [aws_securityhub_account.main]
}
resource "aws_securityhub_standards_subscription" "pci_dss" {
count = var.enable_pci_dss_standard ? 1 : 0
standards_arn = "arn:aws:securityhub:${data.aws_region.current.name}::standards/pci-dss/v/3.2.1"
depends_on = [aws_securityhub_account.main]
}
# 3rd party products
resource "aws_securityhub_product_subscription" "products" {
count = length(var.enable_product_arns)
product_arn = replace(var.enable_product_arns[count.index], "<REGION>", data.aws_region.current.name)
depends_on = [aws_securityhub_account.main]
}