terraform

事前準備

AWS マネジメントコンソールで作業

入門

RDS インスタンスの構築があると結構時間がかかります ( 当エントリの構成で約8分程度 ) 。

https://tech.recruit-mp.co.jp/infrastructure/post-10665/

tfファイル

type (Optional) - If set this defines the type of the variable. Valid values are string, list, and map. If this field is omitted, the variable type will be inferred based on default. If no default is provided, the type is assumed to be string.

https://www.terraform.io/docs/configuration/variables.html

typeは省略するとdefaultを基に推測、defaultがない場合はstringとみなす

Terraformではtfファイルで定義されているリソース間の依存関係を検出し、自動的に構築順序を制御してくれます。

http://febc-yamamoto.hatenablog.jp/?page=1517827055

terraform.tfstate

Terraformはリソースの状態を terraform.tfstate というJSONファイルで管理しています。その内容と実際の状態に差分が存在する場合、単純にコードの内容を適用してしまうと、Terraform側の設定、つまり古い設定で上書きしてしまいます。しかし、 refresh というサブコマンドを使えばこのJSONファイルへ実際の設定を反映してくれるので、変更に追従可能です。

$ terraform refresh

https://dev.classmethod.jp/cloud/aws/manages-cloudwatch-alarm-with-terraform/

ベスト・プラクティス

Terraform Module Registry https://registry.terraform.io/ を使いましょう。 以上です。

http://febc-yamamoto.hatenablog.jp/entry/2018/02/01/090046