Shayl.Taveras
portfolio / projects / compliant-s3
← back to portfolio
// Project Walkthrough · 02
Compliant S3 Primitive — NIST 800-53

A Terraform module that enforces five NIST 800-53 controls directly into every AWS S3 bucket it provisions. After apply, terraform show -json produces machine-readable compliance evidence an auditor can traverse without a console login.

terraform aws s3 nist 800-53 kms · iac-as-evidence · hipaa
Problem Statement
01

Every auditor eventually asks: "Show me that your S3 buckets are encrypted, access-controlled, and logging." The typical answer is a console screenshot taken that morning — a point-in-time artifact with no chain of custody and no way to prove the configuration was in place before the audit started.

This primitive inverts that. The Terraform state is the evidence. Because the controls are defined in code and applied through a plan-and-apply cycle, the configuration is version-controlled, repeatable, and machine-readable.

Architecture Decision
02

The core insight is that Terraform both enforces the control and generates the audit artifact in a single step. There is no gap between what was deployed and what the evidence says.

// iac as evidence
One Step: Deploy and Attest
terraform apply enforces the controls. terraform show -json produces the evidence. Both happen in the same run — the state file is the audit artifact.
// kms encryption
Customer-Managed Keys (SC-28)
AES-256 via KMS with customer-managed keys. Key ARN, rotation schedule, and policy all surfaced in state — direct evidence of encryption at rest.
// access control
Public Access Block (AC-3)
All four public access block settings enforced at the resource level. No bucket provisioned by this module can be made public.
// audit logging
Dedicated Log Bucket (AU-3, AU-6)
Server access logging enabled and pointed at a dedicated log bucket. Enforced in the module — consumers cannot disable it.
Controls Enforced
03
Control IDControl NameHow It's Enforced
SC-28Protection of Information at RestAES-256 encryption via KMS with customer-managed key — fixed resource attribute
AC-3Access EnforcementAll four S3 public access block settings enforced — not parameterized
CM-6Configuration SettingsObject versioning enabled, bucket ownership enforced, ACLs disabled
AU-3Content of Audit RecordsServer access logging enabled and directed to a dedicated log bucket
AU-6Audit Review and AnalysisLog bucket created and managed by the module — consumers cannot disable logging
The Evidence Artifact
04

Running terraform show -json after apply produces structured, machine-readable output that maps directly to each control. An auditor reading the state can verify SC-28 via the server_side_encryption_configuration block, AC-3 via the public_access_block resource, and AU-3 via the logging block.

// generate machine-readable evidence
# After terraform apply, run:
terraform show -json | jq '.' > compliance-evidence.json

# State fields an auditor checks:
# server_side_encryption_configuration → SC-28
# public_access_block_configuration → AC-3
# logging.target_bucket → AU-3/AU-6
# versioning.enabled → CM-6
Module Structure
05
tools/terraform/primitives/compliant-s3/
  main.tf # s3 bucket + kms key + log bucket
  variables.tf # bucket name, tags, environment
  outputs.tf # bucket arn, kms arn, log bucket arn
  versions.tf # provider version constraints
  evidence/ # generated compliance-evidence.json artifacts
// deploy
terraform init
terraform plan -var="bucket_name=my-compliant-bucket"
terraform apply -auto-approve
terraform show -json > evidence/compliance-evidence.json
Summary
06
5
controls enforced
0
optional toggles
1
command for evidence
0
screenshots needed
Project Details
type
terraform module
cloud
AWS
resource
S3 + KMS
evidence
terraform state
framework
NIST 800-53
hipaa
aligned
Controls
SC-28
Encryption at Rest
AC-3
Access Enforcement
CM-6
Config Settings
AU-3
Audit Records
AU-6
Audit Review
Links
github
portfolio