Troubleshoot when using terraformer with tfenv
- kkumtree
2023-09-24T11:47:51+09:00
Removing & installing packages are some annoying, isn’t it? So, I like using version managers like SDKMAN, nvm, etc..
I also use tfenv for terraform version management.
(prev post: KR/‘Terraform μμνκΈ° w/Minimal Ubuntu’)
And I recommend neighbors to use terraformer for first learning about terraform.
terraformer is a great terraform generator tool for converting existing cloud infrastructure to terraform code.
In this post, I write how I use terraformer with tfenv.
1. How to install terraformer in Linux
- After follow below, you can use terraformer with
terraformercommand!
export PROVIDER=aws
# you can use other providers like 'google, kubernetes',
# Or if you want to use all providers, adjust 'all' instead of 'aws'
curl -LO "https://github.com/GoogleCloudPlatform/terraformer/releases/download/$(curl -s https://api.github.com/repos/GoogleCloudPlatform/terraformer/releases/latest | grep tag_name | cut -d '"' -f 4)/terraformer-${PROVIDER}-linux-amd64"
chmod +x terraformer-${PROVIDER}-linux-amd64
sudo mv terraformer-${PROVIDER}-linux-amd64 /usr/local/bin/terraformer
2. Importing AWS VPC with terraformer
- After install terraformer, you can import AWS VPC with terraformer like below
(Also you can import other AWS resources like EC2, S3, etc..)
terraformer import aws --resources=vpc --regions=ap-northeast-2
- But, error will happen… if you use tfenv like me.
$ terraformer import aws --resources=vpc --regions=ap-northeast-2
2023/09/24 12:03:53 aws importing region ap-northeast-2
2023/09/24 12:03:53 open /home/kkumtree/.terraform.d/plugins/linux_amd64: no such file or directory
$ whereis terraform
terraform: /home/kkumtree/.tfenv/bin/terraform
-
As you can see, terraformer can’t find terraform binary.