terraformerを使ってコード化対応
手動で管理していたCloudDNSをコード管理したかったので、terraformerを使ってコード化しました。
Installation
brew install terraformer
事前準備
コマンド実行したら以下エラーが出たので、ディレクトリにpluginをinstall
Copy your Terraform provider's plugin(s) to folder ~/.terraform.d/plugins/{darwin,linux}_amd64/, as appropriate.
mkdir -p ~/.terraform.d/plugins/darwin_amd64
cd ~/.terraform.d/plugins/darwin_amd64
wget https://releases.hashicorp.com/terraform-provider-google/2.17.0/terraform-provider-google_2.17.0_darwin_amd64.zip
unzip terraform-provider-google_2.17.0_darwin_amd64.zip
Command実行
CloudDNSの以下リソースのコード化を実行
terraformer import google --resources=dns --projects=hogehoge --regions=asia-northeast1
2019/10/23 13:47:53 google importing project hogehoge region asia-northeast1
2019/10/23 13:47:54 google importing... dns
...
2019/10/23 13:48:00 google Connecting....
2019/10/23 13:48:00 google save dns
2019/10/23 13:48:00 google save tfstate for dns
tfstateファイルとtfファイルが作成されていることを確認
ll generated/google/hogehoge/dns/asia-northeast1/
default.tfstate*
dns_managed_zone.tf*
dns_record_set.tf*
outputs.tf*
provider.tf*
