forked from nozaq/terraform-aws-secure-baseline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
63 lines (49 loc) · 2.86 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
data "aws_region" "current" {}
# --------------------------------------------------------------------------------------------------
# Enable SecurityHub
# --------------------------------------------------------------------------------------------------
resource "aws_securityhub_account" "main" {
count = var.enabled ? 1 : 0
}
# --------------------------------------------------------------------------------------------------
# Add member accounts
# --------------------------------------------------------------------------------------------------
resource "aws_securityhub_member" "members" {
count = var.enabled ? length(var.member_accounts) : 0
depends_on = [aws_securityhub_account.main]
account_id = var.member_accounts[count.index].account_id
email = var.member_accounts[count.index].email
invite = true
}
# --------------------------------------------------------------------------------------------------
# Subscribe CIS benchmark
# --------------------------------------------------------------------------------------------------
resource "aws_securityhub_standards_subscription" "cis" {
count = var.enabled && var.enable_cis_standard ? 1 : 0
standards_arn = "arn:aws:securityhub:::ruleset/cis-aws-foundations-benchmark/v/1.2.0"
depends_on = [aws_securityhub_account.main]
}
# --------------------------------------------------------------------------------------------------
# Subscribe AWS foundational security best practices standard
# --------------------------------------------------------------------------------------------------
resource "aws_securityhub_standards_subscription" "aws_foundational" {
count = var.enabled && 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]
}
# --------------------------------------------------------------------------------------------------
# Subscribe PCI DSS standard
# --------------------------------------------------------------------------------------------------
resource "aws_securityhub_standards_subscription" "pci_dss" {
count = var.enabled && 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]
}
# --------------------------------------------------------------------------------------------------
# Subscribe to 3rd party products
# --------------------------------------------------------------------------------------------------
resource "aws_securityhub_product_subscription" "products" {
count = var.enabled ? length(var.enable_product_arns) : 0
product_arn = replace(var.enable_product_arns[count.index], "<REGION>", data.aws_region.current.name)
depends_on = [aws_securityhub_account.main]
}