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

var_file path is not absolute #80

Open
grasbergerm opened this issue May 25, 2022 · 0 comments
Open

var_file path is not absolute #80

grasbergerm opened this issue May 25, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@grasbergerm
Copy link

Is your feature request related to a problem? Please describe.
When trying to use a dynamic value with a plan or apply job, it is very difficult to pass the dynamically created value as a var or a var_file.

Describe the solution you'd like
The var_file attribute should accept an absolute path instead of expecting a var file from within the module path.

Describe alternatives you've considered
I've tried passing a variable directly, with the var attribute, but it does not seem that the plan/apply reads from environment variables set in a pre-step step.

Additional context
Here's my current setup, please let me know if there's a better way to do this:

The pre-step command, grabbing a variable created in another job:

commands:
  set-image-tag-terraform-var:
    steps:
      - attach_workspace:
          at: /tmp/deploy/workspace
      - run: |
          cat /tmp/deploy/workspace/new-env-vars >> $BASH_ENV
          source $BASH_ENV
          echo "image_tag=\"$VERSION\"" >> /tmp/vars.tfvars

and the plan job:

- terraform/plan:
    pre-steps:
      - set-image-tag-terraform-var
    name: terraform-plan-staging
    path: terraform-cluster-service
    checkout: true
    context: aws
    persist-workspace: true
    workspace: staging
    var_file: ../../../tmp/vars.tfvars
    requires:
      - terraform-validate-staging
      - pipeline/build-deploy

I have tried unsuccessfully with the pre-step command, grabbing a variable created in another job and creating a new variable:

commands:
  set-image-tag-terraform-var:
    steps:
      - attach_workspace:
          at: /tmp/deploy/workspace
      - run: |
          cat /tmp/deploy/workspace/new-env-vars >> $BASH_ENV
          source $BASH_ENV
          echo $VERSION

and the plan job:

- terraform/plan:
    pre-steps:
      - set-image-tag-terraform-var
    name: terraform-plan-staging
    path: terraform-cluster-service
    checkout: true
    context: aws
    persist-workspace: true
    workspace: staging
    var: image_tag=${VERSION}
    requires:
      - terraform-validate-staging
      - pipeline/build-deploy

but it seems $BASH_ENV is not loaded as $VERSION is empty.

@grasbergerm grasbergerm added the enhancement New feature or request label May 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant