Skip to content

Reference Unmanaged EBS Volumes

Define EBS Volumes

Define the lookup_ebs_volumes attribute of the EBS variable as true. This will cause the "ebs_volume" module to include all matching EBS volumes in the returned map using the volume-id as keys. Optionally, use the filter attribute to limit the EBS volumes returned.

If no filter is supplied, all EBS volumes will be contained in the map, including volumes created by Terraform. It is recommended to use a filter to prevent the map from containing duplicates with multiple keys referencing the same EBS volumes, however, it is not required.

ebs = {
    lookup_ebs_volumes = true
    filter = [
        {
            name = "volume-id"
            values = ["vol-0e40d4635eb3d484e", "vol-0e40d4635eb3d484l"]
        }
    ]
    volumes = {
        externaldiska = {
            availability_zone = "us-west-2a"
            size = 80
        }
        externaldiskb = {
            availability_zone = "us-west-2a"
            size = 80
        }
    }
}

Attach EBS Volumes to Instances

Use the external_disk attribute to attach one of the external EBS volumes to a VM. The ID of the volume can be used to reference the unmanaged disk. The EBS volume must be in the same availability zone as the instance to be attached.

odb = {
    names = [
        "tstodb"
    ]
    root_block_device = {
            volume_size = 100
            volume_type = "io2"
            iops = "3000"
        }
    disks = {
        disk1 = {
            device_name = "/dev/sdb"
            size = 60
        },
        disk2 = {
            device_name = "/dev/sdc"
            external_disk = "vol-0e40d4635eb3d484e"
        }
    }
}

Example ebs_volume Module Output

See the output from the ebs_volume module below for an example of how the keys from the returned map appear for the different types of storage configurations.

    ...
        + externaldiskb         = {
            + arn                  = (known after apply)
            + availability_zone    = "us-west-2a"
            + encrypted            = true
            + final_snapshot       = false
            + id                   = (known after apply)
            + iops                 = (known after apply)
            + kms_key_id           = (known after apply)
            + multi_attach_enabled = null
            + outpost_arn          = null
            + size                 = 80
            + snapshot_id          = (known after apply)
            + tags                 = {
                + Name        = "Utah-AWS-externaldiskb-DISK"
                + ansible_key = "externaldiskb"
            }
            + tags_all             = {
                + Name        = "Utah-AWS-externaldiskb-DISK"
                + ansible_key = "externaldiskb"
                + environment = "full"
                + repo        = "https://github.com/Sapphire-Health/Terraform-Github-AWS"
            }
            + throughput           = (known after apply)
            + timeouts             = null
            + type                 = "gp3"
        }
        + "odb.tstodb.disk1"    = {
            + arn                  = (known after apply)
            + availability_zone    = (known after apply)
            + encrypted            = true
            + final_snapshot       = false
            + id                   = (known after apply)
            + iops                 = (known after apply)
            + kms_key_id           = (known after apply)
            + multi_attach_enabled = null
            + outpost_arn          = null
            + size                 = 60
            + snapshot_id          = (known after apply)
            + tags                 = {
                + Name        = "Utah-AWS-disk1-tstodb-DISK"
                + ansible_key = "disk1"
            }
            + tags_all             = {
                + Name        = "Utah-AWS-disk1-tstodb-DISK"
                + ansible_key = "disk1"
                + environment = "full"
                + repo        = "https://github.com/Sapphire-Health/Terraform-Github-AWS"
            }
            + throughput           = (known after apply)
            + timeouts             = null
            + type                 = "gp3"
        }
        + vol-0e40d4635eb3d484e = {
            + arn                  = "arn:aws:ec2:us-west-2:163104270306:volume/vol-0e40d4635eb3d484e"
            + availability_zone    = "us-west-2a"
            + encrypted            = false
            + filter               = [
                + {
                    + name   = "volume-id"
                    + values = [
                        + "vol-0e40d4635eb3d484e",
                    ]
                },
            ]
            + id                   = "vol-0e40d4635eb3d484e"
            + iops                 = 3000
            + kms_key_id           = ""
            + most_recent          = false
            + multi_attach_enabled = false
            + outpost_arn          = ""
            + size                 = 35
            + snapshot_id          = ""
            + tags                 = {
                + Name = "anothertest"
            }
            + throughput           = 125
            + timeouts             = null
            + volume_id            = "vol-0e40d4635eb3d484e"
            + volume_type          = "gp3"
        }
    }
}