Skip to content

[PLAT-71] Allow define one optional volume #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

keymon
Copy link
Contributor

@keymon keymon commented May 25, 2017

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)

keymon added 2 commits May 25, 2017 12:53
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 link
Contributor

@bart613 bart613 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - just two comments?

"host_path"= "/tmp"
}
]
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this being defined here and in variables.tf on purpose? Would this not cause error?

]
}

output volumes {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a useful, potential reason for this output?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I accidentally added those.

@keymon
Copy link
Contributor Author

keymon commented May 25, 2017

Closing it to remove spurious variable and output

@keymon keymon closed this May 25, 2017
@keirbadger keirbadger deleted the PLAT-71_add_volume branch May 28, 2021 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants