With EBS Volumes
Deploy an EC2 instance with additional EBS volumes for persistent storage.
module "database_server" {
source = "registry.patterneddesigns.ca/patterneddesigns/ec2-instance/aws"
version = "1.5.0"
instance_name = "database-server"
instance_type = "r6i.large"
ami_id = data.aws_ami.amazon_linux.id
subnet_id = module.vpc.private_subnets[0]
ebs_optimized = true
root_block_device = {
volume_size = 50
volume_type = "gp3"
encrypted = true
}
ebs_block_devices = [
{
device_name = "/dev/sdf"
volume_size = 100
volume_type = "gp3"
iops = 3000
throughput = 125
encrypted = true
},
{
device_name = "/dev/sdg"
volume_size = 500
volume_type = "st1"
encrypted = true
}
]
tags = {
Environment = "production"
Service = "database"
}
}
Volume Types
| Type | Use Case | Performance |
|---|---|---|
| gp3 | General purpose SSD | 3,000-16,000 IOPS |
| io2 | High-performance databases | Up to 64,000 IOPS |
| st1 | Throughput-optimized HDD | 500 MB/s max |
| sc1 | Cold storage HDD | 250 MB/s max |
Notes
- EBS volumes are automatically encrypted when
encrypted = true - Use
ebs_optimized = truefor dedicated EBS throughput - Additional volumes require mounting inside the instance