5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Terraform を 0.8.8 から 0.9.1 にアップグレードしたら、remote state の設定方法変わった

5
Posted at

目的

Terraform のバージョンが v0.9.1 になったので、アップグレードしたら、remote state の設定方法変わっていたので、設定方法を見直す

v0.8.8 までの設定方法

S3 では、以下のような Terraform コマンドを実行してたかと。

terraform remote config -backend=s3  -backend-config="bucket=tctf-state" -backend-config="key=prod.tfstate" -backend-config="region=ap-northeast-1"

v0.9.0 からの設定方法

任意の Terraform ファイル (config.tf みたいな) に以下のコードを追加する。
S3 とかでやったよ!という事例はよく見るので、Microsoft Azure Storage でやってみた。

[config.tf]
terraform {
  backend "azure" {
    storage_account_name = "abcd1234"
    container_name       = "tfstate"
    key                  = "prod.terraform.tfstate"
  }
}

アクセス キーは、環境変数とかで、直接 .tf ファイルには書かないほうが良いかと。
そして、terraform init コマンドを実行すると、remote state が利用できました。

参考

詳細は、こちらを御覧ください。

5
4
2

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
5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?