이 단계에서는 먼저 Terraform 프로젝트를 초기화한 다음 terraform plan 명령을 실행하여 실행 계획 (execution plan) 을 생성합니다.
변경 사항을 계획하기 전에 프로젝트를 초기화해야 합니다. terraform init 명령은 구성을 스캔하고 필요한 프로바이더 (이 경우 local_file용) 를 다운로드하며 백엔드를 설정합니다.
터미널에서 먼저 terraform init을 실행합니다.
terraform init
초기화가 성공적으로 완료되면 terraform plan을 실행합니다. 이 명령은 변경 사항에 대한 "드라이 런 (dry run)"을 제공하므로 Terraform 워크플로우의 중요한 부분입니다. 실제로 변경 사항을 적용하지 않고 Terraform 이 인프라에 대해 수행할 작업을 보여줍니다. 이를 통해 의도된 작업을 검토하고 확인할 수 있습니다.
terraform plan
Terraform 은 구성 파일을 읽고 현재 인프라 상태 (현재 비어 있음) 와 비교합니다. 그런 다음 조치 계획을 표시합니다. 생성될 리소스가 하나 있음을 나타내는 아래와 유사한 출력을 보게 될 것입니다.
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
## local_file.example will be created
+ resource "local_file" "example" {
+ content = "Hello, Terraform!"
+ content_base64sha256 = (known after apply)
+ content_base64sha512 = (known after apply)
+ content_md5 = (known after apply)
+ content_sha1 = (known after apply)
+ content_sha256 = (known after apply)
+ content_sha512 = (known after apply)
+ directory_permission = "0777"
+ file_permission = "0777"
+ filename = "./hello.txt"
+ id = (known after apply)
}
Plan: 1 to add, 0 to change, 0 to destroy.
resource "local_file" "example" 옆의 + 기호는 이 리소스가 생성될 것임을 나타냅니다. 출력에는 새 파일에 설정될 모든 속성이 자세히 나와 있습니다.