aztfmod / rover

The rover is a docker container in charge of the deployment of the Terraform platform engineering for Azure
MIT License
173 stars 144 forks source link

Export JSON format for Terraform plan #181

Closed arnaudlh closed 2 years ago

arnaudlh commented 3 years ago

For plan security analysis, we need to have the output of the Terraform in JSON format

terraform show -json tfplan.tfplan > tfplan.json
LaurentLesle commented 2 years ago

Consider running the following commands:

rover \
  -lz /tf/caf/landingzones/caf_launchpad \
  -var-folder /tf/caf/configuration/contoso/platform/level0/launchpad \
  -tfstate_subscription_id <guid>\
  -target_subscription <guid> \
  -tfstate caf_launchpad.tfstate \
  -log-severity ERROR \
  -launchpad \
  -env contoso \
  -level level0 \
  -p ${TF_DATA_DIR}/caf_launchpad.tfstate.tfplan \
  -a plan

# then
terraform show -json ${TF_DATA_DIR}/caf_launchpad.tfstate.tfplan > ${TF_DATA_DIR}/tfplan.json