boltops-tools / terraspace

Terraspace: The Terraform Framework
https://terraspace.cloud
Apache License 2.0
674 stars 46 forks source link

Terraspace >= 2.0 returns -detailed-exitcode 1 when plan is successful with diff to apply (Should be exit code 2) #270

Open djbr33ze opened 2 years ago

djbr33ze commented 2 years ago

Checklist

My Environment

Software Version
Operating System Mac OS 12.6
Terraform v 1.3.0
Terraspace v 2.2.2
Ruby v 3.0.0

Expected Behaviour

terraspace plan app1 -detailed-exitcode should return a detailed-exitcode value of '2' if the plan is successful with a diff to apply. (This only happens with terraspace > 1.1.7)

Current Behavior

The detailed exit code returned by terraspace is '1'. However when I run terraform plan -detailed-exitcode in the .terraspace-cache folder, I can confirm that terraform returns an exit code of '2' as expected.

Step-by-step reproduction instructions

terraspace plan locks -detailed-exitcode

Terraspace Plan Output and Debug Logs Terraform will perform the following actions: azurerm_management_lock.rg_infnet_lock will be destroyed (because azurerm_management_lock.rg_infnet_lock is not in configuration) - resource "azurerm_management_lock" "rg_infnet_lock" { - id = "HIDDEN" -> null - lock_level = "CanNotDelete" -> null - name = "rg-us-psoi-pa-inf-net-del-lock" -> null - notes = "Notes for the lock on the rg rg-us-psoi-pa-inf-net" -> null - scope = "HIDDEN" -> null } Plan: 0 to add, 0 to change, 1 to destroy. D, [2022-09-22T10:22:45.240901 #65241] DEBUG -- : Backend change detected. Removing .terraspace-cache for complete reinitialization I, [2022-09-22T10:22:45.259374 #65241] INFO -- : Building .terraspace-cache/canadacentral/dev/stacks/locks D, [2022-09-22T10:22:45.275059 #65241] DEBUG -- : Created .terraspace-cache/canadacentral/dev/stacks/locks/backend.tf D, [2022-09-22T10:22:45.284073 #65241] DEBUG -- : Created .terraspace-cache/canadacentral/dev/stacks/locks/provider.tf D, [2022-09-22T10:22:45.294366 #65241] DEBUG -- : Created .terraspace-cache/canadacentral/dev/stacks/locks/00-main.tf D, [2022-09-22T10:22:45.303008 #65241] DEBUG -- : Created .terraspace-cache/canadacentral/dev/stacks/locks/01-aks-clusters-lock.tf D, [2022-09-22T10:22:45.312175 #65241] DEBUG -- : Created .terraspace-cache/canadacentral/dev/stacks/locks/02-resource-groups-lock.tf D, [2022-09-22T10:22:45.320726 #65241] DEBUG -- : Created .terraspace-cache/canadacentral/dev/stacks/locks/03-storage-accounts-locks.tf D, [2022-09-22T10:22:45.328964 #65241] DEBUG -- : Created .terraspace-cache/canadacentral/dev/stacks/locks/README.md D, [2022-09-22T10:22:45.337935 #65241] DEBUG -- : Created .terraspace-cache/canadacentral/dev/stacks/locks/config.auto.tfvars D, [2022-09-22T10:22:45.347094 #65241] DEBUG -- : Created .terraspace-cache/canadacentral/dev/stacks/locks/variables.tf D, [2022-09-22T10:22:45.348082 #65241] DEBUG -- : Layers for locks: D, [2022-09-22T10:22:45.348381 #65241] DEBUG -- : Built in .terraspace-cache/canadacentral/dev/stacks/locks I, [2022-09-22T10:22:46.954640 #65241] INFO -- : Current directory: .terraspace-cache/canadacentral/dev/stacks/locks D, [2022-09-22T10:22:47.949776 #65241] DEBUG -- : Resource Group rg-us-psoi-pa-inf-cicd already exists D, [2022-09-22T10:22:48.741369 #65241] DEBUG -- : Storage Account pccstguspainftf already exists D, [2022-09-22T10:22:49.193802 #65241] DEBUG -- : Storage Blob Container psoi-inrastructure-terraform-state already exists I, [2022-09-22T10:22:49.195339 #65241] INFO -- : => terraform init -get -input=false >> /tmp/terraspace/log/init/locks.log I, [2022-09-22T10:23:02.842429 #65241] INFO -- : => terraform plan -detailed-exitcode -input=false

Code Sample

  1. terraspace plan app1 -detailed-exitcode (ensure there is a diff to apply)

  2. echo $? (validate exitcode is 1 where it should be 2)