《Terraform 101 从入门到实践》 Terraform常用命令
source link: https://www.pkslow.com/archives/terraform-101-commands
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
《Terraform 101 从入门到实践》 Terraform常用命令
《Terraform 101 从入门到实践》这本书只将在南瓜慢说官方网站和GitHub两个地方同步更新,如果你在其它地方看到,那应该就是抄袭和未授权的转载。书中的示例代码也是放在GitHub上,方便大家参考查看。
指定插件目录初始化:
$ terraform init -plugin-dir=/Users/larry/Software/terraform/plugins
$ terraform init -plugin-dir=${TERRAFORM_PLUGIN}
将目录下所有Terraform文件格式化,包含子目录:
$ terraform fmt -recursive
非交互式apply和destroy:
$ terraform apply -auto-approve
$ terraform destroy -auto-approve
创建一个工作区并切换:
$ terraform workspace new pkslow
切换到已存在的工作区:
$ terraform workspace select pkslow
输出变更计划到指定文件:
$ terraform plan -out=pkslow.plan
根据计划执行变更:
$ terraform apply pkslow.plan
输入变量:
$ terraform apply -var="env=uat"
$ terraform apply -var-file="prod.tfvars"
$ terraform output
$ terraform console
$ terraform get
有用的别名:
alias tfmt='terraform fmt -recursive'
alias tinit='terraform init -plugin-dir=${TERRAFORM_PLUGIN}'
alias tapply='terraform apply -auto-approve'
alias tdestroy='terraform destroy -auto-approve'
alias tplan='terraform plan'
Code for all: GitHub
欢迎关注微信公众号<南瓜慢说>,将持续为你更新...
Recommendations:
Cloud Native
Terraform
Container: Docker/Kubernetes
Spring Boot / Spring Cloud
Https
如何制定切实可行的计划并好好执行
- Author 作者: LarryDpk 南瓜慢说
- Link 链接: https://www.pkslow.com/archives/terraform-101-commands
- 版权声明: 本博客所有文章除特别声明外,不可转载!
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK