[英]Efficient way to manage terraform state with Azure storage contianer per pipeline
As part of the IaC workflow we are implementing through Terraform, for some of the common resources we provision for users, we want to create a centralized remote state store.作为我们通过 Terraform 实施的 IaC 工作流程的一部分,对于我们为用户提供的一些公共资源,我们希望创建一个集中的远程 state 存储。 We are using Azure cloud so the default choice is to use Azure blob storage.我们正在使用 Azure 云,因此默认选择是使用 Azure blob 存储。 We were initially thinking of creating one storage continaer per pipeline and store the state there.我们最初考虑为每个管道创建一个存储容器并将 state 存储在那里。 But then there was another thought wherein create one container and create directory structure per pipeline and store the state there.但是后来又有了另一种想法,其中创建一个容器并为每个管道创建目录结构并将 state 存储在那里。 I understand blob storage by default is the flat file system.我了解默认情况下的 blob 存储是平面文件系统。 But Azure storage also gives an option to enable hierarchical file structure with ADLS2.但是 Azure 存储还提供了一个选项,可以使用 ADLS2 启用分层文件结构。 Did anyone attempt to store terraform states by enabling hierarchical file system structure in Azure?是否有人试图通过在 Azure 中启用分层文件系统结构来存储 terraform 状态? Is that a valid option at all?这是一个有效的选择吗? Also, can anyone suggest what would be the recommended apporach in my scenario?另外,有人可以建议在我的场景中推荐的方法是什么吗?
Thanks Tintu谢谢廷图
Never tried with ADLS2 by using its hierarchical feature.从未尝试过使用 ADLS2 的分层功能。 But since your requirement is to save the statefiles in same container but within different folders, you can try out specifying different folder structure while configuring the backend in backend.tf但是由于您的要求是将状态文件保存在同一个容器中但在不同的文件夹中,您可以尝试在 backend.tf 中配置后端时指定不同的文件夹结构
terraform init backend-config "key=$somePath/<tfstate-file-name>.tfstate"
And pass different somePath values from a different backend.tfvars files.并从不同的 backend.tfvars 文件传递不同的 somePath 值。
I hope this answers your question!我希望这回答了你的问题!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.