Backends

A “backend” in Terraform determines how state is loaded and how an operation such as apply is executed. This abstraction enables non-local file state storage, remote execution, etc.

Documentation

gcs

https://www.terraform.io/docs/backends/types/gcs.html

Example:

terraform {
  backend "gcs" {
    bucket  = "tf-state-prod"
    prefix  = "terraform/state"
  }
}
  • 認証用の credentials または access_token が必要。

config variables

gcloud auth application-default login

See also:

s3

https://www.terraform.io/docs/backends/types/s3.html

  • ロックしたいときはDynamoDBを使う。
    • オプション dynamodb_table を指定する