Skip to content
This repository has been archived by the owner on Mar 14, 2022. It is now read-only.

aws_ecs_service cannot accommodate "volume" declaration(s) #18

Open
atz opened this issue Nov 15, 2018 · 2 comments
Open

aws_ecs_service cannot accommodate "volume" declaration(s) #18

atz opened this issue Nov 15, 2018 · 2 comments

Comments

@atz
Copy link
Contributor

atz commented Nov 15, 2018

https://github.com/sul-dlss/terraform-module-aws-ecs/blob/master/service/main.tf#L169

The resource cannot both declare a volume and still support FARGATE (or non-volume EC2).

This is the specific instance of a general problem with the module/source approach. The upstream code cannot conditionally include any structured block¹ (of which there are hundreds in terraform AWS options). That's by design, since the HCL would no longer be structurally declarative.

Because we would need a copy-paste ECS-with-volume version of the same code, I don't see how this approach can become sufficiently flexible or reusable.


¹ I presume we really don't want to go the way of count/string_to_bool/regex hacks, but even that doesn't really solve this.

@atz
Copy link
Contributor Author

atz commented Nov 19, 2018

Slack discussion expressed consensus that this service cannot do both, so will need to be replicated/forked. Note: these use cases would each require their own separate module:

  • ECS Fargate
  • ECS EC2 w/ 1 volume
  • ECS EC2 w/ 2 volumes
  • etc.

Each of those would require additional different modules in an n-dimensional matrix with every other block that might be configured in the underlying resources. Need a second port exposed? ECS EC2 w/ 3 volumes 2 ports. Need two security groups? Etc.

While the current approach might be amenable to copy/paste/modify for 2 projects, it certainly won't scale to 20.

@atz
Copy link
Contributor Author

atz commented Dec 6, 2018

Rather than fix the ECS module repo to accommodate this use case, we broke off separate code
https://github.com/sul-dlss/terraform-aws/tree/6610d9b5c85c0cc05f7365cef9873ac24190ca5a/modules/local/trellis

Currently not fully abstract, but it could be refactored.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant