refined-lamp-66835
02/07/2024, 6:41 PMrefined-lamp-66835
02/07/2024, 6:42 PMterraform init --backend-config=vars/backend.conf
what would be the eqauivalent of this using the terraform_deployment targetcareful-address-89803
02/07/2024, 10:39 PMrefined-lamp-66835
02/08/2024, 8:26 AMrefined-lamp-66835
02/08/2024, 8:31 AMError: error loading state: unsupported checkable object kind "var"
Maybe its because of older terraform version used by pants.
Is there a way where we can specify which terraform version to be used by pants.curved-television-6568
02/08/2024, 9:03 AMIs there a way where we can specify which terraform version to be used by pants.yes, see: https://www.pantsbuild.org/2.18/reference/subsystems/download-terraform
refined-lamp-66835
02/08/2024, 1:43 PMUnknownVersion: No known version of terraform 1.7.2 for macos_x86_64 found in ('1.4.6|macos_curved-television-6568
02/08/2024, 1:48 PMrefined-lamp-66835
02/08/2024, 1:50 PM<version>|<name>|<sha256sum>|<?>
1.4.6|macos_x86_64|5d8332994b86411b049391d31ad1a0785dfb470db8b9c50617de28ddb5d1f25d|22051279
So how do we get the name is it anything we can provide or you have some predefined name or naming schems?
Whats the very last part <?>?careful-address-89803
02/08/2024, 5:42 PMrefined-lamp-66835
02/08/2024, 6:18 PMrefined-lamp-66835
02/08/2024, 6:22 PMrefined-lamp-66835
02/08/2024, 7:01 PM:29:06.28 [INFO] pantsd started
00:29:06.63 [INFO] Initializing scheduler...
00:29:12.41 [INFO] Scheduler initialized.
00:29:17.72 [INFO] Deploying targets...
╷
│ Error: Backend initialization required, please run "terraform init"
│
│ Reason: Initial configuration of the requested backend "s3"
│
│ The "backend" is the interface that Terraform uses to store state,
│ perform operations, etc. If this message is showing up, it means that the
│ Terraform configuration you're using is using a custom configuration for
│ the Terraform backend.
│
│ Changes to backend configurations require reinitialization. This allows
│ Terraform to set up the new configuration, copy existing state, etc. Please run
│ "terraform init" with either the "-reconfigure" or "-migrate-state" flags to
│ use the current configuration.
│
│ If the change reason above is incorrect, please verify your configuration
│ hasn't changed and try again. At this point, no changes to your existing
│ configuration or state have been made.
╵
✕ terraform/environments:staging failedrefined-lamp-66835
02/08/2024, 7:01 PMcareful-address-89803
02/09/2024, 4:14 AMrefined-lamp-66835
02/09/2024, 4:16 AMterraform init -reconfigure commandrefined-lamp-66835
02/09/2024, 4:17 AM-reconfigure arugment to terraform initcareful-address-89803
02/09/2024, 6:06 AMinit process. I thought there was, but they're only passed to the apply process. I think you'd need to manually run the upgrade, and then Pants should use the migrated state.
the TF backend runs init and then apply . Seeing 'please run "terraform init"' and 'Initial configuration of the requested backend "s3"' made me think that init had failed, Pants swallowed the error, and then the deployment wasn't initialised. Another reason I'm concerned that's the case is that the TF backend doesn't keep a persistent initialised ".terraform" directory, so it shouldn't have a backend that needs to be reconfigured (although I've never used the s3 backend). you could check with pants check on the root module of the deployment, as that runs terraform init -backend=false which might show an init error.
you migth also run it with keep-sandboxes=always which should keep the Pants sandbox around. You could then open it and manually edit the command. But that seems like a lot more workcareful-address-89803
02/09/2024, 6:09 AM-reconfigure or -migrate-state? I don't think I've used either of themrefined-lamp-66835
02/09/2024, 6:13 AMs3 to local or any other backend. then we need to run -migrate-state backend.refined-lamp-66835
02/09/2024, 6:13 AMrefined-lamp-66835
02/09/2024, 6:14 AMrefined-lamp-66835
02/09/2024, 6:18 AMcareful-address-89803
02/09/2024, 6:29 AMrefined-lamp-66835
02/09/2024, 6:54 PMcareful-address-89803
02/10/2024, 5:06 AMrefined-lamp-66835
02/12/2024, 7:09 AMterraform init command is popping up again. Basically on local it was solved by keeping the sandbox and then manually running terraform command with required args.
But since this propblem is occuring in CI pipeline i.e github action. There is no way to keep the sandbox and run this command manually there. So far I have tried to look into this. There is an option to pass args via environment variable. https://developer.hashicorp.com/terraform/cli/config/environment-variables#tf_cli_args-and-tf_cli_args_name. I am able to use this option on local. But its not helping me in CI.
So for now looks like passing extra args through pants is the only option. let me know if there is workaround in pants for this. So far have looked in to terraform_download subsystem, terraform_deployment target and experimental-deploy goal. Nothing helpful found or I at least I am not able to find it.refined-lamp-66835
02/12/2024, 7:16 AMcareful-address-89803
02/12/2024, 5:06 PM[download_terraform].extra_env_vars would work locally but not in CI.
There currently isn't a way to pass extra cli args to the terraform init invocation.
You should be able to run the terraform commands directly still.careful-address-89803
02/12/2024, 5:09 PMrefined-lamp-66835
02/13/2024, 6:04 AMcareful-address-89803
02/13/2024, 6:33 AMTerraformTool, called something like extra_init_args, similar to args here. I think you'll have to set passthrough to false, I'm pretty sure there can be only 1 passthrough option.
2. request the TerraformTool in get_terraform_providers here. There's an example of how to do that here
3. add the value of the option to the args, like here
I hope that helps! If you'd like more guidance or help you can ping me, either here on in direct messages