Tfenv

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 terraformer command!
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์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

kkumtree

Source code on GitHub

ยฉ 2025 kkumtree and contributors All rights reserved.
Licensed under
CC BY-NC-ND 4.0