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

How can I run rover while passing tfvars locally #10

Closed
pankajshrestha opened this issue Aug 18, 2021 · 1 comment
Closed

How can I run rover while passing tfvars locally #10

pankajshrestha opened this issue Aug 18, 2021 · 1 comment

Comments

@pankajshrestha
Copy link

Hello,

Very excited to try this out. I have downloaded the file locally in mac and trying to run from root of TF, how can I pass *.tfvars file when running rover?

Looks like there is option for passing some kind of config but did not see example of how pass this.

Appreciate suggestions on this.

Thanks

@Xide
Copy link
Contributor

Xide commented Aug 19, 2021

Hello !

Running rover --help explain how to use the tfVar and tfVarsFile, among others.

In order to use a .tfvars file, you an use this command: rover -tfVarsFile /path/to/test.tfvars
Be sure to use the key-value (i.e: name=value) format fot your tfvars file, JSON is not yet parsed corrctly by rover.

In order to convert a JSON into a tfvars, you can use the following snippet:

# Input file
ofile="/path/to/test.tfvars.json"
# Output file
vfile=$(mktemp)

# JSON -> KV variables
cat ${ofile} | \
  jq -r '. as $in | keys[] | [.]+["=\""]+[$in[.]]+["\""] | map(tostring) | add' > \
  ${vfile}

If you are running Rover in Docker, you'll also need to mount the variables file into the container:

vfile="/path/to/test.tfvars"
TERRAFORM_FILES_DIR="/path/to/terraform_files"

docker run \
  --rm \
  -it \
  -p 9000:9000 \
  -v "${vfile}:/vars:ro" \
  -v ${TERRAFORM_FILES_DIR}:/src \
  im2nguyen/rover \
  -tfVarsFile /vars"

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