Open raspbeguy opened 5 months ago
What is the error message you are receiving when using the terraform_state
plugin? Also, what version of the cloud.terraform
collection and Ansible are you using?
I'm using master version on the plugins.
I have got this error:
[WARNING]: * Failed to parse /home/ggodfroy/repo/metrics-infra/ansible/environments/preprod-test/terraform_state.yml with auto plugin: Command '['tofu', 'init', '-input=false', '-no-color', '-backend-config',
'hostname=terraform.mydomain.examples', '-backend-config', 'organization=my-org', '-backend-config', "workspaces={'name': 'my-workspace'}"]' returned non-zero exit status 1.
When I execute this tofu command myself I get this error:
OpenTofu initialized in an empty directory!
The directory has no OpenTofu configuration files. You may begin working
with OpenTofu immediately by creating OpenTofu configuration files.
I guess there is no way to change directory in terraform_state
. Also I don't know why I functionally would need some terraform/tofu config because I normally provided everything the plugin needs to fetch states.
Same error with tofu and terraform btw.
SUMMARY
As I understand there is two way to build an inventory using terraform states:
cloud.terraform.terraform_state
to query directly a state backend using provided backend configurationcloud.terraform.terraform_provider
to query stated through local terraform projectI didn't manage to use
terraform_state
, with the following configuration:For that reason I'm using Terraform Cloud with multiple workspaces. For now I'm successfully using
terraform_provider
. My terraform configuration looks like this:I use
tags
instead ofworkspace
parameter to enable using several workspaces.The problem with
terraform_provider
is that I have to manually switch to the desired workspace by typing:I would rather have an option in
terraform_provider
to specify the workspace.Another option would be to make
terraform_state
work with the remote option.ISSUE TYPE
COMPONENT NAME
cloud.terraform.terraform_state
cloud.terraform.terraform_provider