README

  • tfenvのインストール
  • 設定ファイルの作成
  • terraform init
  • terraform plan
  • terraform apply

設計運用

ファイル内容
main.tfリソースを作成する(moduels, locals, data-sources)
variables.tfmain.tf で使われる変数
outputs.tfmain.tf が作成したリソースの出力
1
% tree large-terraform 
large-terraform
├── README.md
├── modules
│   └── network
│       ├── main.tf
│       ├── outputs.tf
│       └── variables.tf
├── prod
│   ├── main.tf
│   ├── outputs.tf
│   ├── terraform.tfvars
│   └── variables.tf
└── stage
    ├── main.tf
    ├── outputs.tf
    ├── terraform.tfvars
    └── variables.tf

HCL (HCL is the HashiCorp configuration language.)

コメント:

  • After Terraform 0.12(Reliable JSON Syntax:コメント記述): “//”

plan

1
$ env $(cat .env|xargs) terraform -chdir=prod plan -out=myplan.plan
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
% unzip -l prod/*.plan
Archive:  prod/myplan.plan
  Length      Date    Time    Name
---------  ---------- -----   ----
     1591  06-13-2021 16:08   tfplan
      119  06-13-2021 16:08   tfstate
      119  06-13-2021 16:08   tfstate-prev
      185  06-13-2021 16:08   tfconfig/m-/main.tf
        0  06-13-2021 16:08   tfconfig/m-/outputs.tf
       89  06-13-2021 16:08   tfconfig/m-/variables.tf
     1017  06-13-2021 16:08   tfconfig/m-s3_web/main.tf
       62  06-13-2021 16:08   tfconfig/m-s3_web/variables.tf
      137  06-13-2021 16:08   tfconfig/modules.json
---------                     -------
     3319                     9 files

plan

1
$ env $(cat .env|xargs) terraform -chdir=prod apply myplan.plan