Setting Up AWS for ISO 27001 Certification
This documents how I set up AWS infrastructure to meet ISO 27001 requirements using AWS Config for rule enforcement and Security Hub for centralized compliance reporting.
Architecture Overview
AWS Config Rules for ISO 27001
The key controls mapped to ISO 27001 Annex A:
# A.9 - Access Control
resource "aws_config_config_rule" "iam_root_access_key" {
name = "iam-root-access-key-check"
source {
owner = "AWS"
source_identifier = "IAM_ROOT_ACCESS_KEY_CHECK"
}
}
resource "aws_config_config_rule" "mfa_enabled" {
name = "iam-user-mfa-enabled"
source {
owner = "AWS"
source_identifier = "IAM_USER_MFA_ENABLED"
}
}
resource "aws_config_config_rule" "no_unrestricted_ssh" {
name = "restricted-ssh"
source {
owner = "AWS"
source_identifier = "INCOMING_SSH_DISABLED"
}
}
# A.10 - Cryptography
resource "aws_config_config_rule" "s3_encryption" {
name = "s3-bucket-server-side-encryption-enabled"
source {
owner = "AWS"
source_identifier = "S3_BUCKET_SERVER_SIDE_ENCRYPTION_ENABLED"
}
}
resource "aws_config_config_rule" "rds_encryption" {
name = "rds-storage-encrypted"
source {
owner = "AWS"
source_identifier = "RDS_STORAGE_ENCRYPTED"
}
}
resource "aws_config_config_rule" "ebs_encryption" {
name = "encrypted-volumes"
source {
owner = "AWS"
source_identifier = "ENCRYPTED_VOLUMES"
}
}
# A.12 - Operations Security
resource "aws_config_config_rule" "cloudtrail_enabled" {
name = "cloudtrail-enabled"
source {
owner = "AWS"
source_identifier = "CLOUD_TRAIL_ENABLED"
}
}
resource "aws_config_config_rule" "vpc_flow_logs" {
name = "vpc-flow-logs-enabled"
source {
owner = "AWS"
source_identifier = "VPC_FLOW_LOGS_ENABLED"
}
}
# A.13 - Communications Security
resource "aws_config_config_rule" "alb_https" {
name = "alb-http-to-https-redirection-check"
source {
owner = "AWS"
source_identifier = "ALB_HTTP_TO_HTTPS_REDIRECTION_CHECK"
}
}
Security Hub Configuration
Security Hub aggregates findings and maps them to compliance frameworks:
resource "aws_securityhub_account" "main" {}
# Enable ISO 27001 standard
resource "aws_securityhub_standards_subscription" "iso27001" {
standards_arn = "arn:aws:securityhub:${var.region}::standards/iso-27001/v/2022/1.0.0"
depends_on = [aws_securityhub_account.main]
}
# Enable AWS Foundational Security Best Practices
resource "aws_securityhub_standards_subscription" "aws_foundational" {
standards_arn = "arn:aws:securityhub:${var.region}::standards/aws-foundational-security-best-practices/v/1.0.0"
depends_on = [aws_securityhub_account.main]
}
# Automated findings notification
resource "aws_cloudwatch_event_rule" "security_hub_findings" {
name = "security-hub-high-severity"
description = "Alert on HIGH and CRITICAL Security Hub findings"
event_pattern = jsonencode({
source = ["aws.securityhub"]
detail-type = ["Security Hub Findings - Imported"]
detail = {
findings = {
Severity = {
Label = ["HIGH", "CRITICAL"]
}
}
}
})
}
resource "aws_cloudwatch_event_target" "sns" {
rule = aws_cloudwatch_event_rule.security_hub_findings.name
target_id = "security-alerts"
arn = aws_sns_topic.security_alerts.arn
}
CloudTrail for Audit Logging
Every API call is logged and stored in a dedicated audit S3 bucket with integrity validation:
resource "aws_cloudtrail" "audit" {
name = "iso27001-audit-trail"
s3_bucket_name = aws_s3_bucket.audit_logs.id
include_global_service_events = true
is_multi_region_trail = true
enable_log_file_validation = true
event_selector {
read_write_type = "All"
include_management_events = true
data_resource {
type = "AWS::S3::Object"
values = ["arn:aws:s3"]
}
}
cloud_watch_logs_group_arn = "${aws_cloudwatch_log_group.cloudtrail.arn}:*"
cloud_watch_logs_role_arn = aws_iam_role.cloudtrail_cloudwatch.arn
}
resource "aws_s3_bucket" "audit_logs" {
bucket = "company-iso27001-audit-logs"
}
resource "aws_s3_bucket_versioning" "audit_logs" {
bucket = aws_s3_bucket.audit_logs.id
versioning_configuration {
status = "Enabled"
}
}
resource "aws_s3_bucket_lifecycle_configuration" "audit_logs" {
bucket = aws_s3_bucket.audit_logs.id
rule {
id = "archive-old-logs"
status = "Enabled"
transition {
days = 90
storage_class = "GLACIER"
}
expiration {
days = 2555 # 7 years retention for compliance
}
}
}
ISO 27001 Control Mapping
| ISO 27001 Control | AWS Service | Implementation |
|---|---|---|
| A.5 - Information Security Policies | IAM, SCP | Service Control Policies at org level |
| A.9 - Access Control | IAM, MFA | Least privilege + mandatory MFA |
| A.10 - Cryptography | KMS, ACM | Encryption at rest and in transit |
| A.12 - Operations Security | CloudTrail, Config | Full audit trail + compliance rules |
| A.13 - Communications Security | VPC, Security Groups | Network segmentation + flow logs |
| A.16 - Incident Management | GuardDuty, Security Hub | Automated detection and alerting |
| A.18 - Compliance | Config, Security Hub | Continuous compliance monitoring |
Results
- Achieved ISO 27001 compliance readiness with automated evidence collection
- 90+ Config rules enforcing security controls continuously
- < 24 hour remediation for high-severity findings via automated alerting
- Zero audit findings from external auditors on infrastructure controls