たとえば、Terraformで外部モジュールをGitリポジトリで参照している場合を考えます。
Module Sources / Generic Git Repository
module "vpc" { source = "git::https://example.com/vpc.git" } module "storage" { source = "git::ssh://username@example.com/storage.git" }
ドキュメントの例がまさにそうなのですけど、モジュールのバージョンを指定していません。
このような場合、1度「terraform init」を行うと次回は取得を行ってくれないわけで。この挙動が良い時、悪い時は
ケースバイケースです。
開発中とかは、再取得して欲しいとかあるかもしれません。
そういう時は、「terraform init」に「-upgrade」オプションを指定します。
$ terraform init -upgrade
このオプションは、本来は現在の構成が許す範囲(バージョン制限)の中で、モジュールなどを最新版にアップグレードするための
オプションです。
Update all previously installed plugins to the newest version that complies with the configuration's version constraints. This option does not apply to manually installed plugins.
ですが、今回のような利用方法の場合は、結果として最新化を行うことができます。
Re-running init with modules already installed will install the sources for any modules that were added to configuration since the last init, but will not change any already-installed modules. Use -upgrade to override this behavior, updating all modules to the latest available source code.
Command: init / Child Module Installation
確認したTerraformのバージョンは、こちら。
$ terraform version Terraform v0.12.28