terraformはまだ1.x以上じゃない
リリース情報より。
この記事の確認時点の最新は、0.12.7 (August 22, 2019)。
0.12.x。
安定バージョンを1.0.x以上と定義すると今後も細かいバージョンアップと仕様変更がるものと思われる。
0.11.xと0.12.xは大きくことなる
HashiCorp Terraform 0.12 Preview
こちらのとおりでだいぶ変わる。
0.11.14には0.12にアップデートするサポートコマンドも用意されている。
terraform 0.12checklist
例えば、以下の表示。
これは、変数 count
を使ってしまっているが、 Input Variables
の変更が今後ある指摘。
# Module `"hoge"`
- [ ] The variable name "count" is now reserved.
Terraform 0.12 reserves certain variable names that have (or will have in future) a special meaning when used in a "module" block. The name of this variable must be changed before upgrading to v0.12. This will unfortunately be a breaking change for any user of this module, requiring a major release to indicate that.
For more information on the reserved variable names, see the documentation at https://www.terraform.io/docs/configuration/variables.html .
0.12以上使わせたくないとき
とはいえ、0.11を使っている事情もあるだろう。
アップデート前に0.12を使おうとするクライアントがいて、tfstteなどを書き換えられると困る。
そこで、アップデート前にバージョンを固定させるようにしたほうがいい。
versionを固定するtfファイルをそえてあげるとよいだろう。
% cat version.tf
terraform {
required_version = "~> 0.11"
}
逆に0.12しか使わせたくないとき
0.12から変わるので、基本0.12以上対応にした場合は以下のようにmoduleごとも含めて0.12以上を指定したほうがよいだろう。
terraform {
required_version = "~> 0.12"
}
複数プロジェクトをまたいでいるときは、気にしておきたい。
このmoduleは0.12以上対応です
参考: terraform-aws-modules/terraform-aws-eksのmoduleの使用例
terraform {
required_version = ">= 0.12"
required_providers {
aws = ">= 2.8"
local = ">= 1.2"
null = ">= 2.1"
template = ">= 2.1"
random = ">= 2.1"
}
}
providerも同様に指定するとよい。
このあたり、細かく設定するとterarform本体のバージョンやproviderのバージョンを固定しながら扱うことができる。