Skip to content

Latest commit

 

History

History
 
 

attached_ebs

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

attached_ebs

Introduction

attached_ebs is a Terraform module used to generate persistent EBS or EC2 Instance Store volumes and attach them to auto-scaled instances, also managing daily snapshots for EBS instances.

Usage

Set the input variable group to a unique identifier to use to refer to the group of disks. Make sure to tag all of your instances with Group=XXXX (with XXXX as the value you set for group). This is used by the IAM policy to enable permissions for attaching EBS volumes within the group.

The input variable attached_ebs takes a map of volume definitions to attach to instances on boot:

module "attached-ebs" {
  source = "github.com/ondat/etcd3-bootstrap/terraform/modules/attached_ebs"
  attached_ebs = {
    "ondat_data_1": { # Basic EBS example
      size = 100
      availability_zone = eu-west-1a
      encrypted = true
      volume_type = gp3
      block_device_aws = "/dev/xvda1"
      block_device_os = "/dev/nvme0n1"
      block_device_mount_path = "/var/lib/data0"
    }
    "ondat_data_2": { # EC2 Instance Store
      availability_zone = eu-west-1a
      ephemeral = true
      block_device_os = "/dev/nvme1n1"
      block_device_mount_path = "/var/lib/data0"
    }
    "ondat_data_3": { # Full EBS example
      size = 100
      availability_zone = eu-west-1a
      dependson = ["ondat_data_1"]
      encrypted = true
      restore_snapshot = ""
      iops = 3000
      volume_type = io2
      throughput = 150000
      kms_key_id = "arn:aws::kms/..."
      block_device_aws = /dev/xvda2
      block_device_os = /dev/nvme2n1
      block_device_mount_path = /var/lib/data1
    }
  }
}

For airgapped or private environments, use the variable ebs_bootstrap_binary_url to provide an HTTP/S address from which to retrieve the necessary binary.

Use the output iam_role_policy_document to generate and assign the policy to your ASG node's role.

Use the output userdata_snippets_by_az to embed in your ASG's userdata - it's a map of AZ to snippets.

Appendix

Requirements

No requirements.

Providers

Name Version
aws 4.16.0

Modules

No modules.

Resources

Name Type
aws_dlm_lifecycle_policy.automatic_snapshots resource
aws_ebs_volume.ssd resource
aws_iam_role.dlm_lifecycle_role resource
aws_iam_role_policy.dlm_lifecycle resource
aws_iam_policy_document.ebs data source
aws_region.current data source

Inputs

Name Description Type Default Required
attached_ebs Map of the EBS objects to allocate any n/a yes
ebs_bootstrap_binary_url Custom URL from which to download the ebs_bootstrap binary any null no
group A unique identifier for the EBS group string n/a yes

Outputs

Name Description
iam_role_policy_document IAM role policy document to assign to ASG instance role
userdata_snippets_by_az Map of snippets of userdata to assign to ASG instances by availability zone