Terraform-基本命令:terraform apply

时间:2025-02-12 14:52:37

terraform apply

terraform apply 命令用于执行资源的创建或变更。在操作执行前会进行一次人机交互,用于对资源创建和变更的确认。我们也可以使用 "-auto-approve" 选项跳过人机交互直接执行。

$ terraform applyAn execution plan has been generated and is shown below.Resource actions are indicated with the following symbols:Terraform will perform the following action:...Plan: 1 to add, 0 to change, 1 to destroy.Do you want to perform these actions?  Terraform will perform the actions described above.  Only 'yes' will be accepted to approve.  Enter a value:
terraform apply 的执行结果会保存在状态文件 (terraform.tfstate) 中,并且会显示定义的输出变量值。
Apply complete! Resources: 1 to add, 0 to change, 1 to destroy.Outputs:vpc_id = df507d37-bce2-4750-8873-f62abb3b085c
support.huaweicloud.com/basics-terraform/terraform_0025.html