Hashicorp Terraform 远程状态和 Azure

Hashicorp Terraform Remote State and Azure

我知道 Terraform 支持 Azure,实际上我已经能够通过执行以下操作让 Terraform 与 A​​zure 一起工作:

Main.tf

terraform {  
  backend "azurerm" {  
     }  
}  

当我查看 blob 容器时,我看到 myapp.tfstate 文件,这意味着我已经成功了,对吧?

这到底能给我带来什么?我知道我的状态文件现在保存在 Azure 中,但是......这对我有什么帮助?我四处寻找解释这一点的文档,但出于某种原因一直无法找到任何内容。

其实把Terraform存放在Azure Storage Account里面,我觉得跟本地没什么区别,只是换了地方而已。但是根据文档中的描述:

By default, data stored in an Azure Blob is encrypted before being persisted to the storage infrastructure. When Terraform needs state, it is retrieved from the backend and stored in memory on your development system. In this configuration, the state is secured in Azure Storage and not written to your local disk.

看来对数据的安全性还是有一点影响的

Charles 关于什么都没有存储 "just" 在另一个地方是正确的,但他是错误的,没有区别。它们是有区别的。主要区别在于您是否有一个团队使用 TF。

你看,状态不仅用于存储状态,还用于表示当前正在进行操作。叫 locking。通过集中存储,您的队友 none 可能会在其他人已经这样做时意外尝试和更改资源。