I'm using Terraform to create an ECS Cluster, a task definition and a service.
For task definition, the piece of code looks like this:
resource "aws_ecs_task_definition" "postgres" {
container_definitions = ...
family = "Postgres"
requires_compatibilities = ["EC2"]
network_mode = "bridge"
volume {
name = "PreCreatedEBSVolume"
docker_volume_configuration {
scope = "task"
autoprovision = false
driver = "rexray/ebs"
}
}
}
I specifically set autoprovision
to false
to make sure a new volume is not created. But still, when the service runs, a new volume is created with 16GiB (which I assume is the default size) and used instead of using the "PreCreatedEBSVolume".
I check the docker volume ls
in the instance and sure enough, I see the EBS volumes listed. And if I run a new instance with this volume mounted, it's mounting as expected.
Is there a way I can make REX-Ray use existing block storage?
I found the issue.
The problem is the "scope" property. The docs had the following to say:
So, I just had to change it to "shared" from "task" to make it use the existing EBS volume.