3
0

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 3 years have passed since last update.

terraform backendでs3(さくらのクラウド オブジェクトストレージ)を使う

3
Posted at

terraform公式のbackendのs3設定を使用して、tfstateの保存先をさくらのクラウド オブジェクトストレージにします。
しかし、いくつかのエラーが発生するため設定を追加します。

リージョンに関するエラー

...
Error: Invalid AWS Region: jp-north-1
...

名前解決に関するエラー

...
Error: error using credentials to get account ID: error calling sts:GetCallerIdentity: RequestError: send request failed
caused by: Post https://sts.jp-north-1.amazonaws.com/: dial tcp: lookup sts.jp-north-1.amazonaws.com on **********: no such host
...

これらを解決して使用するために、以下の2つの設定を入れます。

skip_credentials_validation = true
skip_region_validation      = true

設定を入れた場合のHCLは以下の通りです。

例

terraform {
  backend "s3" {
    bucket = "tfstate" # バケット名
    key    = "terraform.tfstate"
    endpoint = "s3.isk01.sakurastorage.jp"
    region = "jp-north-1"
    access_key = "access_key" # アクセスキーID
    secret_key = "secret_key" # シークレットアクセスキー
    skip_credentials_validation = true
    skip_region_validation      = true
  }
}

resource "sakuracloud_server" "server" {
  name        = "server"
  core        = 1
  memory      = 1
  description = "server"

  network_interface {
    upstream         = "shared"
  }

  disk_edit_parameter {
    password        = "P@ssword!"
    disable_pw_auth = false
  }
  count = 1
}
3
0
0

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
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?