terraform应用是否也针对已部署的内容刷新状态?

terraform应用是否也针对已部署的内容刷新状态?,terraform,Terraform,假设我运行terraformapply,没有refresh标志,也没有提到计划 terraform是否会将我定义为IaC的状态刷新为已部署的状态?或者它只会查看我当前的状态文件,并将其与我更新为IaC的文件进行比较 文档没有提到terraform的默认刷新行为。terraform apply将始终检查新状态。默认情况下,任何terraform操作都将首先刷新状态。理想情况下,您应该始终执行terraform plan-out.plan,然后使用terraform apply.plan将此计划应用

假设我运行
terraformapply
,没有
refresh
标志,也没有提到计划

terraform是否会将我定义为IaC的状态刷新为已部署的状态?或者它只会查看我当前的状态文件,并将其与我更新为IaC的文件进行比较


文档没有提到terraform的默认刷新行为。

terraform apply将始终检查新状态。默认情况下,任何terraform操作都将首先刷新状态。理想情况下,您应该始终执行
terraform plan-out.plan
,然后使用
terraform apply.plan
将此计划应用于环境。这确保了一致性,并且您确切地知道环境中将发生什么。
如果计划是旧的,同时环境发生了变化,terraform将检测到这一点,并将给您一个错误-迫使您重新计划并应用。

terraform apply将始终检查新状态。默认情况下,任何terraform操作都将首先刷新状态。理想情况下,您应该始终执行
terraform plan-out.plan
,然后使用
terraform apply.plan
将此计划应用于环境。这确保了一致性,并且您确切地知道环境中将发生什么。
如果计划很旧,同时环境也发生了变化,terraform将检测到这一点并给您一个错误,迫使您重新计划并应用。

terraform将在运行依赖它的命令之前自动刷新状态(例如
计划
应用
销毁

通过查看运行以下命令的输出,您可以看到这一点:

$ terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

data.aws_region.current: Refreshing state...

------------------------------------------------------------------------

No changes. Infrastructure is up-to-date.

This means that Terraform did not detect any differences between your
configuration and real physical resources that exist. As a result, no
actions need to be performed.

Terraform将在运行依赖它的命令之前自动刷新状态(例如
计划
应用
销毁

通过查看运行以下命令的输出,您可以看到这一点:

$ terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

data.aws_region.current: Refreshing state...

------------------------------------------------------------------------

No changes. Infrastructure is up-to-date.

This means that Terraform did not detect any differences between your
configuration and real physical resources that exist. As a result, no
actions need to be performed.