Skip to content

Commit af85d33

Browse files
committed
feat: Configure Macie on all regions.
1 parent 3e01727 commit af85d33

File tree

5 files changed

+107
-0
lines changed

5 files changed

+107
-0
lines changed

tofu/config/security-delegate/.terraform.lock.hcl

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tofu/config/security-delegate/main.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ module "automations" {
2525
}
2626
}
2727

28+
# Configure Macie in each region.
29+
module "macie" {
30+
for_each = toset(["us-east-1", "us-east-2", "us-west-1", "us-west-2"])
31+
source = "../../modules/macie"
32+
33+
providers = {
34+
aws = aws.by_region[each.key]
35+
}
36+
}
37+
2838
output "tfstate_bucket" {
2939
value = module.backend.bucket
3040
}

tofu/modules/macie/main.tf

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
data "aws_region" "current" {}
2+
3+
data "external" "template_id" {
4+
program = [
5+
"aws", "macie2", "list-sensitivity-inspection-templates", "--query",
6+
"sensitivityInspectionTemplates[?name=='automated-sensitive-data-discovery'] | [0] | {id: id}",
7+
"--output", "json", "--region", data.aws_region.current.name
8+
]
9+
}
10+
11+
resource "terraform_data" "template" {
12+
depends_on = [data.external.template_id]
13+
14+
# Trigger replacement when the template file changes.
15+
triggers_replace = [
16+
filesha256("${path.module}/template.yaml")
17+
]
18+
19+
provisioner "local-exec" {
20+
command = "aws macie2 update-sensitivity-inspection-template --id ${data.external.template_id.result.id} --region ${data.aws_region.current.name} --cli-input-yaml file://${path.module}/template.yaml"
21+
}
22+
}
23+
24+
output "template_id" {
25+
value = data.external.template_id.result.id
26+
}

tofu/modules/macie/template.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
description: Default Template used for Automated Discovery
2+
excludes:
3+
managedDataIdentifierIds: []
4+
includes:
5+
allowListIds: []
6+
customDataIdentifierIds: []
7+
managedDataIdentifierIds:
8+
- ADDRESS
9+
- AWS_CREDENTIALS
10+
- BANK_ACCOUNT_NUMBER
11+
- CREDIT_CARD_EXPIRATION
12+
- CREDIT_CARD_MAGNETIC_STRIPE
13+
- CREDIT_CARD_NUMBER
14+
- CREDIT_CARD_NUMBER_(NO_KEYWORD)
15+
- CREDIT_CARD_SECURITY_CODE
16+
- DATE_OF_BIRTH
17+
- DRIVERS_LICENSE
18+
- GCP_API_KEY
19+
- HTTP_BASIC_AUTH_HEADER
20+
- HTTP_COOKIE
21+
- JSON_WEB_TOKEN
22+
- LATITUDE_LONGITUDE
23+
- MEDICAL_DEVICE_UDI
24+
- NAME
25+
- OPENSSH_PRIVATE_KEY
26+
- PGP_PRIVATE_KEY
27+
- PHONE_NUMBER
28+
- PKCS
29+
- PUTTY_PRIVATE_KEY
30+
- USA_HEALTHCARE_PROCEDURE_CODE
31+
- USA_HEALTH_INSURANCE_CLAIM_NUMBER
32+
- USA_INDIVIDUAL_TAX_IDENTIFICATION_NUMBER
33+
- USA_MEDICARE_BENEFICIARY_IDENTIFIER
34+
- USA_NATIONAL_DRUG_CODE
35+
- USA_NATIONAL_PROVIDER_IDENTIFIER
36+
- USA_PASSPORT_NUMBER
37+
- USA_SOCIAL_SECURITY_NUMBER
38+
- US_DRUG_ENFORCEMENT_AGENCY_NUMBER
39+
- VEHICLE_IDENTIFICATION_NUMBER

tofu/modules/macie/versions.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
terraform {
2+
required_version = ">= 1.9"
3+
4+
required_providers {
5+
aws = {
6+
source = "hashicorp/aws"
7+
version = "~> 5.88"
8+
}
9+
10+
external = {
11+
source = "hashicorp/external"
12+
version = "~> 2.3"
13+
}
14+
}
15+
}

0 commit comments

Comments
 (0)