terraformer 설치 및 실행

scvit·2023년 10월 25일

설치

brew install terraformer

  • Plugin 설치
wget https://releases.hashicorp.com/terraform-provider-aws/5.22.0/terraform-provider-aws_5.22.0_darwin_arm64.zip
mv terraform-provider-aws_5.22.0_darwin_arm64.zip ~/.terraform.d/plugins/darwin_arm64
cd ~/.terraform.d/plugins/darwin_arm64
unzip terraform-provider-aws_5.22.0_darwin_arm64.zip


실행

terraformer import aws --resource=<뽑을 리소스> --regions=<뽑을 리전> 
  • --filter
    • 태그의 이름으로 필터링해서 원하는 값만 뽑고싶다
    • 예 : --filter="Name=tags.Name;Value=mwjo-test-igw"


Provider 수정 필요

  • terraform init 에서 발생 에러
 Error: Invalid legacy provider address
│ 
│ This configuration or its associated state refers to the unqualified provider "aws".
│ 
│ You must complete the Terraform 0.13 upgrade process before upgrading to later versions.

.state 파일의 provider가 달라서 발생하는 문제

terraformer로 뽑은 .tfstate

 "provider": "provider.aws"

실제 code에서의 provider

 "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]"

.tfstate 가 있는 경로에서 provider를 변경하면 해결

terraform state replace-provider -- -/aws hashicorp/aws

이후 terraform init -> plan 으로 terraformer가 일치하게 뽑아냈는가 확인해보기 !

참조 링크 https://teichae.tistory.com/entry/terraformer%EB%A5%BC-%EC%9D%B4%EC%9A%A9%ED%95%98%EC%97%AC-aws-resource-import-%ED%95%B4%EB%B3%B4%EA%B8%B0

0개의 댓글