README
ebs
Creates KMS-encrypted EBS volumes with optional EC2 attachment and DLM snapshot lifecycle policies.
Provisions gp3 EBS volumes (or any volume type) with encryption enforced, optional instance attachment via a Name-tag data lookup, and Data Lifecycle Manager policies for automated snapshot creation and retention. A DLM execution role is created automatically if none is supplied.
Usage
module "ebs" {
source = "hcassc.jfrog.io/iac-terraform-modules-virtual/storage/ebs/aws"
version = "0.1.0"
volumes = {
data = {
availability_zone = "us-east-1a"
size = 100
kms_key_id = module.kms.key_arn
instance_name = "my-ec2-instance"
device_name = "/dev/xvdf"
}
}
snapshot_schedules = {
daily = {
name = "daily-snapshots"
retain_count = 7
target_tags = { Backup = "true" }
}
}
}
Requirements
| Name | Version |
|---|---|
| terraform | ~> 1.5 |
| aws | ~> 6.50 |
Providers
| Name | Version |
|---|---|
| aws | 6.50.0 |
Resources
| Name | Type |
|---|---|
| aws_dlm_lifecycle_policy.this | resource |
| aws_ebs_volume.this | resource |
| aws_iam_role.dlm | resource |
| aws_iam_role_policy_attachment.dlm | resource |
| aws_volume_attachment.this | resource |
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| dlm_execution_role_arn | ARN of the IAM role for DLM (optional — creates role when null) | string |
null |
no |
| dlm_policy_name | Name for the Data Lifecycle Manager policy | string |
"ebs-snapshot-policy" |
no |
| snapshot_schedules | Map of DLM snapshot schedules | map(object({ name = string interval = optional(number, 24) interval_unit = optional(string, "HOURS") times = optional(list(string), ["03:00"]) retain_count = optional(number, 7) target_tags = map(string) })) | {} |
no |
| tags | Resource tags to apply to all resources | map(string) |
{} |
no |
| volumes | Map of EBS volumes to create | map(object({ availability_zone = string size = number type = optional(string, "gp3") iops = optional(number, null) throughput = optional(number, null) encrypted = optional(bool, true) kms_key_id = optional(string, null) multi_attach_enabled = optional(bool, false) snapshot_id = optional(string, null) final_snapshot = optional(bool, false) # Attachment instance_name = optional(string, null) # data lookup key device_name = optional(string, null) force_detach = optional(bool, false) })) | {} |
no |
Outputs
| Name | Description |
|---|---|
| dlm_policy_ids | Map of schedule key to DLM lifecycle policy ID |
| volume_arns | Map of logical volume key to EBS volume ARN |
| volume_ids | Map of logical volume key to EBS volume ID |