Closed7

terraform導入スクラップ

りゅうりゅう

terraform インストール

brew install terraform

バージョン確認

% terraform --version
Terraform v0.15.0
on darwin_amd64
りゅうりゅう

Terraform のバージョン管理マネージャー

% brew install tfenv

エラーが発生するので、以下実行

brew unlink terraform
エラー内容
23:22:24 [~/10_private_work/1_handson]
% brew install tfenv
Error:
  homebrew-core is a shallow clone.
To `brew update`, first run:
  git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
This command may take a few minutes to run due to the large size of the repository.
This restriction has been made on GitHub's request because updating shallow
clones is an extremely expensive operation due to the tree layout and traffic of
Homebrew/homebrew-core and Homebrew/homebrew-cask. We don't do this for you
automatically to avoid repeatedly performing an expensive unshallow operation in
CI systems (which should instead be fixed to not use shallow clones). Sorry for
the inconvenience!
==> Downloading https://github.com/tfutils/tfenv/archive/v2.2.0.tar.gz
Already downloaded: /Users/suzukiryusei/Library/Caches/Homebrew/downloads/d5f3775943c8e090ebe2af640ea8a89f99f7f0c2c47314d76073410338ae02de--tfenv-2.2.0.tar.gz
Error: Cannot install tfenv because conflicting formulae are installed.
  terraform: because tfenv symlinks terraform binaries

Please `brew unlink terraform` before continuing.

Unlinking removes a formula's symlinks from /usr/local. You can
link the formula again after the install finishes. You can --force this
install, but the build may fail or cause obscure side effects in the
resulting software.
23:22:27 [~/10_private_work/1_handson]
りゅうりゅう

tfenv の使い方

インストール可能一覧

% tfenv list-remote

特定のバージョンインストール

% tfenv install 0.12.5

特定のバージョンに切り替え

% tfenv use 0.12.5
りゅうりゅう

チーム開発用のバージョン指定ファイル

% echo 0.15.0 > .terraform-version
% tfenv install

指定のバージョンインストール


23:37:34 [~/10_private_work/1_handson/terraform-first-book]
% echo 0.15.0 > .terraform-version
23:38:28 [~/10_private_work/1_handson/terraform-first-book]
% tfenv install

りゅうりゅう

公式記述のインストール

$ git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
$ brew tap hashicorp/tap
$ brew install hashicorp/tap/terraform
りゅうりゅう

コマンドメモ

% terraform plan
% terraform apply
% terraform plan
% terraform destroy
このスクラップは2023/01/07にクローズされました