Build a Security and Compliance Stack

By Pulumi Team
Published
Updated

The Challenge

You need infrastructure that meets security and compliance requirements from day one. Rather than retrofitting security onto existing deployments, this approach builds security controls into the foundation: network isolation, encrypted data stores, audit trails, and automated compliance monitoring that detects drift before it becomes a vulnerability.

What You'll Build

  • Security-hardened VPC with private subnets
  • Secure server access without SSH
  • Compliance monitoring for configuration drift
  • Centralized security findings dashboard
  • Automated remediation for common issues

Neo Try This Prompt in Pulumi Neo

Run this prompt in Neo to deploy your infrastructure, or edit it to customize.

Best For

Use this prompt when you need infrastructure that satisfies security audits, compliance frameworks, or enterprise governance requirements. This is relevant for regulated industries, applications handling sensitive data, or any team that wants to establish security best practices as part of their infrastructure foundation.

Architecture Overview

This architecture implements a defense-in-depth approach to AWS infrastructure security. It starts with network isolation through a VPC with public and private subnets across multiple availability zones. Servers run in private subnets with no direct internet access, and administrators connect through a secure session manager rather than opening SSH ports. This eliminates an entire class of network-based attacks.

On top of the network foundation, the architecture adds layers of monitoring and protection. Compliance monitoring tracks whether resources conform to security rules and flags deviations. Threat detection analyzes network traffic, DNS queries, and API calls for signs of compromise. Audit logging records every API call made in the account, creating an immutable trail for forensic analysis and compliance audits.

The final layer is automated remediation. When compliance monitoring detects a common misconfiguration, such as an S3 bucket that was made public or a security group with overly permissive rules, a Lambda function automatically corrects the issue. This reduces the time between detection and fix from hours (waiting for a human) to seconds.

Network Security

The VPC architecture places all application servers in private subnets that have no direct route to the internet. Outbound traffic goes through NAT gateways, and inbound traffic is limited to load balancers in public subnets. Secure access to servers uses a session manager that creates encrypted tunnels without requiring open ports, key management, or bastion hosts.

Compliance Monitoring and Threat Detection

Compliance monitoring continuously evaluates resource configurations against a set of rules. When a resource drifts from its expected configuration, the system records the finding and can trigger remediation. Threat detection runs independently, analyzing VPC flow logs, DNS logs, and API activity for patterns that indicate reconnaissance, credential compromise, or data exfiltration.

Audit Logging and Encryption

Every API call in the account is logged with details about who made the call, from where, and what changed. Logs are stored with validation enabled so any tampering is detectable. All data at rest is encrypted using managed encryption keys, and encryption in transit is enforced across all services. This combination satisfies the logging and encryption requirements of most compliance frameworks.

Common Customizations

  • Add WAF protection: Extend the prompt to include a Web Application Firewall with rules for common web vulnerabilities like SQL injection and cross-site scripting.
  • Enable specific compliance standards: Request compliance rules mapped to a specific framework like CIS Benchmarks, SOC 2, or HIPAA to get targeted compliance monitoring.
  • Add centralized logging: Ask for a centralized log aggregation service that collects logs from all services into a single searchable repository.
  • Implement network segmentation: Request additional VPCs or subnets to isolate different application tiers or workloads from each other.