Open3
既存リソースのterraform化

- terraform importでtfstateを更新
- tfファイルを更新
- terraform planで更新がないことを確認

とおもいきやtfファイルも作ってくれるterraformerというものがあるっぽい

既存のALBのterraform化
適当にALB作る
terraformerのインストール
$ brew install terraformer
対応しているリソース一覧
provider用意する
provider "aws" {
region = "ap-northeast-1"
}
$ terraform init
$ terraformer import aws --regions=ap-northeast-1 --resources=alb --profile ""
profileの設定のバグ?
やったぜ
upgrade
$ terraform state replace-provider -auto-approve "registry.terraform.io/-/aws" "hashicorp/aws"
tfファイルが生成された場所に移動してterraform init
terraform plan
で差分がないことを確認
- before
- after
$ terraform apply
完了