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.
Terraform ์์ํ๊ธฐ w/Minimal Ubuntu
- kkumtree
2023-08-31T22:21:08+09:00
์ด๋ฒ์๋ CloudNet@์์ ์งํํ๋ Terraform ์คํฐ๋(์ดํ, T101)์ ์ฐธ์ฌํ์ต๋๋ค.
Terraform์ ์ฐ๋ฉด ์ ์ข์์ง๋ ์์ธํ๊ณ ์ ๋ฌธ์ ์ธ ๊ธ์ด ์์ผ๋ฏ๋ก, ์ฐธ๊ณ ํ์๋ฉด ์ข์ ๊ฒ ๊ฐ์ต๋๋ค. (๋งํฌ: 44bits)
์์ ์ ํ
๋ผํผ์ ์ผ๋ ์ ์ด ์์ง๋ง, Moduleํ๊ฐ ์ด๋ ต๊ธฐ๋ ํ๊ณ
์ด๋ฒ ๊ธฐํ์ ํ
๋ผํผ ์ ๊ฐ์ ๋ค์ ๋ณต๊ธฐํ๋ ๋ง์์ผ๋ก ์ฐธ์ฌํ์ต๋๋ค.
์ฌ์ฉํ ๊ต์ฌ๋ [ํ ๋ผํผ์ผ๋ก ์์ํ๋ IaC] ์ ๋๋ค.
์ด๋ฒ์๋ Terraform ์ด๊ธฐ ์
์
์ ๋ํด, ์ดํด๋ณด๊ณ
์ํ์ผ์ Canonical ๊ณต์ Minimal Ubuntu(ARM64) AMI๋ฅผ ์ค์นํด๋ณด๊ฒ ์ต๋๋ค.
- Terraform ์ค์น
- tfenv ์ฌ์ฉ๊ณผ .tf ์์ฑ ๋ฐ๋ผํ๊ธฐ
- Hello World in terraform
- Terraform ์จ๋ณด๊ธฐ
์์ผ๋ก ์งํํฉ๋๋ค.
Terraform ์ค์น
Terraform์ Linux ํ๊ฒฝ(Ubuntu ๊ธฐ์ค)์์ ์ค์นํ ์ ์๋ ๋ฐฉ๋ฒ์ด 3๊ฐ์ง ์ ๋ ์์ต๋๋ค.
์ต์ ๋ด์ฉ์ Terraform CLI์์ ํ์ธํ ์ ์์ต๋๋ค.