I'm trying to setup an ECS cluster using Terraform and I can't figure out how to make Terraform autoprovision an EBS volume on the ECS instance that hosts a service that requires that volume.
In my config I have:
resource "aws_ecs_task_definition" "name" {
family = "name"
container_definitions = "${file("task-definitions/name.json")}"
volume {
name = "name-storage"
host_path = "/ecs/name-storage"
}
}
resource "aws_ecs_service" "name" {
name = "name"
cluster = "${aws_ecs_cluster.main.id}"
task_definition = "${aws_ecs_task_definition.name.arn}"
desired_count = 1
iam_role = "${aws_iam_role.ecs_service_role.arn}"
depends_on = ["aws_iam_role_policy.ecs_service_role_policy"]
load_balancer {
elb_name = "${aws_elb.name.id}"
container_name = "name"
container_port = 8000
}
}
and in the task-definitions/name.json
I have:
"mountPoints": [
{
"sourceVolume": "name-storage",
"containerPath": "/var/lib/cassandra"
}
]
How do I actually get the volume on the instance that hosts this service?