boltops-tools / terraspace

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

'terraspace all' commands not passing through terraform-specific arguments to terraform #295

Open alexpilon666 opened 1 year ago

alexpilon666 commented 1 year ago

Checklist

My Environment

Software Version
Operating System Kubuntu 22.04.1
Terraform 1.3.9
Terraspace 2.2.3
Ruby 3.0.3p157

Expected Behaviour

The underlying terraform command should receive the passed-through terraspace all arguments, such as terraspace all plan <stackName> -destroy --> terraform plan -destroy.

Current Behavior

The underlying terraform command does not receive terraspace all arguments, and uses the default terraform <cmd> -input=false command every time. This seems to only be true when using terraform-specific arguments, like -destroy, -refresh=false. When using --out <planName> it works properly.

Step-by-step reproduction instructions

To reproduce:

╭─pilona@ ~/GIT_PROJECTS/terraspace β•°β”€βž€ TS_ENV=dev TS_EXTRA='edu' TS_BUFFER_TIMEOUT=10800 terraspace plan -refresh=false

Building .terraspace-cache/canadacentral/dev/stacks/.edu config/terraform/tfvars/base.tfvars config/terraform/tfvars/dev.tfvars config/terraform/tfvars/edu.tfvars config/terraform/tfvars/dev-edu.tfvars config/terraform/tfvars/canadacentral.tfvars config/terraform/tfvars/canadacentral/base.tfvars config/terraform/tfvars/canadacentral/dev.tfvars config/terraform/tfvars/canadacentral/edu.tfvars config/terraform/tfvars/canadacentral/dev-edu.tfvars app/stacks//tfvars/base.tfvars (found) app/stacks//tfvars/dev.tfvars app/stacks//tfvars/edu.tfvars app/stacks//tfvars/dev-edu.tfvars app/stacks//tfvars/canadacentral.tfvars app/stacks//tfvars/canadacentral/base.tfvars app/stacks//tfvars/canadacentral/dev.tfvars app/stacks//tfvars/canadacentral/edu.tfvars app/stacks//tfvars/canadacentral/dev-edu.tfvars (found) Current directory: .terraspace-cache/canadacentral/dev/stacks/.edu => terraform plan -refresh=false -input=false data.azurerm_client_config.this: Reading... data.azurerm_client_config.this: Read complete after 0s [id=Y2xpZW50Q29uZmlncy9jbGllbnRJZD02ODI1NTdmYS0zYjFmLTQzODItYmQyOS01ZjZhOTk4NjVjNWM7b2JqZWN0SWQ9YmY3MTIxZmQtOTY5Yy00OGVkLWIxODctOTdhYzQwYmQ4NzA2O3N1YnNjcmlwdGlvbklkPWFiY2RkMGE3LTg0ZmYtNGM5Yy1iMDY2LTY3OGY5MTQyOWQwNTt0ZW5hbnRJZD01NTFlYmU3Yy00NzdkLTQ2MDctYjlhNi0xMDFlZTM2NWU3NzU=]

No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.

╭─pilona@MTLWINMN156 ~/GIT_PROJECTS/terraspace β•°β”€βž€ TS_ENV=dev TS_EXTRA='edu' TS_BUFFER_TIMEOUT=10800 terraspace all plan -refresh=false; terraspace logs plan -a

Running: terraspace plan # batch 1 Batch Run 1: Running: terraspace plan Logs: log/plan/.log terraspace plan : Plan: 0 to add, 2 to change, 0 to destroy. Time took: 18s Showing: log/plan/.log [2023-03-01T12:54:13 #1963584 terraspace plan ]: Current directory: .terraspace-cache/canadacentral/dev/stacks/.edu [2023-03-01T12:54:15 #1963584 terraspace plan ]: => terraform plan -input=false [2023-03-01T12:54:26 #1963584 terraspace plan ]: data.azurerm_client_config.this: Reading... [2023-03-01T12:54:26 #1963584 terraspace plan ]: module.resource_group.azurerm_resource_group.this: Refreshing state... [id=] [2023-03-01T12:54:26 #1963584 terraspace plan ]: data.azurerm_client_config.this: Read complete after 0s [id=Y2xpZW50Q29uZmlncy9jbGllbnRJZD02ODI1NTdmYS0zYjFmLTQzODItYmQyOS01ZjZhOTk4NjVjNWM7b2JqZWN0SWQ9YmY3MTIxZmQtOTY5Yy00OGVkLWIxODctOTdhYzQwYmQ4NzA2O3N1YnNjcmlwdGlvbklkPWFiY2RkMGE3LTg0ZmYtNGM5Yy1iMDY2LTY3OGY5MTQyOWQwNTt0ZW5hbnRJZD01NTFlYmU3Yy00NzdkLTQ2MDctYjlhNi0xMDFlZTM2NWU3NzU=] [2023-03-01T12:54:26 #1963584 terraspace plan ]: module.content_notification_sbus.module.this["edu-"].azurerm_servicebus_namespace.this: Refreshing state... [id=] ...

... [2023-03-01T12:54:32 #1963584 terraspace plan ]: [2023-03-01T12:54:32 #1963584 terraspace plan ]: Plan: 0 to add, 2 to change, 0 to destroy. [2023-03-01T12:54:32 #1963584 terraspace plan ]: [2023-03-01T12:54:32 #1963584 terraspace plan ]: [2023-03-01T12:54:32 #1963584 terraspace plan ]: ───────────────────────────────────────────────────────────────────────────── [2023-03-01T12:54:32 #1963584 terraspace plan ]: [2023-03-01T12:54:32 #1963584 terraspace plan ]: Note: You didn't use the -out option to save this plan, so Terraform can't [2023-03-01T12:54:32 #1963584 terraspace plan ]: guarantee to take exactly these actions if you run "terraform apply" now. ## Code Sample Cannot provide code sample as this is all specific and confidential to our company, and the issue seems to be between `terraspace` and `terraform` themselves, not because of code. ## Solution Suggestion Just like with regular non-`all` commands, `terraspace all` commands should be passing all of their arguments to the underlying `terraform` commands, whether they be native `terraspace` arguments or native `terraform` arguments.
cshintov commented 1 year ago

As far as I know terraspace doesn't pass such arguments to terraform unless there's a wrapper already.

For example you can do terraspace output for the whole stack. But can't get value of individual output. Also -target is also not implemented.