Terraform-provider-aws: Feature request: ECS Docker volume support

Created on 12 Aug 2018  ·  9Comments  ·  Source: hashicorp/terraform-provider-aws

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

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.

New or Affected Resource(s)

  • aws_ecs_task_definition

Potential Terraform Configuration

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"
                }
    }
  }
}

References

https://docs.aws.amazon.com/AmazonECS/latest/developerguide/docker-volumes.html

https://aws.amazon.com/about-aws/whats-new/2018/08/amazon-ecs-now-supports-docker-volume-and-volume-plugins/

enhancement servicecs

Most helpful comment

@russmac i've started working on this issue

All 9 comments

👍

:+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;

  • Specify an existing Docker volume (which you have to provision yourself on the ECS instances the container has affinity to) however each instance will have a different volume.
  • Refer to an existing path in the container and use the lower performing Docker writable layer, Which is not persistent.

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!

Was this page helpful?
0 / 5 - 0 ratings