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

Preserve workspace in custom workflow #1011

Closed
andyshinn opened this issue Apr 27, 2020 · 1 comment
Closed

Preserve workspace in custom workflow #1011

andyshinn opened this issue Apr 27, 2020 · 1 comment

Comments

@andyshinn
Copy link

I think this might be related to #935 (or maybe the feature request of the issue). Also linking #661 where I first encountered this but didn't fully understand what was happening.

I would like to propose a feature request to preserve the workspace for custom workflows. Currently, in each stage of a custom workflow I do:

version: 3
projects:
  - name: staging
    dir: terraform
    workspace: staging
    workflow: staging
workflows:
  staging:
    plan:
      steps:
      - env:
          name: TF_WORKSPACE
          command: 'echo "$WORKSPACE"'
      - init
      - plan:
          extra_args: ["-var-file", "vars/staging.tfvars"]

Without the added env step the workspace in the project is ignored. I would expect that TF_WORKSPACE so it is available to all steps. It is also something I miss when creating new projects because the failures at init are not apparent that the workspace is missing.

Then, the steps become a more concise:

version: 3
projects:
  - name: staging
    dir: terraform
    workspace: staging
    workflow: staging
workflows:
  staging:
    plan:
      steps:
      - init
      - plan:
          extra_args: ["-var-file", "vars/staging.tfvars"]

I'm also going to link #659 as it is a little related in that it would allow easier sharing of workflows where the vars file in this case always matches the workspace:

version: 3
projects:
  - name: staging
    dir: terraform
    workspace: staging
    workflow: environments
  - name: production
    dir: terraform
    workspace: production
    workflow: environments
workflows:
  environments:
    plan:
      steps:
      - init
      - plan:
          extra_args: ["-var-file", "vars/${TF_WORKSPACE}.tfvars"]

A low-priority thing for sure (manually setting TF_WORKSPACE to WORKSPACE is a workaround). But I think the UX around this could be improved.

@mwarkentin
Copy link
Contributor

Should this be closed?

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

No branches or pull requests

3 participants