AWS has added support for docker volumes to be generated by task definition configuration on 09/08/2018: https://aws.amazon.com/about-aws/whats-new/2018/08/amazon-ecs-now-supports-docker-volume-and-volume-plugins/
Parameter details are here: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/docker-volumes.html
This expands the possible parameters in a volumes array to this:
"volumes": [
{
"name": "string",
"host": {
"sourcePath": "string"
},
"dockerVolumeConfiguration": {
"scope": "string",
"autoprovision": boolean,
"driver": "string",
"driverOpts": {
"key": "value"
},
"labels": {
"key": "value"
}
}
}
]
This greatly streamlines provisioning of docker volumes in a Terraform ECS deployment.
resource "aws_ecs_task_definition" "service" {
family = "service"
container_definitions = "${file("task-definitions/service.json")}"
volume {
name = "service-storage"
host_path = "/ecs/service-storage"
docker_volume_configuration {
driver = "local"
scope = "shared"
autoprovision = true,
labels {
name = "service-storage"
}
}
}
}
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/docker-volumes.html
👍
:+1:
Are there any workarounds you have found in the mean time? Basically I want to be able to create a task definition that uses a persistent docker data volume, however the only thing I could find in the Terraform docs states:
ECS will create a nonpersistent data volume that starts empty and is deleted after the task has finished
Terraform noob here
@markphelps The current parameters allow you to;
The new parameters would create a docker volume on the instance the task is launched or if "shared" set use an existing one (and not delete it when the task stops)
@russmac i've started working on this issue
@ewilde Thank you, I can use your PR as a guide to get started writing Go for the next feature I need.
Initial support for this has been merged in and will be released with version 1.36.0 of the AWS provider, likely later today. 👍
This has been released in version 1.36.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.
I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.
If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!
Most helpful comment
@russmac i've started working on this issue