Think before you speak, read before you think.

terraform terragrunt

https://www.terraform-best-practices.com/
https://github.com/terraform-linters/tflint

check:

terraform init
# terragrunt init -upgrade 重新更新依赖
terraform validate
terraform plan

交互 approve 方式执行

terraform apply

直接执行,省去交互

terraform apply -auto-approve

格式化代码

terraform fmt -recursive
terragrunt hclfmt

查看 state

terraform state list

import state

terragrunt import --terragrunt-working-dir dev/k8s/namespaces 'kubernetes_namespace.namespaces["app"]' app

清理 dev 集群 hongkong

terragrunt run-all plan --terragrunt-working-dir deploy/dev/gke/hongkong
terragrunt run-all destroy --terragrunt-working-dir deploy/dev/gke/hongkong

查看依赖图

terragrunt graph-dependencies --terragrunt-working-dir deploy/dev/gke/hongkong

执行 destroy

    - terragrunt plan -destroy -target k8s
    - terragrunt destroy -target module.k8s -force

terragrunt 删除目录感知不到要删除对应的 resource
应该删除对应的 inputs, 前提 inputs 要支持空 defaut 值

升级

brew upgrade terragrunt

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *