LoginSignup
2
3

More than 3 years have passed since last update.

terraformのコマンドの意味を調べる(apply/console/destroy/env/fmt...)

Posted at

version

Terraform v0.12.26

command

Common commands:
    apply              Builds or changes infrastructure
    console            Interactive console for Terraform interpolations
    destroy            Destroy Terraform-managed infrastructure
    env                Workspace management
    fmt                Rewrites config files to canonical format
    get                Download and install modules for the configuration
    graph              Create a visual graph of Terraform resources
    import             Import existing infrastructure into Terraform
    init               Initialize a Terraform working directory
    login              Obtain and save credentials for a remote host
    logout             Remove locally-stored credentials for a remote host
    output             Read an output from a state file
    plan               Generate and show an execution plan
    providers          Prints a tree of the providers used in the configuration
    refresh            Update local state file against real resources
    show               Inspect Terraform state or plan
    taint              Manually mark a resource for recreation
    untaint            Manually unmark a resource as tainted
    validate           Validates the Terraform files
    version            Prints the Terraform version
    workspace          Workspace management

All other commands:
    0.12upgrade        Rewrites pre-0.12 module source code for v0.12
    debug              Debug output management (experimental)
    force-unlock       Manually unlock the terraform state
    push               Obsolete command for Terraform Enterprise legacy (v1)
    state              Advanced state management

公式サイト:Commands - Terraform by HashiCorp

ざっくり解説

command 動き
apply *.tfで記載した内容で構築を行う
console terraformで使える関数のテストが行えるインタラクティブなコマンド
destroy *.tfで記載した内容の削除を行う
env 現在非推奨。workspaceを使うこと。
fmt *.tfファイルの整形を行う
get terraform moduleのダウンロード
graph terraformのコードをgraph化する
import 既存のリソースをterraformに入れる
init terraformの環境を用意する時に最初に叩くコマンド
login terraform cloudやenterpriseにログインするとき
logout 上記からログアウトするとき
output stateファイルから出力変数の値を抽出するために使用
plan dry-run(実行したときの変更サれるものを表示する)
providers terraformのproviderを操作するときのコマンド
refresh リソースの実体を正としてtfstateの状態を最新化してくれる
show stateやplanファイルを人間が見やすいように表示する
taint 手動で操作されたりなどでterraformの管理外となったリソースにタグをつける(汚染する)plan→applyすると初めて削除される
untaint 付けたタグを削除する
validate 作成した*.tfファイルが正しいかをチェックする
version terraformのバージョン表示
workspace workspaceの管理(作成、参照、移動)
2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3