From f8edbcf4bb50090a924e8aedb4011d24e8fb0d08 Mon Sep 17 00:00:00 2001 From: Jon Bogaty Date: Wed, 16 Nov 2022 11:03:06 -0600 Subject: [PATCH] Support declaring individual efs, docker, fsx volumes for tasks --- main.tf | 20 +++++++++++++++++- variables-deprecated.tf | 30 ++++++++++++++++++++++++++ variables.tf | 47 +++++++++++++++++++++++++++++++++-------- 3 files changed, 87 insertions(+), 10 deletions(-) create mode 100644 variables-deprecated.tf diff --git a/main.tf b/main.tf index 3ed3eec0..734f7315 100644 --- a/main.tf +++ b/main.tf @@ -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" { @@ -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 diff --git a/variables-deprecated.tf b/variables-deprecated.tf new file mode 100644 index 00000000..1d9637b8 --- /dev/null +++ b/variables-deprecated.tf @@ -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 = [] +} \ No newline at end of file diff --git a/variables.tf b/variables.tf index 2ab44a4e..471a0dbf 100644 --- a/variables.tf +++ b/variables.tf @@ -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 @@ -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 = [] }