Skip to content

Support terraform resources outside the given template directory #5677

Closed

Description

@denbeigh2000

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

Activity

  1. kylecarbs commented on Jan 11, 2023

    @kylecarbs
    Member

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

  2. denbeigh2000 commented on Jan 11, 2023

    @denbeigh2000
    ContributorAuthor

    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
  3. kylecarbs commented on Jan 11, 2023

    @kylecarbs
    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?

  4. denbeigh2000 commented on Jan 11, 2023

    @denbeigh2000
    ContributorAuthor

    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?

  5. ammario commented on Jan 12, 2023

    @ammario
    Member

    What if the tarring process traversed symlinks?

  6. denbeigh2000 commented on Jan 12, 2023

    @denbeigh2000
    ContributorAuthor

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

  7. self-assigned this
    on Jan 12, 2023
  8. ammario commented on Jan 15, 2023

    @ammario
    Member

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

    tar -cvh . | coder templates <push|create> -d - <name>
    
  9. denbeigh2000 commented on Jan 17, 2023

    @denbeigh2000
    ContributorAuthor

    Thank you very, very much 🙏

  10. ofey404 commented on May 27, 2023

    @ofey404

    I like this feature, thanks @denbeigh2000

  11. pasuder commented on Dec 12, 2023

    @pasuder

    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?

  12. ammario commented on Dec 12, 2023

    @ammario
    Member

    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.

  13. pasuder commented on Dec 14, 2023

    @pasuder

    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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions