You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For some cases and workloads we need to pass some modules to the task
definition. The volumes are passed as a list of maps to the
ecs_task_resource[1].
But the current syntax of terraform does not allow consume this value
directly from a variable. Trying to do so, we hit the issues described
in [2] and [3] (pending to report a specific bug).
But we found out that it works if we build the map structure directly
within the resource, and we use interpolation to consume the values of
the map.
Meanwhile the terraform project does not provide a definitive solution,
we will implement the following workaround:
- The module will receive configuration for one unique module, being
the default a empty map {}
- If the map is empty, a dummy volume will be passed as `name=dummy`
and `host_path=/tmp/dummy_volume`
This would cover our specific case in the short term, and can be later
easily adapted to use a optional list of volumes.
[1] https://www.terraform.io/docs/providers/aws/r/ecs_task_definition.html#volume
[2] hashicorp/terraform#10407
[3] hashicorp/terraform#7705 (comment)
Copy file name to clipboardExpand all lines: README.md
+1
Original file line number
Diff line number
Diff line change
@@ -24,6 +24,7 @@ This module creates a basic ECS Task Definition.
24
24
*`family` - the name of the task definition. For ECS services it is recommended to use the same name as for the service, and for that name to consist of the environment name (e.g. "live"), the comonent name (e.g. "foobar-service"), and an optional suffix (if an environment has multiple services for the component running - e.g. in a multi-tenant setup), separated by hyphens.
25
25
*`container_definitions` - list of strings. Each string should be a JSON document describing a single container definition - see https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html.
26
26
*`task_role_arn` - The Amazon Resource Name for an IAM role for the task.
27
+
*`volume` - Volume block map with 'name' and 'host_path'. 'name': The name of the volume as is referenced in the sourceVolume. 'host_path' The path on the host container instance that is presented to the container.
Copy file name to clipboardExpand all lines: variables.tf
+6
Original file line number
Diff line number
Diff line change
@@ -13,3 +13,9 @@ variable "task_role_arn" {
13
13
type="string"
14
14
default=""
15
15
}
16
+
17
+
variable"volume" {
18
+
description="Volume block map with 'name' and 'host_path'. 'name': The name of the volume as is referenced in the sourceVolume. 'host_path' The path on the host container instance that is presented to the container."
0 commit comments