Azure / aztfexport

A tool to bring existing Azure resources under Terraform's management
https://azure.github.io/aztfexport/
Mozilla Public License 2.0
1.63k stars 190 forks source link

Terraform binary not found #547

Closed manotux closed 3 months ago

manotux commented 4 months ago

The terraform cli tool is installed:

$ terraform version
Terraform v1.6.3-dev
on linux_amd64

$ whereis terraform                                                                                                           
terraform: /usr/bin/terraform

The linux amd64 binary was downloaded:

$ whereis aztfexport
aztfexport: /usr/local/bin/aztfexport

$ aztfexport -v                                            
aztfexport version v0.14.2(523f5b8)

But for any command I get the following error stating the terraform binary is not found in $PATH

 error finding a terraform exectuable: unable to find, install, or build from 1 sources: 1 error occurred:
        * terraform: executable file not found in $PATH       

Any clues?

magodo commented 4 months ago

@manotux There might be several reasons:

manotux commented 3 months ago

Thanks for the quick reply.

I've been able to use the terraform binary normally, so I don't think the $PATH or binary exec permission are a problem here. Just in case:

$ ls -l /usr/bin/terraform
-rwxr-xr-x 1 root root 80900136 Nov  2  2023 /usr/bin/terraform

Somehow this code or hc-install is not being able to identity the binary in my system correctly. Any ideas in how to resolve this? I use Kali 2024.2 distro.

Thanks

magodo commented 3 months ago

@manotux The hc-install has also a version constraint on the terraform, which must be >=0.12. Would you please check the terraform version installed on your host?

https://github.com/Azure/aztfexport/blob/d8b7462eead23ad59b5dc5cd893085b729b9b9fb/internal/meta/tfinstall_find.go#L16-L21

manotux commented 3 months ago

@magodo I had already checked that, the terraform version installed is 1.6.3-dev, the one provided on Kali 2024.02.

$ terraform version
Terraform v1.6.3-dev
on linux_amd64

Your version of Terraform is out of date! The latest version
is 1.9.3. You can update by downloading from https://www.terraform.io/downloads.html
$ dpkg -l terraform                       
ii  terraform      1.6.3-0kali1 amd64        tool for building, changing, and versioning infrastructure
magodo commented 3 months ago

With:

func main() {
    c := version.MustConstraints(version.NewConstraint(">=0.12"))
    v := version.Must(version.NewSemver("v1.6.3-dev"))
    fmt.Println(c.Check(v))
}

It prints: false

With v1.6.3, it prints true.

See https://github.com/hashicorp/go-version/issues/36#issuecomment-405297459 for why. So we'd suggest you to install a released version of terraform.

manotux commented 3 months ago

Thanks for your time and verification. I'll consider installing the project binaries rather than using the ones provided by Kali. I've never thought it was a good idea to include strings like '-dev' on package versions; it's not the first time I've seen an issue like that when parsing.