From 65b6072cec0bc7e277639bd2884ea18c8f3874ef Mon Sep 17 00:00:00 2001 From: Elad Date: Mon, 16 Nov 2026 22:27:49 +0200 Subject: [PATCH] chore(e5c9): delete the hand-written guardduty, securityhub and inspector2 E5c9 of the E5c plan. Since E5c8 (#527) no stack has an instance of the hand-written components: the vendored Cloud Posse aws-guardduty, aws-security-hub and aws-inspector2 (delegated administrator + org-settings) own the services. Deletion PR, size-exempt per the plan. - Deleted components/terraform/{guardduty,securityhub,inspector2} (tests and the inline CKV2_AWS_3 skip included) and stacks/catalog/{guardduty,securityhub,inspector2}. - CODEOWNERS: the three catalog entries name the vendored catalogs. - deploy-full-stack: the old names leave the security layer's plan and deploy queries (both copies). - check-first-deploy-inputs: the old names leave MAP_CONSUMERS; tests use aws-guardduty. - plan_sweep_hcl: account_ids (only the deleted aws_inspector2_enabler) leaves LIST_SCALAR_ATTRS. - README 60 root modules (44 hand-written); CLAUDE.md 38 of the 44 validate tags.Environment; aws-security-hub catalog comments no longer point at deleted files. Resolved stacks are byte-identical (stack-snapshot IDENTICAL, 28 stacks). --- .github/CODEOWNERS | 6 +- CLAUDE.md | 2 +- README.md | 2 +- .../terraform/guardduty/.terraform.lock.hcl | 29 ----- components/terraform/guardduty/README.md | 18 --- components/terraform/guardduty/main.tf | 61 ---------- components/terraform/guardduty/outputs.tf | 19 --- components/terraform/guardduty/provider.tf | 7 -- components/terraform/guardduty/variables.tf | 86 ------------- components/terraform/guardduty/versions.tf | 10 -- .../terraform/inspector2/.terraform.lock.hcl | 29 ----- components/terraform/inspector2/README.md | 23 ---- components/terraform/inspector2/main.tf | 27 ---- components/terraform/inspector2/outputs.tf | 9 -- components/terraform/inspector2/provider.tf | 7 -- .../inspector2/tests/inspector2.tftest.hcl | 115 ------------------ components/terraform/inspector2/variables.tf | 61 ---------- components/terraform/inspector2/versions.tf | 10 -- .../terraform/securityhub/.terraform.lock.hcl | 29 ----- components/terraform/securityhub/README.md | 27 ---- components/terraform/securityhub/main.tf | 67 ---------- components/terraform/securityhub/outputs.tf | 14 --- components/terraform/securityhub/provider.tf | 7 -- .../securityhub/tests/securityhub.tftest.hcl | 66 ---------- components/terraform/securityhub/variables.tf | 69 ----------- components/terraform/securityhub/versions.tf | 10 -- scripts/plan_sweep_hcl.py | 2 - stacks/catalog/aws-security-hub/defaults.yaml | 4 +- stacks/catalog/guardduty/defaults.yaml | 31 ----- stacks/catalog/guardduty/main-prod.yaml | 22 ---- stacks/catalog/guardduty/main-standby.yaml | 18 --- stacks/catalog/guardduty/main.yaml | 23 ---- stacks/catalog/guardduty/prod.yaml | 25 ---- stacks/catalog/inspector2/defaults.yaml | 28 ----- stacks/catalog/inspector2/main.yaml | 23 ---- stacks/catalog/securityhub/defaults.yaml | 30 ----- stacks/catalog/securityhub/main-prod.yaml | 23 ---- stacks/catalog/securityhub/main-region.yaml | 48 -------- stacks/catalog/securityhub/main-standby.yaml | 42 ------- stacks/catalog/securityhub/main.yaml | 22 ---- stacks/catalog/securityhub/prod.yaml | 22 ---- workflows/deploy-full-stack.yaml | 18 ++- .../common/check-first-deploy-inputs.py | 4 +- .../common/test_check_first_deploy_inputs.py | 4 +- 44 files changed, 18 insertions(+), 1181 deletions(-) delete mode 100644 components/terraform/guardduty/.terraform.lock.hcl delete mode 100644 components/terraform/guardduty/README.md delete mode 100644 components/terraform/guardduty/main.tf delete mode 100644 components/terraform/guardduty/outputs.tf delete mode 100644 components/terraform/guardduty/provider.tf delete mode 100644 components/terraform/guardduty/variables.tf delete mode 100644 components/terraform/guardduty/versions.tf delete mode 100644 components/terraform/inspector2/.terraform.lock.hcl delete mode 100644 components/terraform/inspector2/README.md delete mode 100644 components/terraform/inspector2/main.tf delete mode 100644 components/terraform/inspector2/outputs.tf delete mode 100644 components/terraform/inspector2/provider.tf delete mode 100644 components/terraform/inspector2/tests/inspector2.tftest.hcl delete mode 100644 components/terraform/inspector2/variables.tf delete mode 100644 components/terraform/inspector2/versions.tf delete mode 100644 components/terraform/securityhub/.terraform.lock.hcl delete mode 100644 components/terraform/securityhub/README.md delete mode 100644 components/terraform/securityhub/main.tf delete mode 100644 components/terraform/securityhub/outputs.tf delete mode 100644 components/terraform/securityhub/provider.tf delete mode 100644 components/terraform/securityhub/tests/securityhub.tftest.hcl delete mode 100644 components/terraform/securityhub/variables.tf delete mode 100644 components/terraform/securityhub/versions.tf delete mode 100644 stacks/catalog/guardduty/defaults.yaml delete mode 100644 stacks/catalog/guardduty/main-prod.yaml delete mode 100644 stacks/catalog/guardduty/main-standby.yaml delete mode 100644 stacks/catalog/guardduty/main.yaml delete mode 100644 stacks/catalog/guardduty/prod.yaml delete mode 100644 stacks/catalog/inspector2/defaults.yaml delete mode 100644 stacks/catalog/inspector2/main.yaml delete mode 100644 stacks/catalog/securityhub/defaults.yaml delete mode 100644 stacks/catalog/securityhub/main-prod.yaml delete mode 100644 stacks/catalog/securityhub/main-region.yaml delete mode 100644 stacks/catalog/securityhub/main-standby.yaml delete mode 100644 stacks/catalog/securityhub/main.yaml delete mode 100644 stacks/catalog/securityhub/prod.yaml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 2884e850..7e146e3c 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -24,9 +24,9 @@ /stacks/catalog/secretsmanager/ @hemzaz /stacks/catalog/aws-cloudtrail/ @hemzaz /stacks/catalog/aws-config/ @hemzaz -/stacks/catalog/guardduty/ @hemzaz -/stacks/catalog/securityhub/ @hemzaz -/stacks/catalog/inspector2/ @hemzaz +/stacks/catalog/aws-guardduty/ @hemzaz +/stacks/catalog/aws-security-hub/ @hemzaz +/stacks/catalog/aws-inspector2/ @hemzaz /stacks/catalog/security-monitoring/ @hemzaz /stacks/catalog/apigateway-account/ @hemzaz /stacks/catalog/backup/ @hemzaz diff --git a/CLAUDE.md b/CLAUDE.md index 491eff98..559ad7f4 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -47,7 +47,7 @@ Nothing has been applied to AWS yet, so refactors need no state migration. - Stage `fixtures` (`fnx-ue1-fixtures-`) puts each catalog template under the checks and is never deployed; `KNOWN_BROKEN_FIXTURES` (`workflows/scripts/common/fixtures.py`) relaxes a template until its port PR removes the entry. -- 41 of the 47 hand-written root modules validate a non-empty `tags.Environment` (all but `backend`, +- 38 of the 44 hand-written root modules validate a non-empty `tags.Environment` (all but `backend`, `dns`, `iam`, `kms`, `secretsmanager`, and `aws-config-bucket`, a house copy of a Cloud Posse component that names from `vars.context` like the vendored ones); many use it in resource names. - A vendored component (`vendor.yaml`) names resources from the null-label `vars.context` of the diff --git a/README.md b/README.md index 51232a62..38dc9c78 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ models something, copy its variable names, types and defaults; use typed objects ``` atmos.yaml Atmos config: version constraint, paths, name_template, Native CI, scaffolds -components/terraform/ 63 root modules (47 hand-written, 16 vendored; + _library/ shared modules and account-map/, Cloud Posse's vendored iam-roles module, which the vendored account-map-bypass providers mixin bypasses); each has a README +components/terraform/ 60 root modules (44 hand-written, 16 vendored; + _library/ shared modules and account-map/, Cloud Posse's vendored iam-roles module, which the vendored account-map-bypass providers mixin bypasses); each has a README stacks/orgs/fnx/ org defaults (_defaults.yaml: tags, Terraform version, S3 backend) and the stacks stacks/catalog/ abstract component defaults; templates/ holds opt-in stack templates stacks/mixins/ tenant, stage and region mixins diff --git a/components/terraform/guardduty/.terraform.lock.hcl b/components/terraform/guardduty/.terraform.lock.hcl deleted file mode 100644 index 7c3d144b..00000000 --- a/components/terraform/guardduty/.terraform.lock.hcl +++ /dev/null @@ -1,29 +0,0 @@ -# This file is maintained automatically by "terraform init". -# Manual edits may be lost in future updates. - -provider "registry.terraform.io/hashicorp/aws" { - version = "6.67.0" - constraints = "~> 6.65" - hashes = [ - "h1:8kRViFkyn96SufnuV3Oi3QmfL+DiyxlhAPcSX2jH0T0=", - "h1:EB9ixYOZrSlYD7wtJxf88qwoyyWrlKDKxhzaCLIb3t4=", - "h1:OgdIUAQDtJBxlKjoPgChD1w57vl6hm6PyJHiBYgsgQA=", - "h1:zLmFaFw5LptpWftHL3O6+7uykOH/0F9AmyVQ7V6kslY=", - "zh:111d5686a1f4ccbc888bb5e2229308bcdd9149898c6af97969fcdfb0e7bd2aa0", - "zh:21b3b7693bd9754c039fd546f03ed09e7510c6189aa5ee37176f144cf8dd5f95", - "zh:25e03c7f025ff4851889537605aa560d2e39bd738b33a5204b8037eb164b475f", - "zh:2817a046f1060e25bf04b0eb78f4e251130bb92dc82ec1264ce156dc9bf78e67", - "zh:2d318d674c3ec9dbd97ddb10b12ad4827be4f508c43ba2ae1e0523baa9e367e3", - "zh:2f07ab356718267299e10b6072472ded29d82753883027bf43bcd687ac72feb2", - "zh:32307e67f83bc0dc94d38cfcd23d782166a09e0e975e2a5aa7d7a3e7ca5d3da8", - "zh:4ce94853264097dd7f4542b3cfd18d2b98b06d23321db45d5e384ea275a57f63", - "zh:869656c41cc7c7412f213e488f98167cff61deafcb8cf245d25d056e8dfdc263", - "zh:8fd8c814e9d8edf152552047db23bf5b5d63f22e6b0b5d47b2af851376e99349", - "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", - "zh:9cbc02ceef9bd469da497a1e7065ff984bdacfbe919ac3cce804a86c13b6e2c6", - "zh:9ea55dda2767acfc1f6337fc7d29b1d4d79d6f8f04871f8ad99a6078d2865994", - "zh:d7149df0819fb57a160489db45d33951765b8f0118daa3b4cd549a0135bc97a1", - "zh:e5819937bb7043d08c9829b32d52d9fb55a5b9a4d8d55d550d47a3d7392db546", - "zh:f93bc38dbc0ad53842303f30eec7a22c525c4d56209b54ec33a8d375cfc4e4fd", - ] -} diff --git a/components/terraform/guardduty/README.md b/components/terraform/guardduty/README.md deleted file mode 100644 index 826be2ba..00000000 --- a/components/terraform/guardduty/README.md +++ /dev/null @@ -1,18 +0,0 @@ -# guardduty - -The GuardDuty detector for one account and region, its S3, EKS audit log and EBS malware -protection plans, and ARCHIVE finding filters. Defaults follow Cloud Posse `aws-guardduty`: S3 -protection on, EKS and malware scanning off (prod turns both on). - -## Wiring - -- Instance: none (E5c8): the organization's vendored `aws-guardduty` (delegated administrator in - each `--security` stack) replaced it; this component is deleted in E5c9. - -## Notes - -- This component is the only owner of the detector; `enable = false` destroys it and its filters. -- Protection plans are `aws_guardduty_detector_feature` resources (AWS provider 6.x). -- Each `auto_archive_filter` needs at least one `criteria` field (a severity-only rule would - archive everything at that severity). Filter rank follows list order, so reordering renames - and re-ranks filters. diff --git a/components/terraform/guardduty/main.tf b/components/terraform/guardduty/main.tf deleted file mode 100644 index 0e3b9871..00000000 --- a/components/terraform/guardduty/main.tf +++ /dev/null @@ -1,61 +0,0 @@ -locals { - name_prefix = "${var.tags["Environment"]}-guardduty" - - # On AWS provider 6.x the detector no longer takes inline `datasources` blocks; - # each protection plan is its own aws_guardduty_detector_feature resource. - features = { - S3_DATA_EVENTS = var.enable_s3_protection - EKS_AUDIT_LOGS = var.enable_kubernetes_protection - EBS_MALWARE_PROTECTION = var.enable_malware_protection - } -} - -resource "aws_guardduty_detector" "main" { - # checkov:skip=CKV2_AWS_3: Deliberate scope limit, not a false positive. The check wants the - # detector wired to an aws_guardduty_organization_configuration with org-wide auto-enrollment. - # That resource may only be created by the Organizations delegated administrator account, this - # component deploys into a member account, and no stack here asks for org-wide enrollment. - count = var.enable ? 1 : 0 - - enable = true - finding_publishing_frequency = var.finding_publishing_frequency - - tags = { Name = local.name_prefix } -} - -resource "aws_guardduty_detector_feature" "main" { - for_each = var.enable ? local.features : {} - - detector_id = aws_guardduty_detector.main[0].id - name = each.key - status = each.value ? "ENABLED" : "DISABLED" -} - -# Findings matching a filter with action ARCHIVE are suppressed from the active -# finding list; rank decides evaluation order when several filters overlap. -resource "aws_guardduty_filter" "auto_archive" { - count = var.enable ? length(var.auto_archive_filter) : 0 - - name = "${local.name_prefix}-auto-archive-${count.index + 1}" - action = "ARCHIVE" - detector_id = aws_guardduty_detector.main[0].id - rank = count.index + 1 - - finding_criteria { - criterion { - field = "severity" - equals = [tostring(var.auto_archive_filter[count.index].severity)] - } - - dynamic "criterion" { - for_each = var.auto_archive_filter[count.index].criteria - - content { - field = criterion.key - equals = criterion.value - } - } - } - - tags = { Name = "${local.name_prefix}-auto-archive-${count.index + 1}" } -} diff --git a/components/terraform/guardduty/outputs.tf b/components/terraform/guardduty/outputs.tf deleted file mode 100644 index a2c76648..00000000 --- a/components/terraform/guardduty/outputs.tf +++ /dev/null @@ -1,19 +0,0 @@ -output "detector_id" { - description = "ID of the GuardDuty detector (null when enable is false)" - value = var.enable ? aws_guardduty_detector.main[0].id : null -} - -output "detector_arn" { - description = "ARN of the GuardDuty detector (null when enable is false)" - value = var.enable ? aws_guardduty_detector.main[0].arn : null -} - -output "enabled_features" { - description = "Protection plan name to status, as applied to the detector" - value = { for name, feature in aws_guardduty_detector_feature.main : name => feature.status } -} - -output "auto_archive_filter_arns" { - description = "ARNs of the auto-archive finding filters" - value = aws_guardduty_filter.auto_archive[*].arn -} diff --git a/components/terraform/guardduty/provider.tf b/components/terraform/guardduty/provider.tf deleted file mode 100644 index 6c843dc5..00000000 --- a/components/terraform/guardduty/provider.tf +++ /dev/null @@ -1,7 +0,0 @@ -provider "aws" { - region = var.region - - default_tags { - tags = var.tags - } -} diff --git a/components/terraform/guardduty/variables.tf b/components/terraform/guardduty/variables.tf deleted file mode 100644 index c2bfed4e..00000000 --- a/components/terraform/guardduty/variables.tf +++ /dev/null @@ -1,86 +0,0 @@ -variable "region" { - type = string - description = "AWS region" - - validation { - condition = can(regex("^[a-z]{2}(-[a-z]+)+-\\d+$", var.region)) - error_message = "The region must be a valid AWS region name (e.g., us-east-1, eu-west-1)." - } -} - -variable "tags" { - type = map(string) - description = "Tags to apply to resources; must include Environment (used in resource names)" - - validation { - condition = trimspace(lookup(var.tags, "Environment", "")) != "" - error_message = "tags must include a non-empty Environment value." - } -} - -variable "enable" { - type = bool - description = "Create the GuardDuty detector and everything attached to it" - default = true -} - -############################################## -# Protection Plans -############################################## - -variable "enable_s3_protection" { - type = bool - description = "Enable the S3_DATA_EVENTS protection plan" - default = true -} - -variable "enable_kubernetes_protection" { - type = bool - description = "Enable the EKS_AUDIT_LOGS protection plan" - default = true -} - -variable "enable_malware_protection" { - type = bool - description = "Enable the EBS_MALWARE_PROTECTION protection plan" - default = true -} - -variable "finding_publishing_frequency" { - type = string - description = "How often findings are published to EventBridge and other members" - default = "FIFTEEN_MINUTES" - - validation { - condition = contains(["FIFTEEN_MINUTES", "ONE_HOUR", "SIX_HOURS"], var.finding_publishing_frequency) - error_message = "finding_publishing_frequency must be FIFTEEN_MINUTES, ONE_HOUR or SIX_HOURS." - } -} - -############################################## -# Auto-archive Filters -############################################## - -variable "auto_archive_filter" { - type = list(object({ - severity = number - criteria = map(list(string)) - })) - description = "Filters that archive matching findings. `criteria` maps a GuardDuty finding field (e.g. `type`) to the values it must equal." - default = [] - - validation { - condition = alltrue([for f in var.auto_archive_filter : f.severity >= 1 && f.severity <= 8]) - error_message = "Each auto_archive_filter severity must be between 1 and 8." - } - - validation { - condition = alltrue([for f in var.auto_archive_filter : length(f.criteria) > 0]) - error_message = "Each auto_archive_filter must set at least one criteria field; a severity-only archive rule would suppress every finding at that severity." - } - - validation { - condition = length(var.auto_archive_filter) <= 100 - error_message = "GuardDuty allows at most 100 filters per detector (rank is 1-100)." - } -} diff --git a/components/terraform/guardduty/versions.tf b/components/terraform/guardduty/versions.tf deleted file mode 100644 index 082a8f12..00000000 --- a/components/terraform/guardduty/versions.tf +++ /dev/null @@ -1,10 +0,0 @@ -terraform { - required_version = ">= 1.16.0, < 2.0.0" - - required_providers { - aws = { - source = "hashicorp/aws" - version = "~> 6.65" - } - } -} diff --git a/components/terraform/inspector2/.terraform.lock.hcl b/components/terraform/inspector2/.terraform.lock.hcl deleted file mode 100644 index 7c3d144b..00000000 --- a/components/terraform/inspector2/.terraform.lock.hcl +++ /dev/null @@ -1,29 +0,0 @@ -# This file is maintained automatically by "terraform init". -# Manual edits may be lost in future updates. - -provider "registry.terraform.io/hashicorp/aws" { - version = "6.67.0" - constraints = "~> 6.65" - hashes = [ - "h1:8kRViFkyn96SufnuV3Oi3QmfL+DiyxlhAPcSX2jH0T0=", - "h1:EB9ixYOZrSlYD7wtJxf88qwoyyWrlKDKxhzaCLIb3t4=", - "h1:OgdIUAQDtJBxlKjoPgChD1w57vl6hm6PyJHiBYgsgQA=", - "h1:zLmFaFw5LptpWftHL3O6+7uykOH/0F9AmyVQ7V6kslY=", - "zh:111d5686a1f4ccbc888bb5e2229308bcdd9149898c6af97969fcdfb0e7bd2aa0", - "zh:21b3b7693bd9754c039fd546f03ed09e7510c6189aa5ee37176f144cf8dd5f95", - "zh:25e03c7f025ff4851889537605aa560d2e39bd738b33a5204b8037eb164b475f", - "zh:2817a046f1060e25bf04b0eb78f4e251130bb92dc82ec1264ce156dc9bf78e67", - "zh:2d318d674c3ec9dbd97ddb10b12ad4827be4f508c43ba2ae1e0523baa9e367e3", - "zh:2f07ab356718267299e10b6072472ded29d82753883027bf43bcd687ac72feb2", - "zh:32307e67f83bc0dc94d38cfcd23d782166a09e0e975e2a5aa7d7a3e7ca5d3da8", - "zh:4ce94853264097dd7f4542b3cfd18d2b98b06d23321db45d5e384ea275a57f63", - "zh:869656c41cc7c7412f213e488f98167cff61deafcb8cf245d25d056e8dfdc263", - "zh:8fd8c814e9d8edf152552047db23bf5b5d63f22e6b0b5d47b2af851376e99349", - "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", - "zh:9cbc02ceef9bd469da497a1e7065ff984bdacfbe919ac3cce804a86c13b6e2c6", - "zh:9ea55dda2767acfc1f6337fc7d29b1d4d79d6f8f04871f8ad99a6078d2865994", - "zh:d7149df0819fb57a160489db45d33951765b8f0118daa3b4cd549a0135bc97a1", - "zh:e5819937bb7043d08c9829b32d52d9fb55a5b9a4d8d55d550d47a3d7392db546", - "zh:f93bc38dbc0ad53842303f30eec7a22c525c4d56209b54ec33a8d375cfc4e4fd", - ] -} diff --git a/components/terraform/inspector2/README.md b/components/terraform/inspector2/README.md deleted file mode 100644 index d324f4d3..00000000 --- a/components/terraform/inspector2/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# inspector2 - -Enables Amazon Inspector for one account and region, scanning the resource types the -`auto_enable_*` flags select (EC2, ECR, Lambda and, opt-in, Lambda code). Modelled on Cloud Posse -`aws-inspector2`, single-account path only (see `main.tf`). Off by default: Inspector bills per -resource scanned. - -## Wiring - -- Instance: none (E5c8): the organization's vendored `aws-inspector2` (delegated administrator in - each `--security` stack, org-settings committed `metadata.enabled: false`, owner - OQ-IN) replaced it; this component is deleted in E5c9. -- Used by: nothing (security-monitoring routes Inspector findings by a flag). - -## Notes - -- This component is the only owner of Inspector for the account; `enabled: false` (or removing a - flag) disables scanning of those resource types. -- Organization mode (delegated administrator, organization auto-enable, member association) is - not implemented: this repo has no AWS Organizations management or delegated-administrator - stack. Each workload account enables itself instead. -- `auto_enable_lambda_code` needs `auto_enable_lambda`, and `enabled: true` needs at least one of - EC2, ECR or Lambda (both validated). diff --git a/components/terraform/inspector2/main.tf b/components/terraform/inspector2/main.tf deleted file mode 100644 index b20f7b31..00000000 --- a/components/terraform/inspector2/main.tf +++ /dev/null @@ -1,27 +0,0 @@ -# Amazon Inspector for one account and region, modelled on Cloud Posse -# aws-inspector2 (cloudposse-terraform-components/aws-inspector2). Deviation: -# only the single-account path. Cloud Posse's component delegates the -# Inspector administrator from the organization management account and, in the -# delegated administrator account, sets the organization's auto-enable and -# associates members. This repo has no AWS Organizations management or -# delegated-administrator stack, so each workload account enables itself here, -# with the resource types the auto_enable_* flags select. -locals { - resource_types = compact([ - var.auto_enable_ec2 ? "EC2" : null, - var.auto_enable_ecr ? "ECR" : null, - var.auto_enable_lambda ? "LAMBDA" : null, - var.auto_enable_lambda_code ? "LAMBDA_CODE" : null, - ]) -} - -data "aws_caller_identity" "current" { - count = var.enabled ? 1 : 0 -} - -resource "aws_inspector2_enabler" "main" { - count = var.enabled ? 1 : 0 - - account_ids = [data.aws_caller_identity.current[0].account_id] - resource_types = local.resource_types -} diff --git a/components/terraform/inspector2/outputs.tf b/components/terraform/inspector2/outputs.tf deleted file mode 100644 index 8d10a32d..00000000 --- a/components/terraform/inspector2/outputs.tf +++ /dev/null @@ -1,9 +0,0 @@ -output "account_id" { - description = "AWS account ID Inspector is enabled in (null when enabled is false). security-monitoring routes Inspector findings while it is set" - value = var.enabled ? one(aws_inspector2_enabler.main[0].account_ids) : null -} - -output "enabled_resource_types" { - description = "Resource types Inspector scans in this account (EC2, ECR, LAMBDA, LAMBDA_CODE); empty when enabled is false" - value = var.enabled ? sort(tolist(aws_inspector2_enabler.main[0].resource_types)) : tolist([]) -} diff --git a/components/terraform/inspector2/provider.tf b/components/terraform/inspector2/provider.tf deleted file mode 100644 index 6c843dc5..00000000 --- a/components/terraform/inspector2/provider.tf +++ /dev/null @@ -1,7 +0,0 @@ -provider "aws" { - region = var.region - - default_tags { - tags = var.tags - } -} diff --git a/components/terraform/inspector2/tests/inspector2.tftest.hcl b/components/terraform/inspector2/tests/inspector2.tftest.hcl deleted file mode 100644 index ab59cfac..00000000 --- a/components/terraform/inspector2/tests/inspector2.tftest.hcl +++ /dev/null @@ -1,115 +0,0 @@ -# Mock-provider tests: no AWS credentials, no network. Run from the component -# directory with `terraform init -backend=false && terraform test`. - -mock_provider "aws" { - override_during = plan - - mock_data "aws_caller_identity" { - defaults = { - account_id = "123456789012" - } - } -} - -variables { - region = "us-east-1" - tags = { - Environment = "test" - Tenant = "fnx" - ManagedBy = "Terraform" - } -} - -run "off_by_default_creates_nothing" { - command = plan - - assert { - condition = length(aws_inspector2_enabler.main) == 0 && length(data.aws_caller_identity.current) == 0 - error_message = "enabled defaults to false: no enabler and no caller identity lookup." - } - - assert { - condition = output.account_id == null && length(output.enabled_resource_types) == 0 - error_message = "Disabled: account_id is null (security-monitoring's Inspector route stays off) and no resource types." - } -} - -run "enabled_uses_cloud_posse_defaults" { - command = plan - - variables { - enabled = true - } - - assert { - condition = aws_inspector2_enabler.main[0].account_ids == toset(["123456789012"]) - error_message = "The enabler covers this account only." - } - - assert { - condition = output.enabled_resource_types == tolist(["EC2", "ECR", "LAMBDA"]) - error_message = "Cloud Posse defaults: EC2, ECR and LAMBDA on, LAMBDA_CODE off." - } - - assert { - condition = output.account_id == "123456789012" - error_message = "account_id is the enabled account." - } -} - -run "resource_types_follow_the_flags" { - command = plan - - variables { - enabled = true - auto_enable_ec2 = false - auto_enable_ecr = true - auto_enable_lambda = true - auto_enable_lambda_code = true - } - - assert { - condition = aws_inspector2_enabler.main[0].resource_types == toset(["ECR", "LAMBDA", "LAMBDA_CODE"]) - error_message = "Only the flagged resource types are scanned, LAMBDA_CODE included." - } -} - -run "rejects_enabled_without_resource_types" { - command = plan - - variables { - enabled = true - auto_enable_ec2 = false - auto_enable_ecr = false - auto_enable_lambda = false - } - - expect_failures = [var.enabled] -} - -run "rejects_lambda_code_without_lambda" { - command = plan - - variables { - enabled = true - auto_enable_lambda = false - auto_enable_lambda_code = true - } - - expect_failures = [var.auto_enable_lambda_code] -} - -run "disabled_ignores_empty_resource_types" { - command = plan - - variables { - auto_enable_ec2 = false - auto_enable_ecr = false - auto_enable_lambda = false - } - - assert { - condition = length(aws_inspector2_enabler.main) == 0 - error_message = "With enabled false, no resource type is required." - } -} diff --git a/components/terraform/inspector2/variables.tf b/components/terraform/inspector2/variables.tf deleted file mode 100644 index f8dceaba..00000000 --- a/components/terraform/inspector2/variables.tf +++ /dev/null @@ -1,61 +0,0 @@ -variable "region" { - type = string - description = "AWS region Inspector is enabled in" - - validation { - condition = can(regex("^[a-z]{2}(-[a-z]+)+-\\d+$", var.region)) - error_message = "The region must be a valid AWS region name (e.g., us-east-1, eu-west-1)." - } -} - -variable "tags" { - type = map(string) - description = "Tags to apply to resources; must include Environment" - - validation { - condition = trimspace(lookup(var.tags, "Environment", "")) != "" - error_message = "tags must include a non-empty Environment value." - } -} - -variable "enabled" { - type = bool - description = "Enable Amazon Inspector for this account and region. Inspector bills per resource scanned, so the catalog leaves it false" - default = false - - validation { - condition = !var.enabled || var.auto_enable_ec2 || var.auto_enable_ecr || var.auto_enable_lambda - error_message = "enabled needs at least one resource type: set auto_enable_ec2, auto_enable_ecr or auto_enable_lambda." - } -} - -# Cloud Posse aws-inspector2 input names. There they set the organization's -# auto-enable; here they pick the resource types scanned in this account. -variable "auto_enable_ec2" { - type = bool - description = "Scan EC2 instances (resource type EC2)" - default = true -} - -variable "auto_enable_ecr" { - type = bool - description = "Scan ECR container images (resource type ECR)" - default = true -} - -variable "auto_enable_lambda" { - type = bool - description = "Scan Lambda functions' package dependencies (resource type LAMBDA)" - default = true -} - -variable "auto_enable_lambda_code" { - type = bool - description = "Also scan Lambda function code (resource type LAMBDA_CODE). Needs auto_enable_lambda" - default = false - - validation { - condition = !var.auto_enable_lambda_code || var.auto_enable_lambda - error_message = "auto_enable_lambda_code needs auto_enable_lambda: Lambda code scanning builds on Lambda standard scanning." - } -} diff --git a/components/terraform/inspector2/versions.tf b/components/terraform/inspector2/versions.tf deleted file mode 100644 index 082a8f12..00000000 --- a/components/terraform/inspector2/versions.tf +++ /dev/null @@ -1,10 +0,0 @@ -terraform { - required_version = ">= 1.16.0, < 2.0.0" - - required_providers { - aws = { - source = "hashicorp/aws" - version = "~> 6.65" - } - } -} diff --git a/components/terraform/securityhub/.terraform.lock.hcl b/components/terraform/securityhub/.terraform.lock.hcl deleted file mode 100644 index 7c3d144b..00000000 --- a/components/terraform/securityhub/.terraform.lock.hcl +++ /dev/null @@ -1,29 +0,0 @@ -# This file is maintained automatically by "terraform init". -# Manual edits may be lost in future updates. - -provider "registry.terraform.io/hashicorp/aws" { - version = "6.67.0" - constraints = "~> 6.65" - hashes = [ - "h1:8kRViFkyn96SufnuV3Oi3QmfL+DiyxlhAPcSX2jH0T0=", - "h1:EB9ixYOZrSlYD7wtJxf88qwoyyWrlKDKxhzaCLIb3t4=", - "h1:OgdIUAQDtJBxlKjoPgChD1w57vl6hm6PyJHiBYgsgQA=", - "h1:zLmFaFw5LptpWftHL3O6+7uykOH/0F9AmyVQ7V6kslY=", - "zh:111d5686a1f4ccbc888bb5e2229308bcdd9149898c6af97969fcdfb0e7bd2aa0", - "zh:21b3b7693bd9754c039fd546f03ed09e7510c6189aa5ee37176f144cf8dd5f95", - "zh:25e03c7f025ff4851889537605aa560d2e39bd738b33a5204b8037eb164b475f", - "zh:2817a046f1060e25bf04b0eb78f4e251130bb92dc82ec1264ce156dc9bf78e67", - "zh:2d318d674c3ec9dbd97ddb10b12ad4827be4f508c43ba2ae1e0523baa9e367e3", - "zh:2f07ab356718267299e10b6072472ded29d82753883027bf43bcd687ac72feb2", - "zh:32307e67f83bc0dc94d38cfcd23d782166a09e0e975e2a5aa7d7a3e7ca5d3da8", - "zh:4ce94853264097dd7f4542b3cfd18d2b98b06d23321db45d5e384ea275a57f63", - "zh:869656c41cc7c7412f213e488f98167cff61deafcb8cf245d25d056e8dfdc263", - "zh:8fd8c814e9d8edf152552047db23bf5b5d63f22e6b0b5d47b2af851376e99349", - "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", - "zh:9cbc02ceef9bd469da497a1e7065ff984bdacfbe919ac3cce804a86c13b6e2c6", - "zh:9ea55dda2767acfc1f6337fc7d29b1d4d79d6f8f04871f8ad99a6078d2865994", - "zh:d7149df0819fb57a160489db45d33951765b8f0118daa3b4cd549a0135bc97a1", - "zh:e5819937bb7043d08c9829b32d52d9fb55a5b9a4d8d55d550d47a3d7392db546", - "zh:f93bc38dbc0ad53842303f30eec7a22c525c4d56209b54ec33a8d375cfc4e4fd", - ] -} diff --git a/components/terraform/securityhub/README.md b/components/terraform/securityhub/README.md deleted file mode 100644 index 12e55cf3..00000000 --- a/components/terraform/securityhub/README.md +++ /dev/null @@ -1,27 +0,0 @@ -# securityhub - -Enables Security Hub for one account and region with consolidated control findings and subscribes -the standards in `standards`, given as short `/v/` paths. - -## Wiring - -- Instance: none (E5c8): the organization's vendored `aws-security-hub` (delegated administrator in - each `--security` stack) replaced it; this component is deleted in E5c9. -- No finding aggregator: each region's findings stay in that region (the EU stacks' in the EU). -- Depends on `aws-config` (ordering only): most controls evaluate AWS Config recordings. -- Used by: nothing (security-monitoring routes the member hub's findings by a flag). - -## Notes - -- This component is the only owner of the hub. -- `enable_default_standards = true` lets AWS subscribe FSBP v1.0.0 and CIS v1.2.0 itself; those are - filtered out of `standards` so the apply does not subscribe them twice. -- CIS v1.2.0 uses the partition-wide `:::ruleset/` ARN; every other standard `:::standards/`. -- `disabled_security_controls` disables controls per subscribed standard - (`aws_securityhub_standards_control_association`). `fnx-ue2-prod` and `fnx-ec1-prod` disable, - per AWS's "Controls that you might want to disable": the IAM controls and KMS.1/KMS.2 (global - resources; AWS Config records them only in the account's primary region, us-east-1 for prod, - eu-west-1 for prod-eu) and CloudWatch.1-14 (metric filters on the trail's log group, which is in - the account's primary region, us-east-1 for prod, eu-west-1 for prod-eu). An ID not in that - standard fails at apply. - Cloud Posse's `aws-security-hub` has no such input; this is an extension. diff --git a/components/terraform/securityhub/main.tf b/components/terraform/securityhub/main.tf deleted file mode 100644 index 09c098d1..00000000 --- a/components/terraform/securityhub/main.tf +++ /dev/null @@ -1,67 +0,0 @@ -locals { - # Security Hub subscribes these two itself when enable_default_standards is set. - # Subscribing again would collide on apply, so they are dropped from the explicit - # set instead of forcing every caller to know which standards are implicit. - auto_enabled_standards = [ - "aws-foundational-security-best-practices/v/1.0.0", - "cis-aws-foundations-benchmark/v/1.2.0", - ] - - # CIS v1.2.0 predates the regional standards namespace and is the only standard - # addressed through the partition-wide ruleset path. - ruleset_standards = ["cis-aws-foundations-benchmark/v/1.2.0"] - - standards = var.enable ? toset([ - for standard in var.standards : standard - if !(var.enable_default_standards && contains(local.auto_enabled_standards, standard)) - ]) : toset([]) - - standards_arns = { - for standard in distinct(concat(var.standards, local.auto_enabled_standards, keys(var.disabled_security_controls))) : - standard => contains(local.ruleset_standards, standard) ? "arn:aws:securityhub:::ruleset/${standard}" : "arn:aws:securityhub:${var.region}::standards/${standard}" - } - - # One association per (standard, control) in disabled_security_controls. - disabled_control_associations = var.enable ? { - for pair in flatten([ - for standard, ids in var.disabled_security_controls : [ - for id in ids : { standard = standard, security_control_id = id } - ] - ]) : "${pair.standard}|${pair.security_control_id}" => pair - } : {} -} - -resource "aws_securityhub_account" "main" { - count = var.enable ? 1 : 0 - - enable_default_standards = var.enable_default_standards - - # Consolidated findings: one finding per control check rather than one per - # standard, so a control shared by several standards is not reported N times. - control_finding_generator = "SECURITY_CONTROL" - auto_enable_controls = true -} - -resource "aws_securityhub_standards_subscription" "main" { - for_each = local.standards - - depends_on = [aws_securityhub_account.main] - - standards_arn = local.standards_arns[each.value] -} - -# Controls turned off in one standard each (consolidated control findings: -# the association of a security control with a standard). The DR region's -# instance uses it for the controls that check global resources (IAM), which -# AWS says to disable outside the region that records them (AWS Config -# include_global_resource_types, fnx-ue1-prod only). -resource "aws_securityhub_standards_control_association" "disabled" { - for_each = local.disabled_control_associations - - depends_on = [aws_securityhub_account.main, aws_securityhub_standards_subscription.main] - - standards_arn = local.standards_arns[each.value.standard] - security_control_id = each.value.security_control_id - association_status = "DISABLED" - updated_reason = var.disabled_security_controls_reason -} diff --git a/components/terraform/securityhub/outputs.tf b/components/terraform/securityhub/outputs.tf deleted file mode 100644 index de6baa24..00000000 --- a/components/terraform/securityhub/outputs.tf +++ /dev/null @@ -1,14 +0,0 @@ -output "account_id" { - description = "AWS account ID Security Hub is enabled in (null when enable is false)" - value = var.enable ? aws_securityhub_account.main[0].id : null -} - -output "account_arn" { - description = "ARN of the Security Hub account resource (null when enable is false)" - value = var.enable ? aws_securityhub_account.main[0].arn : null -} - -output "subscribed_standards_arns" { - description = "ARNs of the explicitly subscribed standards; excludes the defaults Security Hub enables on its own" - value = [for subscription in aws_securityhub_standards_subscription.main : subscription.standards_arn] -} diff --git a/components/terraform/securityhub/provider.tf b/components/terraform/securityhub/provider.tf deleted file mode 100644 index 6c843dc5..00000000 --- a/components/terraform/securityhub/provider.tf +++ /dev/null @@ -1,7 +0,0 @@ -provider "aws" { - region = var.region - - default_tags { - tags = var.tags - } -} diff --git a/components/terraform/securityhub/tests/securityhub.tftest.hcl b/components/terraform/securityhub/tests/securityhub.tftest.hcl deleted file mode 100644 index 15c99aa5..00000000 --- a/components/terraform/securityhub/tests/securityhub.tftest.hcl +++ /dev/null @@ -1,66 +0,0 @@ -# Mock-provider tests: no AWS credentials, no network. Run from the component -# directory with `terraform init -backend=false && terraform test`. - -mock_provider "aws" {} - -variables { - region = "us-east-2" - standards = ["pci-dss/v/3.2.1"] - tags = { - Environment = "ue2" - } -} - -run "nothing_disabled_by_default" { - command = plan - - assert { - condition = length(aws_securityhub_standards_control_association.disabled) == 0 - error_message = "No control is disabled unless disabled_security_controls lists it." - } -} - -run "global_resource_controls_are_disabled_per_standard" { - command = plan - - variables { - disabled_security_controls = { - "cis-aws-foundations-benchmark/v/1.2.0" = ["IAM.1"] - "pci-dss/v/3.2.1" = ["IAM.1", "IAM.19"] - } - } - - assert { - condition = ( - length(aws_securityhub_standards_control_association.disabled) == 3 - && aws_securityhub_standards_control_association.disabled["cis-aws-foundations-benchmark/v/1.2.0|IAM.1"].standards_arn == "arn:aws:securityhub:::ruleset/cis-aws-foundations-benchmark/v/1.2.0" - && aws_securityhub_standards_control_association.disabled["pci-dss/v/3.2.1|IAM.19"].standards_arn == "arn:aws:securityhub:us-east-2::standards/pci-dss/v/3.2.1" - && aws_securityhub_standards_control_association.disabled["pci-dss/v/3.2.1|IAM.19"].association_status == "DISABLED" - ) - error_message = "Each (standard, control) pair must become one DISABLED association with the standard's ARN." - } -} - -run "an_unsubscribed_standard_is_rejected" { - command = plan - - variables { - disabled_security_controls = { - "nist-800-53/v/5.0.0" = ["IAM.1"] - } - } - - expect_failures = [var.disabled_security_controls] -} - -run "a_malformed_control_id_is_rejected" { - command = plan - - variables { - disabled_security_controls = { - "pci-dss/v/3.2.1" = ["PCI.IAM.1"] - } - } - - expect_failures = [var.disabled_security_controls] -} diff --git a/components/terraform/securityhub/variables.tf b/components/terraform/securityhub/variables.tf deleted file mode 100644 index 1fcfcbd6..00000000 --- a/components/terraform/securityhub/variables.tf +++ /dev/null @@ -1,69 +0,0 @@ -variable "region" { - type = string - description = "AWS region" - - validation { - condition = can(regex("^[a-z]{2}(-[a-z]+)+-\\d+$", var.region)) - error_message = "The region must be a valid AWS region name (e.g., us-east-1, eu-west-1)." - } -} - -variable "tags" { - type = map(string) - description = "Tags to apply to resources; must include Environment (used in resource names)" - - validation { - condition = trimspace(lookup(var.tags, "Environment", "")) != "" - error_message = "tags must include a non-empty Environment value." - } -} - -variable "enable" { - type = bool - description = "Enable Security Hub in this account and region" - default = true -} - -variable "enable_default_standards" { - type = bool - description = "Let Security Hub subscribe its default standards (AWS Foundational Security Best Practices v1.0.0 and CIS AWS Foundations Benchmark v1.2.0). Those two are then skipped in `standards` to avoid a duplicate subscription." - default = true -} - -variable "disabled_security_controls" { - type = map(list(string)) - description = "Security controls to disable, by standard (`/v/`, a subscribed one) to the control IDs in it (e.g. IAM.1). For the controls that check global resources outside the region that records them (AWS Security Hub guidance)" - default = {} - nullable = false - - validation { - condition = alltrue([for id in flatten(values(var.disabled_security_controls)) : can(regex("^[A-Za-z0-9]+\\.[0-9]+$", id))]) - error_message = "disabled_security_controls values must be security control IDs such as IAM.1." - } - - # Only a subscribed standard has associations to disable. - validation { - condition = alltrue([ - for standard in keys(var.disabled_security_controls) : - contains(var.standards, standard) || (var.enable_default_standards && contains(["aws-foundational-security-best-practices/v/1.0.0", "cis-aws-foundations-benchmark/v/1.2.0"], standard)) - ]) - error_message = "Every disabled_security_controls key must be a subscribed standard: one of standards, or a default standard with enable_default_standards." - } -} - -variable "disabled_security_controls_reason" { - type = string - description = "updated_reason recorded on each disabled_security_controls association" - default = "Checks a global resource; evaluated in the region that records global resources" -} - -variable "standards" { - type = list(string) - description = "Standards to subscribe to, as `/v/` (e.g. `pci-dss/v/3.2.1`). The region and partition are added when building the ARN." - default = [] - - validation { - condition = alltrue([for standard in var.standards : can(regex("^[a-z0-9]+(-[a-z0-9]+)*/v/[0-9]+\\.[0-9]+\\.[0-9]+$", standard))]) - error_message = "Each standard must be a short path of the form /v/.., not a full ARN." - } -} diff --git a/components/terraform/securityhub/versions.tf b/components/terraform/securityhub/versions.tf deleted file mode 100644 index 082a8f12..00000000 --- a/components/terraform/securityhub/versions.tf +++ /dev/null @@ -1,10 +0,0 @@ -terraform { - required_version = ">= 1.16.0, < 2.0.0" - - required_providers { - aws = { - source = "hashicorp/aws" - version = "~> 6.65" - } - } -} diff --git a/scripts/plan_sweep_hcl.py b/scripts/plan_sweep_hcl.py index b49f334b..2fb2b4bf 100644 --- a/scripts/plan_sweep_hcl.py +++ b/scripts/plan_sweep_hcl.py @@ -293,8 +293,6 @@ def split_top(inner, seps): 'member_clusters', # aws_route53_zone: the zone's delegation name servers (dns zone_name_servers). 'name_servers', - # aws_inspector2_enabler: the accounts Inspector is enabled in. - 'account_ids', } FN_CALL = re.compile(r'^([a-z][a-z0-9_]*)\(') IDENT = r'[A-Za-z_][A-Za-z0-9_-]*' diff --git a/stacks/catalog/aws-security-hub/defaults.yaml b/stacks/catalog/aws-security-hub/defaults.yaml index 1a90aa25..3e6b7f03 100644 --- a/stacks/catalog/aws-security-hub/defaults.yaml +++ b/stacks/catalog/aws-security-hub/defaults.yaml @@ -45,7 +45,7 @@ # # Owner decision OQ-SH (2026-11-10): Cloud Posse's default standards (AWS # Foundational Security Best Practices v1.0.0 and CIS AWS Foundations 1.2.0) -# org-wide, LOCAL; prod's PCI DSS standard (hand-written securityhub/prod) is +# org-wide, LOCAL; prod's PCI DSS standard (the hand-written securityhub, deleted in E5c9) is # dropped. Dependencies within one residency: root after step 1, org-settings # after root. Controls are AWS Config rules: each member region needs its # aws-config recorder (E5b). @@ -156,7 +156,7 @@ components: - component: aws-security-hub/root stack: '{{ .settings.context.tenant }}-{{ .settings.context.environment }}-root' - # The hand-written securityhub/main-standby's disabled controls (AWS + # The deleted hand-written securityhub standby's disabled controls (AWS # Security Hub User Guide, "Controls that you might want to disable", # controls-to-disable.html), by consolidated control ID, PCI-only IDs out: # AWS Config records IAM in each account's home region only, so the IAM diff --git a/stacks/catalog/guardduty/defaults.yaml b/stacks/catalog/guardduty/defaults.yaml deleted file mode 100644 index 57f3f028..00000000 --- a/stacks/catalog/guardduty/defaults.yaml +++ /dev/null @@ -1,31 +0,0 @@ ---- -################################################## -# Catalog Configuration for Amazon GuardDuty -################################################## -# One detector per account/region, owned by this component (the Cloud Posse -# aws-guardduty model: one component per service). security-monitoring reads -# `detector_id` from here with !terraform.state and never creates a detector. -# -# Protection plans follow the Cloud Posse aws-guardduty defaults: S3 data -# events on, EKS audit logs and EBS malware scanning off. Those two bill per -# event / per GB scanned, so they are opt-in per stack (prod turns them on). -# The detector itself bills on CloudTrail management events, VPC flow logs -# and DNS logs analysed. - -components: - terraform: - guardduty/defaults: - metadata: - component: guardduty - type: abstract - vars: - enable: true - enable_s3_protection: true - enable_kubernetes_protection: false - enable_malware_protection: false - # Free: only how often updates to EXISTING findings are re-published. - # New findings reach EventBridge within minutes regardless. - finding_publishing_frequency: "FIFTEEN_MINUTES" - auto_archive_filter: [] - tags: - Component: "GuardDuty" diff --git a/stacks/catalog/guardduty/main-prod.yaml b/stacks/catalog/guardduty/main-prod.yaml deleted file mode 100644 index ed47e34d..00000000 --- a/stacks/catalog/guardduty/main-prod.yaml +++ /dev/null @@ -1,22 +0,0 @@ ---- -# ============================================================================= -# guardduty/main in the prod primary stacks: the region's detector -# ============================================================================= -# The production settings (catalog/guardduty/prod): EKS and malware protection -# on, port scans auto-archived. The same shell as main-standby.yaml, kept as -# its own flavor (one file per group). -# ============================================================================= - -import: - - catalog/guardduty/prod - -components: - terraform: - # ========================================================================== - # GuardDuty - owns the detector (security-monitoring only consumes it). - # ========================================================================== - guardduty/main: - metadata: - component: guardduty - inherits: - - guardduty/prod diff --git a/stacks/catalog/guardduty/main-standby.yaml b/stacks/catalog/guardduty/main-standby.yaml deleted file mode 100644 index 87a8b50b..00000000 --- a/stacks/catalog/guardduty/main-standby.yaml +++ /dev/null @@ -1,18 +0,0 @@ ---- -# ============================================================================= -# guardduty/main in the DR warm standby stacks -# ============================================================================= -# This region's detector, with the production settings (catalog/guardduty/prod) -# of the primary stack it stands by for. -# ============================================================================= - -import: - - catalog/guardduty/prod - -components: - terraform: - guardduty/main: - metadata: - component: guardduty - inherits: - - guardduty/prod diff --git a/stacks/catalog/guardduty/main.yaml b/stacks/catalog/guardduty/main.yaml deleted file mode 100644 index add0e16e..00000000 --- a/stacks/catalog/guardduty/main.yaml +++ /dev/null @@ -1,23 +0,0 @@ ---- -# ============================================================================= -# guardduty/main in the nonprod stacks: the region's detector -# ============================================================================= -# The catalog defaults (guardduty/defaults), not the production plans -# (guardduty/prod). -# ============================================================================= - -import: - - catalog/guardduty/defaults - -components: - terraform: - # ========================================================================== - # GuardDuty - owns the detector (security-monitoring only consumes it). - # Catalog defaults: S3 protection on; EKS audit logs and EBS malware - # scanning stay off in non-prod to avoid per-event/per-GB charges. - # ========================================================================== - guardduty/main: - metadata: - component: guardduty - inherits: - - guardduty/defaults diff --git a/stacks/catalog/guardduty/prod.yaml b/stacks/catalog/guardduty/prod.yaml deleted file mode 100644 index 93e94de8..00000000 --- a/stacks/catalog/guardduty/prod.yaml +++ /dev/null @@ -1,25 +0,0 @@ ---- -import: - - catalog/guardduty/defaults - -# Production detector settings, shared by every prod stack's guardduty/main -# (the prod primaries and the DR standbys): prod turns on the protection -# plans the catalog leaves -# opt-in (EKS audit logs and EBS malware scanning bill per event / per GB -# scanned) and auto-archives port-scan noise. -components: - terraform: - guardduty/prod: - metadata: - component: guardduty - type: abstract - inherits: - - guardduty/defaults - vars: - enable_kubernetes_protection: true - enable_malware_protection: true - auto_archive_filter: - - severity: 1 - criteria: - type: - - "Recon:EC2/Portscan" diff --git a/stacks/catalog/inspector2/defaults.yaml b/stacks/catalog/inspector2/defaults.yaml deleted file mode 100644 index b9f426b0..00000000 --- a/stacks/catalog/inspector2/defaults.yaml +++ /dev/null @@ -1,28 +0,0 @@ ---- -################################################## -# Catalog Configuration for Amazon Inspector -################################################## -# Inspector for one account/region, owned by this component (the Cloud Posse -# aws-inspector2 model: one component per service). security-monitoring reads -# `account_id` from here with !terraform.state and routes Inspector findings -# only while it is set, so it never enables Inspector itself. -# -# Off by default: Inspector bills per EC2 instance, container image and Lambda -# function scanned. A stack opts in with `enabled: true`; the auto_enable_* -# flags (Cloud Posse defaults: EC2, ECR and Lambda on, Lambda code off) pick -# what is scanned. - -components: - terraform: - inspector2/defaults: - metadata: - component: inspector2 - type: abstract - vars: - enabled: false - auto_enable_ec2: true - auto_enable_ecr: true - auto_enable_lambda: true - auto_enable_lambda_code: false - tags: - Component: "Inspector" diff --git a/stacks/catalog/inspector2/main.yaml b/stacks/catalog/inspector2/main.yaml deleted file mode 100644 index 25ec7958..00000000 --- a/stacks/catalog/inspector2/main.yaml +++ /dev/null @@ -1,23 +0,0 @@ ---- -# ============================================================================= -# inspector2/main in every environment stack: Inspector -# ============================================================================= -# The catalog defaults as they are (inspector2/defaults). Nonprod, the prod -# primaries and the DR standbys all import this file, so a change here changes -# the DR standbys too; a stack that differs sets vars in its own file. -# ============================================================================= - -import: - - catalog/inspector2/defaults - -components: - terraform: - # ========================================================================== - # Amazon Inspector - owns the enabler (security-monitoring only routes its - # findings). Off, as in the catalog: Inspector bills per resource scanned. - # ========================================================================== - inspector2/main: - metadata: - component: inspector2 - inherits: - - inspector2/defaults diff --git a/stacks/catalog/securityhub/defaults.yaml b/stacks/catalog/securityhub/defaults.yaml deleted file mode 100644 index 63f6c0d2..00000000 --- a/stacks/catalog/securityhub/defaults.yaml +++ /dev/null @@ -1,30 +0,0 @@ ---- -################################################## -# Catalog Configuration for AWS Security Hub -################################################## -# Security Hub for one account/region, owned by this component (the Cloud -# Posse aws-security-hub model: one component per service). security-monitoring -# reads `account_arn` from here with !terraform.state and never enables a hub. -# -# The default standards (AWS Foundational Security Best Practices v1.0.0 and -# CIS AWS Foundations Benchmark v1.2.0) are the baseline everywhere, since the -# compliance-check workflow reports on them. Security Hub bills per control -# check, so extra standards such as PCI DSS are added per stack (prod only). - -components: - terraform: - securityhub/defaults: - metadata: - component: securityhub - type: abstract - # Security Hub's FSBP and CIS controls are AWS Config rules: without a - # recorder they report no data. Ordering only (no state is read). - dependencies: - components: - - component: aws-config - vars: - enable: true - enable_default_standards: true - standards: [] - tags: - Component: "SecurityHub" diff --git a/stacks/catalog/securityhub/main-prod.yaml b/stacks/catalog/securityhub/main-prod.yaml deleted file mode 100644 index 0555102c..00000000 --- a/stacks/catalog/securityhub/main-prod.yaml +++ /dev/null @@ -1,23 +0,0 @@ ---- -# ============================================================================= -# securityhub/main in the prod primary stacks: the region's hub -# ============================================================================= -# The production standards (catalog/securityhub/prod): PCI DSS on top of the -# default ones. A primary's region records the account's global resources -# (aws-config) and holds the trail's log group (cloudtrail), so, -# unlike main-standby.yaml, no IAM, KMS or CloudWatch control is disabled. -# ============================================================================= - -import: - - catalog/securityhub/prod - -components: - terraform: - # ========================================================================== - # Security Hub - owns the hub (security-monitoring only consumes it). - # ========================================================================== - securityhub/main: - metadata: - component: securityhub - inherits: - - securityhub/prod diff --git a/stacks/catalog/securityhub/main-region.yaml b/stacks/catalog/securityhub/main-region.yaml deleted file mode 100644 index 4862f779..00000000 --- a/stacks/catalog/securityhub/main-region.yaml +++ /dev/null @@ -1,48 +0,0 @@ ---- -# ============================================================================= -# securityhub/main in a nonprod account's second region -# ============================================================================= -# The scaffold's nonprod stack with account_singletons=no: the catalog -# defaults (securityhub/defaults; no PCI DSS in non-prod), as in main.yaml, -# minus the controls this region cannot evaluate, as main-standby.yaml does -# for the DR standbys. The account's singletons are its us-east-1 home -# stack's: there AWS Config records the global resources (IAM) and the -# account's one multi-region trail delivers to its log group, where -# security-monitoring/main runs the CIS metric filters. Here the recorder -# skips global types and there is no trail log group -# (catalog/security-monitoring/main-region), so those controls would stay -# FAILED or unevaluated forever. -# ============================================================================= - -import: - - catalog/securityhub/defaults - -components: - terraform: - securityhub/main: - metadata: - component: securityhub - inherits: - - securityhub/defaults - vars: - # Controls the home stack evaluates, disabled here per standard. AWS - # Security Hub User Guide, "Controls that you might want to disable" - # (https://docs.aws.amazon.com/securityhub/latest/userguide/controls-to-disable.html): - # - global resources: AWS Config records IAM in the home region only - # (aws-config), so the IAM controls and KMS.1/KMS.2 (they check IAM - # policies, kms-controls.html) are disabled in every other region; - # - CloudWatch.1-14 (CIS 1.2.0 section 3): log metric filters on the - # trail's log group, which exists only in the home region (its - # multi-region trail); here they cannot pass (cloudwatch-controls.html). - # The lists are main-standby.yaml's without PCI DSS (not enabled in - # non-prod). - disabled_security_controls: - "aws-foundational-security-best-practices/v/1.0.0": - ["IAM.1", "IAM.2", "IAM.3", "IAM.4", "IAM.5", "IAM.6", "IAM.7", "IAM.8", "IAM.21", - "KMS.1", "KMS.2"] - "cis-aws-foundations-benchmark/v/1.2.0": - ["IAM.1", "IAM.2", "IAM.3", "IAM.4", "IAM.5", "IAM.6", "IAM.8", "IAM.9", "IAM.11", "IAM.12", - "IAM.13", "IAM.14", "IAM.15", "IAM.16", "IAM.17", "IAM.18", "IAM.20", - "CloudWatch.1", "CloudWatch.2", "CloudWatch.3", "CloudWatch.4", "CloudWatch.5", - "CloudWatch.6", "CloudWatch.7", "CloudWatch.8", "CloudWatch.9", "CloudWatch.10", - "CloudWatch.11", "CloudWatch.12", "CloudWatch.13", "CloudWatch.14"] diff --git a/stacks/catalog/securityhub/main-standby.yaml b/stacks/catalog/securityhub/main-standby.yaml deleted file mode 100644 index 8f1d5660..00000000 --- a/stacks/catalog/securityhub/main-standby.yaml +++ /dev/null @@ -1,42 +0,0 @@ ---- -# ============================================================================= -# securityhub/main in the DR warm standby stacks -# ============================================================================= -# This region's hub, with the production settings (catalog/securityhub/prod) -# of the primary stack it stands by for (settings.dr.standby_of). -# ============================================================================= - -import: - - catalog/securityhub/prod - -components: - terraform: - securityhub/main: - metadata: - component: securityhub - inherits: - - securityhub/prod - vars: - # Controls the primary evaluates, disabled here per standard. AWS - # Security Hub User Guide, "Controls that you might want to disable" - # (https://docs.aws.amazon.com/securityhub/latest/userguide/controls-to-disable.html): - # - global resources: AWS Config records IAM in the primary's region - # only (aws-config), so the IAM controls and KMS.1/KMS.2 (they - # check IAM policies, kms-controls.html) are disabled in every - # other region; - # - CloudWatch.1-14 (CIS 1.2.0 section 3, PCI CW.1): log metric filters - # on the trail's log group, which exists only in the primary's - # region (its multi-region trail); in other regions they cannot - # pass (cloudwatch-controls.html). - disabled_security_controls: - "aws-foundational-security-best-practices/v/1.0.0": - ["IAM.1", "IAM.2", "IAM.3", "IAM.4", "IAM.5", "IAM.6", "IAM.7", "IAM.8", "IAM.21", - "KMS.1", "KMS.2"] - "cis-aws-foundations-benchmark/v/1.2.0": - ["IAM.1", "IAM.2", "IAM.3", "IAM.4", "IAM.5", "IAM.6", "IAM.8", "IAM.9", "IAM.11", "IAM.12", - "IAM.13", "IAM.14", "IAM.15", "IAM.16", "IAM.17", "IAM.18", "IAM.20", - "CloudWatch.1", "CloudWatch.2", "CloudWatch.3", "CloudWatch.4", "CloudWatch.5", - "CloudWatch.6", "CloudWatch.7", "CloudWatch.8", "CloudWatch.9", "CloudWatch.10", - "CloudWatch.11", "CloudWatch.12", "CloudWatch.13", "CloudWatch.14"] - "pci-dss/v/3.2.1": - ["IAM.1", "IAM.2", "IAM.4", "IAM.6", "IAM.8", "IAM.9", "IAM.10", "IAM.19", "CloudWatch.1"] diff --git a/stacks/catalog/securityhub/main.yaml b/stacks/catalog/securityhub/main.yaml deleted file mode 100644 index e4ffaedf..00000000 --- a/stacks/catalog/securityhub/main.yaml +++ /dev/null @@ -1,22 +0,0 @@ ---- -# ============================================================================= -# securityhub/main in the nonprod stacks: the region's hub -# ============================================================================= -# The catalog defaults (securityhub/defaults), not the production standards -# (securityhub/prod). -# ============================================================================= - -import: - - catalog/securityhub/defaults - -components: - terraform: - # ========================================================================== - # Security Hub - owns the hub (security-monitoring only consumes it). - # Default standards (AWS FSBP + CIS 1.2.0) only; no PCI DSS in non-prod. - # ========================================================================== - securityhub/main: - metadata: - component: securityhub - inherits: - - securityhub/defaults diff --git a/stacks/catalog/securityhub/prod.yaml b/stacks/catalog/securityhub/prod.yaml deleted file mode 100644 index 2f2c8737..00000000 --- a/stacks/catalog/securityhub/prod.yaml +++ /dev/null @@ -1,22 +0,0 @@ ---- -import: - - catalog/securityhub/defaults - -# Production hub settings, shared by every prod stack's securityhub/main -# (the prod primaries and the DR standbys): PCI DSS on top of -# the default standards. AWS auto-subscribes AWS-FSBP and CIS under -# enable_default_standards (catalog default); listing them here as well -# collides at apply, so `standards` carries only what AWS does not enable. -# A stack outside the region that records global resources adds its -# disabled_security_controls: main-standby.yaml adds them for the DR standbys. -components: - terraform: - securityhub/prod: - metadata: - component: securityhub - type: abstract - inherits: - - securityhub/defaults - vars: - standards: - - "pci-dss/v/3.2.1" diff --git a/workflows/deploy-full-stack.yaml b/workflows/deploy-full-stack.yaml index 16501fc7..fd053330 100644 --- a/workflows/deploy-full-stack.yaml +++ b/workflows/deploy-full-stack.yaml @@ -252,10 +252,10 @@ workflows: - name: plan-security type: atmos command: >- - terraform plan --query '.metadata.component == "secretsmanager" or .metadata.component == "guardduty" - or .metadata.component == "securityhub" or .metadata.component == "aws-cloudtrail" + terraform plan --query '.metadata.component == "secretsmanager" + or .metadata.component == "aws-cloudtrail" or .metadata.component == "aws-config" or .metadata.component == "cognito" - or .metadata.component == "apigateway-account" or .metadata.component == "inspector2" or (.metadata.component == "access-analyzer" and .vars.organizations_delegated_administrator_enabled == true) + or .metadata.component == "apigateway-account" or (.metadata.component == "access-analyzer" and .vars.organizations_delegated_administrator_enabled == true) or (.metadata.component == "aws-guardduty" and .vars.admin_delegated != true) or (.metadata.component == "aws-security-hub" and .vars.admin_delegated != true) or (.metadata.component == "aws-inspector2" and .vars.admin_delegated != true) @@ -271,10 +271,9 @@ workflows: type: atmos command: >- terraform deploy --from-plan --query '.metadata.component == "secretsmanager" - or .metadata.component == "guardduty" or .metadata.component == "securityhub" or .metadata.component == "aws-cloudtrail" or .metadata.component == "aws-config" or .metadata.component == "cognito" or .metadata.component == "apigateway-account" - or .metadata.component == "inspector2" or (.metadata.component == "access-analyzer" and .vars.organizations_delegated_administrator_enabled == true) + or (.metadata.component == "access-analyzer" and .vars.organizations_delegated_administrator_enabled == true) or (.metadata.component == "aws-guardduty" and .vars.admin_delegated != true) or (.metadata.component == "aws-security-hub" and .vars.admin_delegated != true) or (.metadata.component == "aws-inspector2" and .vars.admin_delegated != true) @@ -658,10 +657,10 @@ workflows: - name: plan type: atmos command: >- - terraform plan --query '.metadata.component == "secretsmanager" or .metadata.component == "guardduty" - or .metadata.component == "securityhub" or .metadata.component == "aws-cloudtrail" + terraform plan --query '.metadata.component == "secretsmanager" + or .metadata.component == "aws-cloudtrail" or .metadata.component == "aws-config" or .metadata.component == "cognito" - or .metadata.component == "apigateway-account" or .metadata.component == "inspector2" or (.metadata.component == "access-analyzer" and .vars.organizations_delegated_administrator_enabled == true) + or .metadata.component == "apigateway-account" or (.metadata.component == "access-analyzer" and .vars.organizations_delegated_administrator_enabled == true) or (.metadata.component == "aws-guardduty" and .vars.admin_delegated != true) or (.metadata.component == "aws-security-hub" and .vars.admin_delegated != true) or (.metadata.component == "aws-inspector2" and .vars.admin_delegated != true) @@ -677,10 +676,9 @@ workflows: type: atmos command: >- terraform deploy --from-plan --query '.metadata.component == "secretsmanager" - or .metadata.component == "guardduty" or .metadata.component == "securityhub" or .metadata.component == "aws-cloudtrail" or .metadata.component == "aws-config" or .metadata.component == "cognito" or .metadata.component == "apigateway-account" - or .metadata.component == "inspector2" or (.metadata.component == "access-analyzer" and .vars.organizations_delegated_administrator_enabled == true) + or (.metadata.component == "access-analyzer" and .vars.organizations_delegated_administrator_enabled == true) or (.metadata.component == "aws-guardduty" and .vars.admin_delegated != true) or (.metadata.component == "aws-security-hub" and .vars.admin_delegated != true) or (.metadata.component == "aws-inspector2" and .vars.admin_delegated != true) diff --git a/workflows/scripts/common/check-first-deploy-inputs.py b/workflows/scripts/common/check-first-deploy-inputs.py index 033ea59d..2e888484 100644 --- a/workflows/scripts/common/check-first-deploy-inputs.py +++ b/workflows/scripts/common/check-first-deploy-inputs.py @@ -111,13 +111,11 @@ # workload account (a stage's, or prod-eu). CORE_ACCOUNTS = ("root", "audit", "security", "network", "identity", "artifacts") # Components (metadata.component) that read the core accounts: the Cloud Posse identity and security -# components Wave E brings in (E4, E5), and today's account-level security components that E5 turns -# org-wide. Deploying one needs real core account IDs. Not the accounts layer (aws-organization, +# components Wave E brings in (E4, E5). Deploying one needs real core account IDs. Not the accounts layer (aws-organization, # aws-organizational-unit, aws-scp, aws-account: deploy-accounts.yaml), which creates the core accounts # and reads none of their IDs, nor aws-account-settings, which configures only its own account. MAP_CONSUMERS = frozenset({ "aws-identity-center", "aws-teams", "aws-team-roles", "access-analyzer", - "guardduty", "securityhub", "inspector2", # The audit buckets' delivery policies and the Config bucket key's policy # list every account of their residency (E5a4). "aws-cloudtrail-bucket", "aws-config-bucket", diff --git a/workflows/scripts/common/test_check_first_deploy_inputs.py b/workflows/scripts/common/test_check_first_deploy_inputs.py index e3927eff..dd244658 100644 --- a/workflows/scripts/common/test_check_first_deploy_inputs.py +++ b/workflows/scripts/common/test_check_first_deploy_inputs.py @@ -400,7 +400,7 @@ def test_distinct_real_core_accounts_pass(self): self.assertEqual(self.core_errors(), []) def test_placeholder_core_accounts_fail_for_a_map_consumer(self): - found = errors(self.with_map("guardduty", audit="123456789012", identity="000000000000"), ["fnx-ue1-dev"]) + found = errors(self.with_map("aws-guardduty", audit="123456789012", identity="000000000000"), ["fnx-ue1-dev"]) self.assertEqual(sorted(f.key.rsplit(".", 1)[-1] for f in found), ["audit", "identity"]) self.assertTrue(all(f.stack == "repository" and f.row == "Account IDs" for f in found)) @@ -460,7 +460,7 @@ def test_no_account_map_fails(self): self.assertEqual([f.detail for f in errors(stacks)], ["no account map in any deployable stack"]) def test_an_empty_map_fails(self): - stacks = {"fnx-ue1-dev": stack("dev", "222222222222", main={"component": "guardduty", "accounts": {}})} + stacks = {"fnx-ue1-dev": stack("dev", "222222222222", main={"component": "aws-guardduty", "accounts": {}})} self.assertEqual({f.detail for f in errors(stacks)}, {"core account missing"}) def test_bad_core_account_fails_main_and_leads_warn(self):