At the moment the rover apply is running a terraform plan and apply behind the scene. This issue fix that and propose the following:
if no plan is provided then rover apply will execute rover plan and apply
If a plan is provided as a parameter rover apply will use that plan instead of creating a new one
The scenario we want to cover are
Run rover plan in cd pipelines and store the plan in an artifact repo
Perform a review
Execute the apply based on the plan stored in the artifact
Commands to separate plan from apply and destroy.
Plan for an apply
# Rover plan for an apply
rover \
-lz /tf/caf/landingzones/caf_launchpad \
-var-folder /tf/caf/configuration/contoso/platform/demo/level0/launchpad \
-tfstate_subscription_id ${tfstate_subscription_id} \
-target_subscription ${target_subscription} \
-tfstate caf_launchpad.tfstate \
-log-severity ERROR \
-launchpad \
-env it-sre \
-level level0 \
-p ${TF_DATA_DIR}/tf_plan_launchpad.tfplan \
-a plan
# Rover apply based on the previous plan
rover \
-lz /tf/caf/landingzones/caf_launchpad \
-var-folder /tf/caf/configuration/contoso/platform/demo/level0/launchpad \
-tfstate_subscription_id ${tfstate_subscription_id} \
-target_subscription ${target_subscription} \
-tfstate caf_launchpad.tfstate \
-log-severity ERROR \
-launchpad \
-env it-sre \
-level level0 \
-p ${TF_DATA_DIR}/tf_plan_launchpad.tfplan \
-a apply
Plan for a destroy
# Rover plan for a destroy
rover \
-lz /tf/caf/landingzones/caf_launchpad \
-var-folder /tf/caf/configuration/contoso/platform/demo/level0/launchpad \
-tfstate_subscription_id ${tfstate_subscription_id} \
-target_subscription ${target_subscription} \
-tfstate caf_launchpad.tfstate \
-log-severity ERROR \
-launchpad \
-env it-sre \
-level level0 \
-p ${TF_DATA_DIR}/tf_plan_launchpad.tfplan \
-a plan -destroy
# Rover destroy based on the previous plan. Note -var-folder, -var-file or -var must be removed from the command line.
# As the destroy is now based on the plan, terraform is not prompting for the confirmation to destroy the resources
rover \
-lz /tf/caf/landingzones/caf_launchpad \
-tfstate_subscription_id ${tfstate_subscription_id} \
-target_subscription ${target_subscription} \
-tfstate caf_launchpad.tfstate \
-log-severity ERROR \
-launchpad \
-env it-sre \
-level level0 \
-p ${TF_DATA_DIR}/tf_plan_launchpad.tfplan \
-a destroy
At the moment the rover apply is running a terraform plan and apply behind the scene. This issue fix that and propose the following:
The scenario we want to cover are
Commands to separate plan from apply and destroy.
Plan for an apply
Plan for a destroy
Previous commands are still working