2
1

More than 3 years have passed since last update.

便利なterraformコマンド3選 (備忘録)

Last updated at Posted at 2021-01-27

はじめに

  • tfstateで管理しているリソースのリストが見たい
  • tfstateから特定のリソースを管理外にしたい
  • 作成済みのリソースを狙ったtfstateの管理下にしたい

上記のような対応がしたいときにおすすめのコマンドを記載します。

tfstateで管理しているリソースのリストが見たい

terraform state list

上記のコマンドで、モジュールを含むすべてのリソースを一覧表示できます。
参考: 公式ドキュメント

tfstateから特定のリソースを管理外にしたい

terraform state rm [リソース名]

上記のコマンドで、対象のリソースをterraform管理外に設定できます。
参考: 公式ドキュメント

作成済みのリソースを狙ったtfstateの管理下にしたい

terraform import [tfstate上でどんな名前で管理するかを書く] [基本リソース名]

上記のコマンドで、他の方法で作成したリソースを取得して、Terraformの管理下に置くことができます。

参考: 公式ドキュメント

2
1
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
1