End of Atlas free trial

End of Atlas free trial

\(o)/オワタ

$ terraform plan
Error reloading remote state: Unexpected HTTP response code: 400

Body: {"errors":["This feature requires Terraform Enterprise. Please contact sales@hashicorp.com to start or extend your trial."],"success":false}

Freeプランだとterraform(のtfstate置き場として)使えないのよな…。泣きそう。

とりあえずS3に退避。諸々忘れてていったんまっさらにしてから始め直したいので、まずは既存のremote設定を消す(消さなくても出来ると思われる)。

terraform remote config -disable

これでローカルの.terraform/terraform.tfstateを見るようになる。次にterraformのためのIAMを作成する。権限はS3フルアクセスにした(もっと絞っても良さそう)。

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "s3:*",
      "Resource": "*"
    }
  ]
}

その後S3のバケットを掘る。

aws s3 mb s3://my-terraform-state --region=us-east-1
aws s3 mb s3://my-terraform-state/infra --region=us-east-1

作成したバケットをremote先として設定する。

terraform remote config \
-backend=s3 \
-backend-config="bucket=my-terraform-state" \
-backend-config="key=infra/terraform.tfstate" \
-backend-config="region=us-east-1"

実行するとremoteの許可とtfstateの保存が行われる。

Remote state management enabled
Remote state configured and pulled.

pushとかpullしてみて動作確認。

$ terraform remote push
State successfully pushed!

$ terraform remote pull
Local and remote state in sync

バケットにtfstateファイルが作成されていることは以下のようにして確認。

$ aws s3 ls s3://my-terraform-state/infra/ --region=us-east-1
2016-09-23 19:29:17       8692 terraform.tfstate

atlasのterraformはgithubと連携しててgithubにpushしたらatlas側でterraform plan実行してくれたり色々便利だったのでかなC (  ´・ω・`  )