Skip to content

Support passing tfvars files for terraform based provisioner workspaces #1590

Closed as not planned

Description

@Emyrk

What is your suggestion?

Terraform supports using a tfvars. It would be nice if you could do a coder workspaces create --tfvars=my.tfvars.

Currently we are aiming to support yaml/json files to answer all prompts (#1377, #1541).

Supporting tfvars gets a bit complicated. For one, ideally we do not interpret/parse the tfvars, and pass it "as is" to terraform apply/plan. One solution is to support passing a new ParameterDestination type file, which lets writing files to the directory where terraform is run. This could possibly be a security issue though, as now users can not only set all parameters, but are writing arbitrary files to the provisionerd node :(.

Options:

  • Parse the tfvars first and do some sanity checks before uploading the file. This would require us to understand the file extension type, rather than a generic "file upload param".

Why do you want this feature?

terraform apply and coder workspace create become "synonymous" for sake of testing.

Are there any workarounds to get this functionality today?

Yes, use yaml or json files instead.

Are you interested in submitting a PR for this?

Activity

  1. Emyrk commented on May 19, 2022

    @Emyrk
    MemberAuthor

    @kylecarbs Brainstorming with @AbhineetJain on this. Might just support yaml/json at first, then figure this one out next.

  2. kylecarbs commented on May 19, 2022

    @kylecarbs
    Member

    We maybe don't even need to parse the parameters ourselves at all. What if we just included the secrets directly in the archive? Then Terraform would pick them up automatically, and we would perform zero magic.

  3. Emyrk commented on May 19, 2022

    @Emyrk
    MemberAuthor

    When you say secrets do you mean all params?

  4. tjcran commented on May 30, 2022

    @tjcran

    @Emyrk i'm inclined to say this is a nice to have for now. Any reason I should bump this up to sooner?

  5. added this to the Post-MVP milestone on May 30, 2022
  6. ketang commented on May 31, 2022

    @ketang
    Contributor

    We shouldn't have a top level argument that is Terraform-specific. We can do something like --var name=value and handle this in a provisioner-independent way.

  7. Emyrk commented on May 31, 2022

    @Emyrk
    MemberAuthor

    @ketang there is different ideas on how to implement this, but we currently support yaml var files. So any other format would just be "in addition too" the general format.

  8. kylecarbs commented on May 31, 2022

    @kylecarbs
    Member

    Terraform already supports tfvars, so a template manager can just include a tfvar file in their archive when it's uploaded. That should be supported already (maybe we'll have to add --tfvars-file to our provision step?).

  9. ketang commented on May 31, 2022

    @ketang
    Contributor

    maybe we'll have to add --tfvars-file to our provision step?

    Do they directly invoke a Terraform-specific provisioner? If it's through an abstraction, then I have the same comment as above re TF-specific variables and arguments in provisioner-agnostic interfaces and code.

  10. changed the title [-]Feat: Support passing `tfvars` files for terraform based provisioner workspaces[/-] [+]Support passing `tfvars` files for terraform based provisioner workspaces[/+] on Jun 7, 2022
  11. removed this from the Post-MVP milestone on Jul 22, 2022
  12. kylecarbs commented on Aug 24, 2022

    @kylecarbs
    Member

    This seems like something we should wait for customers to request before we implement any parsing logic. Closing for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiArea: HTTP API

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions