Skip to content

EFS volumes (efs_volume_configuration or docker_volume_configuration) doesn't work with trussworks/terraform-aws-ecs-service v.6.6.0 using the module #330

@PhungV0

Description

@PhungV0

Describe the bug
EFS volumes (efs_volume_configuration or docker_volume_configuration) doesn't work with trussworks/terraform-aws-ecs-service v.6.6.0 using the module. I need to modify locally the ecs module main.tf and variables.tf and disable some unnecessary rows to make it happen.

AWS CLI version: aws-cli/2.2.38
terraform v1.3.4
module "ecs-service" {
source = "trussworks/ecs-service/aws"
version ="6.6.0"

When using the ecs module, you can find from main.tf

dynamic "volume" {
for_each = var.container_volumes
content {
name = volume.value.name
}
}
and from variables.tf

variable "container_volumes" {
description = "Volumes that containers in your task may use."
default = []
type = list(
object({
name = string
})
)
}

So basically as default you can add only the name for container_volumes without any efs_volume_configuration or docker_volume_configuration

I need to modify locally main.tf and add extra information to enable mapping the efs volume configuration for ECS

dynamic "volume" {
for_each = var.container_volumes
content {
name = volume.value.name

  # host_path = lookup(volume.value, "host_path", null)

  # dynamic "docker_volume_configuration" {
  #   for_each = lookup(volume.value, "docker_volume_configuration", [])
  #   content {
  #     autoprovision = lookup(docker_volume_configuration.value, "autoprovision", null)
  #     driver        = lookup(docker_volume_configuration.value, "driver", null)
  #     driver_opts   = lookup(docker_volume_configuration.value, "driver_opts", null)
  #     labels        = lookup(docker_volume_configuration.value, "labels", null)
  #     scope         = lookup(docker_volume_configuration.value, "scope", null)
  #   }
  # }

  dynamic "efs_volume_configuration" {
    for_each = lookup(volume.value, "efs_volume_configuration", [])
    content {
      file_system_id          = lookup(efs_volume_configuration.value, "file_system_id", null)
      root_directory          = lookup(efs_volume_configuration.value, "root_directory", null)
      # transit_encryption      = lookup(efs_volume_configuration.value, "transit_encryption", null)
      # transit_encryption_port = lookup(efs_volume_configuration.value, "transit_encryption_port", null)
      # dynamic "authorization_config" {
      #   for_each = lookup(efs_volume_configuration.value, "authorization_config", [])
      #   content {
      #     access_point_id = lookup(authorization_config.value, "access_point_id", null)
      #     iam             = lookup(authorization_config.value, "iam", null)
      #   }
      # }
    }
  }
}

}

and then add to variables.tf

variable "container_volumes" {
description = "Volumes that containers in your task may use."
type = list(object({
#host_path = string
name = string
# docker_volume_configuration = list(object({
# autoprovision = bool
# driver = string
# driver_opts = map(string)
# labels = map(string)
# scope = string
# }))
efs_volume_configuration = list(object({
file_system_id = string
root_directory = string
# transit_encryption = string
# transit_encryption_port = string
# authorization_config = list(object({
# access_point_id = string
# iam = string
# }))
}))
}))
default = []
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions