Skip to content

Commit

Permalink
Support declaring individual efs, docker, fsx volumes for tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
jbcom committed Nov 16, 2022
1 parent ef7af53 commit 67433e1
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 10 deletions.
20 changes: 19 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,22 @@ locals {
main_container_definition = coalesce(var.container_definition, module.container_definition.json_map_encoded)
# combine all container definitions
all_container_definitions = "[${join(",", concat(local.init_container_definitions, [local.main_container_definition]))}]"

efs_volumes = concat(var.efs_volumes, [
for volume_definition in var.volumes : {
host_path = volume_definition["host_path"]
name = volume_definition["name"]
efs_volume_configuration = volume_definition["efs_volume_configuration"]
}
])

docker_volumes = concat(var.docker_volumes, [
for volume_definition in var.volumes : {
host_path = volume_definition["host_path"]
name = volume_definition["name"]
docker_volume_configuration = volume_definition["docker_volume_configuration"]
}
])
}

module "ecs_alb_service_task" {
Expand Down Expand Up @@ -162,7 +178,9 @@ module "ecs_alb_service_task" {
subnet_ids = var.ecs_private_subnet_ids
container_port = var.container_port
nlb_container_port = var.nlb_container_port
docker_volumes = var.volumes
efs_volumes = local.efs_volumes
docker_volumes = local.docker_volumes
fsx_volumes = var.fsx_volumes
ecs_load_balancers = local.load_balancers
deployment_controller_type = var.deployment_controller_type
force_new_deployment = var.force_new_deployment
Expand Down
30 changes: 30 additions & 0 deletions variables-deprecated.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
variable "volumes" {
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
}))
}))
}))
description = <<-EOT
DEPRECATED: Use any of `efs_volumes`, `docker_volumes`, `fsx_volumes`, instead.
Historical description: Task volume definitions as list of configuration objects.
Historical default: `[]`
EOT

default = []
}
47 changes: 38 additions & 9 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -217,17 +217,10 @@ variable "service_registries" {
default = []
}

variable "volumes" {
variable "efs_volumes" {
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
Expand All @@ -239,7 +232,43 @@ variable "volumes" {
}))
}))
}))
description = "Task volume definitions as list of configuration objects"

description = "Task EFS volume definitions as list of configuration objects. You can define multiple EFS volumes on the same task definition, but a single volume can only have one `efs_volume_configuration`."
default = []
}

variable "docker_volumes" {
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
}))
}))

description = "Task docker volume definitions as list of configuration objects. You can define multiple Docker volumes on the same task definition, but a single volume can only have one `docker_volume_configuration`."
default = []
}

variable "fsx_volumes" {
type = list(object({
host_path = string
name = string
fsx_windows_file_server_volume_configuration = list(object({
file_system_id = string
root_directory = string
authorization_config = list(object({
credentials_parameter = string
domain = string
}))
}))
}))

description = "Task FSx volume definitions as list of configuration objects. You can define multiple FSx volumes on the same task definition, but a single volume can only have one `fsx_windows_file_server_volume_configuration`."
default = []
}

Expand Down

0 comments on commit 67433e1

Please sign in to comment.