rackspace / runway

Simplify infrastructure/app deployment.
https://runway.readthedocs.io
Apache License 2.0
157 stars 65 forks source link

[BUG] Unable to specify custom .tfvars location with plan #1543

Open mbordash2 opened 2 years ago

mbordash2 commented 2 years ago

Bug Description

Runway will look in the root module directory for the tfvars file for an environment and if it is not present, it will return an error.

When you want to define your var files in another location, runway doesn't look to see if you specify a custom -var-file location and requires a placeholder file to be present. As you can see below both .tfvars are added to the command which is not necessary.

VERBOSE:runway.core.components.module:External ALB.env-terraform:module payload: {"options": {"terraform_write_auto_tfvars": true, "args": ["-var-file=vars/dev.tfvars"], "terraform_backend_config": {"bucket": "infra-terraform-state", "region": "us-east-1", "dynamodb_table": "dev-us-east-1-tf-lock-table"}}, "parameters": {}, "class_path": null, "environments": {}, "name": "env-terraform", "path": "external-alb/env-terraform", "tags": [], "type": "terraform", "parallel": [], "explicitly_enabled": true}
Exec: "/opt/homebrew/Cellar/tfenv/2.2.2/bin/tfenv" exec "apply -var-file=dev.tfvars -var-file=vars/dev.tfvars -auto-approve=false"

Also, plan does not even pick up the arg so it will not work at all with a custom .tfvars location.

Expected Behavior

It should not be required to have a ENV.tfvars file in the root directory if -var-file= is specificed in the args:.

apply and plan should have equivalent functionality.

Steps To Reproduce

  - name: External ALB
    modules:
      - path: external-alb/env-terraform
        type: terraform
        options:
          terraform_write_auto_tfvars: true
          args:
            - '-var-file=vars/${env DEPLOY_ENVIRONMENT}.tfvars'
          terraform_backend_config:
            bucket: ${var tf_state_bucket.${env DEPLOY_ENVIRONMENT}}
            region: us-east-1
            dynamodb_table: ${var dynamodb_table.${env DEPLOY_ENVIRONMENT}}

Runway version

2.6.2

Installation Type

pypi (pip, pipenv, poetry, etc)

OS / Environment

Anything else?

No response

jake-skipper commented 2 years ago

Fix for this is upcoming in MSI-701.