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

TypeUse CasePerformance
gp3General purpose SSD3,000-16,000 IOPS
io2High-performance databasesUp to 64,000 IOPS
st1Throughput-optimized HDD500 MB/s max
sc1Cold storage HDD250 MB/s max

Notes

  • EBS volumes are automatically encrypted when encrypted = true
  • Use ebs_optimized = true for dedicated EBS throughput
  • Additional volumes require mounting inside the instance