Skip to content

stigian/terraform-aws-cspm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

terraform-aws-cspm

This module configures Cloud Security Posture Management (CSPM) in support of the DoD Zero Trust strategy. The design relies on the AWS Control Tower Landing Zone baseline version 3.3 as a starting point. Additional services are delegated, activated, and configured across the entire AWS Organization including:

  • GuardDuty
  • Detective
  • Inspector
  • Security Hub
  • Config
  • CloudTrail
  • IAM Identity Center

AWS Security Services Best Practices serves as a guide for the default configuration. Configurations for non-security services like AWS Config are also included to ensure compliance with the DoD Zero Trust strategy.

Service Descriptions

GuardDuty

Amazon GuardDuty is a threat detection service that continuously monitors for malicious activity and unauthorized behavior to protect your AWS accounts and workloads. GuardDuty is enabled in all accounts in the AWS Organization. The audit account is the master account for GuardDuty. Member accounts are enabled and configured to send findings to the master account.

Detective

Amazon Detective makes it easy to analyze, investigate, and quickly identify the root cause of security findings or suspicious activities. Detective automatically collects log data from your AWS resources and uses machine learning, statistical analysis, and graph theory to help you visualize and conduct faster and more efficient security investigations.

Inspector

Amazon Inspector is a vulnerability management service that continuously monitors your AWS workloads for software vulnerabilities and unintended network exposure. Amazon Inspector automatically discovers and scans running Amazon EC2 instances, container images in Amazon Elastic Container Registry (Amazon ECR), and AWS Lambda functions.

Security Hub

AWS Security Hub provides you with a comprehensive view of your security state within AWS and helps you check your environment against security industry standards and best practices. Security Hub is enabled in all accounts in the AWS Organization. The audit account is the master account for Security Hub. Member accounts are enabled and configured to send findings to the master account.

Config

AWS Config provides a detailed view of the resources associated with your AWS account, including how they are configured, how they are related to one another, and how the configurations and their relationships have changed over time. AWS Config resources provisioned by AWS Control Tower are tagged automatically with aws-control-tower and a value of managed-by-control-tower.

CloudTrail

AWS Control Tower configures AWS CloudTrail to enable centralized logging and auditing for all accounts. With CloudTrail, the management account can review administrative actions and lifecycle events for member accounts.

IAM Identity Center

AWS Control Tower configures IAM Identity Center to provide a centralized view of identity and access management (IAM) activity across all accounts in the AWS Organization. IAM Identity Center provides a single location to view and manage IAM activity, including changes to IAM policies, roles, and users.

Pre-deployment steps

In Govcloud, create and add accounts to the AWS Organization. The accounts do not need to be placed into Organizational Units (OUs) ahead of time. Control Tower will place the log archive and audit accounts into the proper OUs. We recommend moving the hub-and-spoke account to the Sandbox OU after the module has finished provisioning. You may wish to create additional OUs like Production or Development to suit your specific needs. These OUs will inherit the baseline guardrails applied at the root of the Organization. The minimum accounts you need to create are:

  • Management
  • Hub-and-spoke
  • Log archive
  • Audit

Post-deployment steps

GuardDuty

Note

Enabling member accounts is not retroactive, so you must enable them manually.

  1. Login to the audit account
  2. Navigate to Accounts in the left hand pane
  3. Verify every account Status column shows Enabled
  4. If not, select the checkbox next to each account, click Actions, click Add member

Detective

Note

Enabling member accounts is not retroactive, so you must enable them manually.

  1. Login to the audit account
  2. Navigate to Settings -> Account management in the left hand pane
  3. Verify member accounts Status column shows Enabled
  4. If not, simply click the Enable all accounts button

Inspector

No action required.

Control Tower

No action required.

If in the future you need to enroll/onboard new accounts to Control Tower, see these references:

Security Hub

No action required.

Insight categories for Critical and High findings are automatically configured. Depending on your specific security posture you may wish to fine tune the Security Standard controls to reduce noise.

Config

No action required.

CloudTrail

No action required.

IAM Identity Center

No action required.

Control Tower applies a basic configuration for IAM Identity Center in the management account. We choose not to delegate administration of IAM Identity Center to another account, instead leaving it in the management account. This is because the management account is the root account and has the highest level of permissions. We recommend that you do not delegate IAM Identity Center to another account unless you have a specific use case that requires it.

Customizations to IAM Identity Center such as transitioning to an external identity provider may be applied separately. See the AWS docs for more information.

Requirements

Name Version
terraform >= 1.8.0
aws >= 5.0.0
random >= 3.1.0

Providers

Name Version
aws.audit >= 5.0.0
aws.hubandspoke >= 5.0.0
aws.log >= 5.0.0
aws.management >= 5.0.0

Modules

Name Source Version
central_bucket terraform-aws-modules/s3-bucket/aws ~> 4.3
s3_anfw_logs terraform-aws-modules/s3-bucket/aws ~> 4.3
s3_lb_logs terraform-aws-modules/s3-bucket/aws ~> 4.3
s3_org_cloudtrail_logs terraform-aws-modules/s3-bucket/aws ~> 4.3
s3_org_config_logs terraform-aws-modules/s3-bucket/aws ~> 4.3
s3_server_access_logs terraform-aws-modules/s3-bucket/aws ~> 4.3
s3_vpc_flow_logs terraform-aws-modules/s3-bucket/aws ~> 4.3
s3_waf_logs terraform-aws-modules/s3-bucket/aws ~> 4.3

Resources

Name Type
aws_config_organization_conformance_pack.nist_800_53 resource
aws_controltower_landing_zone.this resource
aws_detective_graph.this resource
aws_detective_organization_admin_account.this resource
aws_detective_organization_configuration.this resource
aws_guardduty_detector.audit resource
aws_guardduty_detector.hubandspoke resource
aws_guardduty_detector.log resource
aws_guardduty_detector.management resource
aws_guardduty_organization_admin_account.this resource
aws_guardduty_organization_configuration.this resource
aws_iam_policy.combined_logs_replication resource
aws_iam_policy.hubandspoke_to_central resource
aws_iam_role.combined_logs_replication resource
aws_iam_role.hubandspoke_to_central resource
aws_iam_role_policy_attachment.combined_logs_replication resource
aws_iam_role_policy_attachment.hubandspoke_to_central resource
aws_iam_service_linked_role.audit_agentless_inspector2 resource
aws_iam_service_linked_role.audit_detective resource
aws_iam_service_linked_role.hubandspoke_agentless_inspector2 resource
aws_iam_service_linked_role.hubandspoke_detective resource
aws_iam_service_linked_role.hubandspoke_inspector2 resource
aws_iam_service_linked_role.log_agentless_inspector2 resource
aws_iam_service_linked_role.log_detective resource
aws_iam_service_linked_role.log_inspector2 resource
aws_inspector2_delegated_admin_account.this resource
aws_inspector2_enabler.audit resource
aws_inspector2_member_association.hubandspoke resource
aws_inspector2_member_association.log resource
aws_inspector2_member_association.management resource
aws_inspector2_organization_configuration.this resource
aws_kms_alias.central_log_bucket resource
aws_kms_alias.control_tower resource
aws_kms_alias.hubandspoke_s3 resource
aws_kms_key.central_log_bucket resource
aws_kms_key.control_tower resource
aws_kms_key.hubandspoke_s3 resource
aws_kms_key_policy.central_log_bucket resource
aws_kms_key_policy.control_tower resource
aws_kms_key_policy.hubandspoke_s3 resource
aws_organizations_delegated_administrator.config resource
aws_organizations_delegated_administrator.config_multiaccountsetup resource
aws_organizations_organization.this resource
aws_s3_bucket_replication_configuration.combined_logs_replication resource
aws_securityhub_configuration_policy.this resource
aws_securityhub_configuration_policy_association.root resource
aws_securityhub_insight.critical resource
aws_securityhub_insight.high resource
aws_securityhub_organization_configuration.this resource
aws_caller_identity.audit data source
aws_caller_identity.hubandspoke data source
aws_caller_identity.log data source
aws_caller_identity.management data source
aws_iam_policy_document.anfw_logs data source
aws_iam_policy_document.central_logs_bucket data source
aws_iam_policy_document.cloudtrail_log_delivery data source
aws_iam_policy_document.combined_logs_replication data source
aws_iam_policy_document.config_log_delivery data source
aws_iam_policy_document.hubandspoke_to_central data source
aws_iam_policy_document.s3_assume_role data source
aws_iam_policy_document.s3_vpc_flow_logs data source
aws_iam_policy_document.waf_logs data source
aws_iam_roles.log_sso_admin data source
aws_organizations_organization.hubandspoke data source
aws_organizations_organization.management data source
aws_organizations_organizational_units.this data source
aws_partition.audit data source
aws_partition.hubandspoke data source
aws_partition.log data source
aws_partition.management data source
aws_region.audit data source
aws_region.hubandspoke data source
aws_region.log data source
aws_s3_bucket.ct_logs data source

Inputs

Name Description Type Default Required
account_id_map Mapping of account names to govcloud account IDs. Update the example account
IDs to suit your environment. Account descriptions are:
- management: AWS Management account, usually the first account created
- hubandspoke: AWS Hub-and-Spoke account, created manually
- log: AWS Log Archive account, to be enrolled in AWS Control Tower
- audit: AWS Audit account, to be enrolled in AWS Control Tower

Example:
{
"management" = "111111111111"
"hubandspoke" = "222222222222"
"log" = "333333333333"
"audit" = "444444444444"
}
map(string) n/a yes
aws_organization_id ID for existing AWS Govcloud Organization. string n/a yes
aws_region Home region for Control Tower Landing Zone and tf backend state. string "us-gov-west-1" no
central_bucket_name_prefix Name prefix for S3 bucket in log account where logs are aggregated for all accounts. string "org-central-logs" no
identifier Name of the project or application. string "demo" no
key_admin_arns List of ARNs for additional key administrators who can manage keys in the log archive account. list(string) [] no

Outputs

Name Description
central_bucket_arn n/a
central_bucket_kms_key_arn n/a

About

Cloud Security Posture Management (CSPM) baseline for Zero Trust

Resources

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages