Skip to content
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

Support terraform resources outside the given template directory #5677

Closed
denbeigh2000 opened this issue Jan 11, 2023 · 12 comments · Fixed by #5720
Closed

Support terraform resources outside the given template directory #5677

denbeigh2000 opened this issue Jan 11, 2023 · 12 comments · Fixed by #5720
Assignees

Comments

@denbeigh2000
Copy link
Contributor

When creating a Coder template, I would like to reference local files outside the given template directory.

Context: I want to re-use common files/terraform modules between multiple templates in a repository. To do this right now, one needs to copy-paste common resources into each template's directory, which is inconvenient and increases the risk of introducing skew.

A practical example: These two templates are near-identical, yet it's not feasible to share common resources between then

@kylecarbs
Copy link
Member

@denbeigh2000 could you create a Terraform module to accomplish this instead?

@denbeigh2000
Copy link
Contributor Author

that'd work if i were willing to split the module out into another repository and import it, but it leaves a few shortcomings:

  • i can't include a terraform module from ../ between these templates
  • i can't make use of common files (e.g., scripts, configuration files, etc) that may be used elsewhere in a shared monorepo

@kylecarbs
Copy link
Member

Ahh, I see. I wonder if it'd be best to upload the entire directory as a template, and be able to specify a subdirectory to execute out of?

@denbeigh2000
Copy link
Contributor Author

that's totally reasonable for the linked case, but there are some valid use cases where this doesn't make sense

e.g., $WORK uses a large, shared monorepo, and there are often resources in far-flung relative directories (e.g., ../../../../resources/some-other-team/some-other-product/resource.yml) that we want to include - an approach like this would require committing nearly the entire repository as a template.

would it be possible to resolve file() resources and include them in the uploaded tarball, so that they can be used in the template?

@ammario
Copy link
Member

ammario commented Jan 12, 2023

What if the tarring process traversed symlinks?

@denbeigh2000
Copy link
Contributor Author

I'd have no issue with making a few relative symlinks to address this 👍

@ammario
Copy link
Member

ammario commented Jan 15, 2023

After #5720 is in you'll be able to do:

tar -cvh . | coder templates <push|create> -d - <name>

@denbeigh2000
Copy link
Contributor Author

Thank you very, very much 🙏

@ofey404
Copy link

ofey404 commented May 27, 2023

I like this feature, thanks @denbeigh2000

@pasuder
Copy link

pasuder commented Dec 12, 2023

What if the tarring process traversed symlinks?

As per my understanding, doing a tar of directory to push template is the only option to follow symlinks as coder templates push does not follow symlinks, correct?

@ammario
Copy link
Member

ammario commented Dec 12, 2023

What if the tarring process traversed symlinks?

As per my understanding, doing a tar of directory to push template is the only option to follow symlinks as coder templates push does not follow symlinks, correct?

That's correct. In general we don't want to go feature-to-feature with tar, so we promote using that for all advanced directory serialization.

@pasuder
Copy link

pasuder commented Dec 14, 2023

Good, it does work with this way:

tar -cvh . | coder templates push ..

Thanks!

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 a pull request may close this issue.

5 participants