본문 바로가기

퍼블릭 클라우드

[Terraform] terraform 명령어

반응형

terraform 명령어

terraform 사용법

terraform -help
$ terraform -help
Usage: terraform [global options] <subcommand> [args]

The available commands for execution are listed below.
The primary workflow commands are given first, followed by
less common or more advanced commands.

Main commands:
  init          Prepare your working directory for other commands
  validate      Check whether the configuration is valid
  plan          Show changes required by the current configuration
  apply         Create or update infrastructure
  destroy       Destroy previously-created infrastructure

All other commands:
  console       Try Terraform expressions at an interactive command prompt
  fmt           Reformat your configuration in the standard style
  force-unlock  Release a stuck lock on the current workspace
  get           Install or upgrade remote Terraform modules
  graph         Generate a Graphviz graph of the steps in an operation
  import        Associate existing infrastructure with a Terraform resource
  login         Obtain and save credentials for a remote host
  logout        Remove locally-stored credentials for a remote host
  output        Show output values from your root module
  providers     Show the providers required for this configuration
  refresh       Update the state to match remote systems
  show          Show the current state or a saved plan
  state         Advanced state management
  taint         Mark a resource instance as not fully functional
  test          Experimental support for module integration testing
  untaint       Remove the 'tainted' state from a resource instance
  version       Show the current Terraform version
  workspace     Workspace management

Global options (use these before the subcommand, if any):
  -chdir=DIR    Switch to a different working directory before executing the
                given subcommand.
  -help         Show this help output, or the help for a specified subcommand.
  -version      An alias for the "version" subcommand.

작업 디렉토리 준비(라이브러리 다운로드)

terraform init

표준 스타일로 구성을 다시 포매팅

terraform fmt

구성이 유효한지 확인(문법 검사)

terraform validate

현재 구성에 필요한 변경 사항 표시

terraform plan

인프라 생성 또는 업데이트

terraform apply
$ terraform apply -help
terraform apply -auto-approve

출력 값 표시(output)

terraform output

Graphviz 그래프 생성

terraform graph

생성된 인프라 제거(삭제)

terraform destroy
terraform destroy -auto-approve

 

참고URL

- Terraform Documentation : https://www.terraform.io/cli/commands

 

728x90
반응형