Backends
A “backend” in Terraform determines how state is loaded and how an operation such as
applyis 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
credentials… GCPのサービスアカウントキー(JSON)のパスを指定する- 環境変数
GOOGLE_BACKEND_CREDENTIALSorGOOGLE_CREDENTIALSによってパスを指定することもできる - https://cloud.google.com/sdk/gcloud/reference/auth/application-default/login で作成できるユーザのApplication Default Credentialsでも良い
- 環境変数
gcloud auth application-default login
See also:
s3
https://www.terraform.io/docs/backends/types/s3.html
- ロックしたいときはDynamoDBを使う。
- オプション
dynamodb_tableを指定する
- オプション