Terraform AWS EC2 Instance
EC2 instances with IAM roles, EBS encryption, IMDSv2, security groups, detailed monitoring, user data, placement options, and optional Elastic IPs or attached volumes.
Controls enforced
These compliance controls are checked at terraform plan time.
- Attached EBS volumes should have encryption enabled(low effort)
- EBS volumes should have encryption at rest enabled(low effort)
- EC2 instances should have attached EBS volumes marked for deletion on termination(low effort)
- EC2 instances should have detailed monitoring enabled(low effort)
- EC2 instances should have EBS optimization enabled(low effort)
- EC2 instances should have IAM profile attached(low effort)
- EC2 instances should be in a VPC(low effort)
- EC2 instances should not use key pairs in running state(low effort)
- EC2 instances should not have a public IP address(low effort)
- EC2 instances should not use multiple ENIs(low effort)
- EC2 instances should have termination protection enabled(low effort)
- EC2 instances should use IMDSv2(low effort)
- EC2 instances should use IAM instance roles for AWS resource access(low effort)
- EC2 instances should not use paravirtual instance types(low effort)
- VPC Security groups should only allow unrestricted incoming traffic for authorized ports(low effort)
- VPC security groups should restrict ingress from 0.0.0.0/0 or ::/0 to cassandra ports 7199 or 9160 or 8888(low effort)
Quick start
View this module on the compliance.tf registry — versions, inputs, and outputs →
See the Get Started guide and Registry Endpoints for details on how to customize the module for your requirements.
Migration from upstream
Already using terraform-aws-modules? Change only the source URL:
module "ec2-instance" {
source = "terraform-aws-modules/ec2-instance/aws"
version = "1.0"
}module "ec2-instance" {
source = "soc2.compliance.tf/terraform-aws-modules/ec2-instance/aws"
version = "1.0"
}Same arguments. Same outputs. Controls are checked at terraform plan. See the Migration Guide for step-by-step instructions.
Reversibility
No lock-in. Switch back by reverting the source URL:
module "ec2-instance" {
source = "terraform-aws-modules/ec2-instance/aws"
}Run terraform init -upgrade. Terraform state is unchanged — same resource addresses, same provider, no compliance.tf-specific resources. Controls you already applied remain in AWS.
Mapped compliance frameworks
Framework coverage
Which controls from this module are active under each framework endpoint.
● enforced by default · ○ not activated by this endpoint