terraform 0.13upgrade 명령

terraform 0.13upgrade 명령

terraform 0.13upgrade 명령은 기존 구성을 업데이트해서 주어진 모듈에서 사용되는 각 프로바이더에 명시적인 source 속성을 추가하는 명령이에요. 프로바이더 소스 설정은 required_providers 블록에 저장돼요.

출처: 문서

본문

이 명령은 Terraform v0.13 릴리스에서만 사용할 수 있어요. 자세한 내용은 Terraform v0.13 업그레이드 가이드를 참고하세요.

사용법 (Usage)

사용법: terraform 0.13upgrade [options] [dir]

0.13upgrade 명령의 주요 목적은 모듈에서 사용 중인 프로바이더를 확인하고, 가능하면 해당 프로바이더의 소스 주소를 감지한 다음, 이 정보를 required_providers 블록에 기록하는 거예요.

참고: 이 명령은 모듈의 .tf.json 파일과 오버라이드 파일을 무시해요.

모듈에 이미 required_providers 블록이 있으면 명령이 이를 제자리에서 업데이트해요. 그렇지 않으면 versions.tf 파일에 새 블록이 추가돼요.

기본적으로 0.13upgrade는 현재 작업 디렉터리의 구성 파일을 변경해요. 그러나 원하면 다른 디렉터리에 대한 명시적 경로를 제공할 수도 있는데, 이는 같은 저장소의 여러 모듈 마이그레이션을 자동화할 때 유용해요.

다른 옵션 없이 실행하면 명령은 먼저 무엇을 할지 설명하고 확인을 요청해요:

$ terraform 0.13upgrade
 
This command will update the configuration files in the given directory to use
the new provider source features from Terraform v0.13. It will also highlight
any providers for which the source cannot be detected, and advise how to
proceed.
 
We recommend using this command in a clean version control work tree, so that
you can easily see the proposed changes as a diff against the latest commit.
If you have uncommited changes already present, we recommend aborting this
command and dealing with them before running this command again.
 
Would you like to upgrade the module in the current directory?
  Only 'yes' will be accepted to confirm.
 
  Enter a value: yes

깨끗한 버전 관리 작업 트리에서 이 명령을 실행할 것을 권장해요. 그러면 VCS 도구를 사용해 제안된 변경(모든 TF-UPGRADE-TODO 주석 포함)을 검토하고, 변경을 커밋하기 전에 필요한 수정을 가할 수 있어요.

커맨드 라인 옵션이 하나 있어요:

  • -yes - 초기 소개 메시지와 대화형 확인을 건너뛰어요. 스크립트에서 명령을 배치로 실행할 때 사용하세요.

배치 사용법 (Batch Usage)

몇 가지 한정된 상황에서 0.13upgrade 명령을 실험한 후, 여러 모듈이 포함된 저장소가 있다면 모두 일괄 업그레이드하고 함께 검토하고 싶을 수 있어요. 도구 자체는 재귀 업그레이드를 지원하지 않지만, Unix 계열 시스템에서는 find 명령을 사용해 다음과 같이 달성할 수 있어요:

$ find . -name '*.tf' | xargs -n1 dirname | uniq | xargs -n1 terraform 0.13upgrade -yes

PowerShell을 사용하는 Windows 시스템에서는 다음 명령을 사용할 수 있어요:

Get-Childitem -Recurse -Include *.tf | Split-Path | `
Select-Object -Unique | ForEach-Object { terraform 0.13upgrade -yes $_.FullName }

위 명령들은 대화형 프롬프트를 재정의하는 -yes 옵션을 포함하므로, 실행하기 전에 깨끗한 작업 트리가 있는지 확인하세요.

더 알아보기 (Learn more)