Terraform Training

Use Infrastructure as Code to provision and manage any cloud, infrastructure, or service

Documents

https://www.terraform.io/ offical docs
https://www.alibabacloud.com/help/zh/doc-detail/91285.htm?spm=a2c63.p38356.b99.372.8b994d00YwQjZI 中文版,阿里云文档
https://learn.hashicorp.com/terraform/getting-started/intro Get Started - AWS

Why not use ansible ? because changes to resources aren’t tracked.
Why didn’t we choose CloudFormation? Its support is limited to AWS.

Terraform config is code we write, state file is a json file. store these on the remote.
Plan is safe to do any where, apply we don’t comment any want. don’t apply locally, don’t apply locally, don’t apply locally!

Commands Description
terraform init Initiate Terraform. Terraform must be initiated before you plan/apply terraform.
terraform plan You will be able to examine Terraform’s execution plan before you deploy it to AWS.
terraform apply Deploy your final execution plan to AWS.
terraform init -upgrade Update providers.
terraform state show Inspect the current state.
terraform graph Displays the visual dependency graph of Terraform resources according to configuration files in DIR (or the current directory if omitted).
terraform destroy Destroy all resources created by terraform and also destroy the changes in your state file.
terraform plan-out To save the displayed plan (from the ‘terraform plan’ command) for reference.