rover
rover copied to clipboard
Add "terraform show" to rover command
hi @naeemdhby, can you add syntax examples please? I always get
Terraform init return code 0
calling show
@calling show
running terraform show with -plan /home/vscode/.terraform.cache/contoso-sandpit/rover_jobs/20220727025455088189884/tfstates/level1/tfstate/d1s146-ddd1we.tfplan
-TF_VAR_workspace: tfstate
-state: /home/vscode/.terraform.cache/contoso-sandpit/rover_jobs/20220727025826081804675/tfstates/level0/tfstate/examples.tfstate
-plan: /home/vscode/.terraform.cache/contoso-sandpit/rover_jobs/20220727025826081804675/tfstates/level0/tfstate/examples.tfplan
null
Terraform show return code: 0
@calling clean_up_variables
cleanup variables
clean_up backend_files
Hi @arnaudlh , rover show command will read tfstate file output, so first need to do rover apply, and then do rover show. @onlyillusion I think would be a good idea to rover show also read tfplan file as well, for example, have a condition to read plan file if passed on as argument, otherwise read from tfstate file.
Hey, we need this parameter to create json files out off the tfplan files for infracost. it also a good option to read tfplan file as well.
I have modified your PR to make it working. Here the steps:
- run a normal rover plan or apply (rover displays where the plan or tfstate got created.)
- rover -a show [-json] [path to plan or tfstate] -o [path to json output]
- cat [path to json output] | jq
With the json file:
rover \
-lz /tf/caf/landingzones/caf_launchpad \
-var-folder /tf/caf/configuration/level0/launchpad \
-tfstate_subscription_id xxx \
-target_subscription xxx \
-tfstate caf_launchpad.tfstate \
-launchpad \
-level level0 \
-p ${TF_DATA_DIR}/caf_launchpad.tfstate.tfplan \
-o ${TF_DATA_DIR}/caf_launchpad.tfstate.tfplan.json \
-a show -json ${TF_DATA_DIR}/caf_launchpad.tfstate.tfplan
Without:
rover \
-lz /tf/caf/landingzones/caf_launchpad \
-var-folder /tf/caf/configuration/level0/launchpad \
-tfstate_subscription_id xxx \
-target_subscription xxx \
-tfstate caf_launchpad.tfstate \
-launchpad \
-level level0 \
-p ${TF_DATA_DIR}/caf_launchpad.tfstate.tfplan \
-a show ${TF_DATA_DIR}/caf_launchpad.tfstate.tfplan