简体   繁体   English

管理每个管道 terraform state 和 Azure 存储容器的有效方法

[英]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.

相关问题 ArgoCD 在 Azure 管道中使用 terraform 进行引导 - ArgoCD bootstrapping with terraform in Azure Pipeline Terraform 设置 azure 存储帐户 virtual.network - Terraform set azure storage account virtual network 使用 Terraform 创建 Azure 突触管道 - Create Azure Synapse Pipeline using Terraform Azure DevOps 管道无法找到可执行文件:“terraform” - Azure DevOps Pipeline unable to locate executable file: 'terraform' 如何在 azure devops 管道中应用 terraform.tfvars - How to apply terraform.tfvars in azure devops pipeline 我们可以在 Azure DevOps 发布管道中运行 terraform 导入吗 - Can we run terraform import in Azure DevOps release pipeline GitLab-CI 管道在同一作业中无法识别 Azure CLI 和 Terraform - GitLab-CI Pipeline Not Recognizing Azure CLI and Terraform in Same Job 使用 Terraform 为 Azure 数据工厂管道创建数组变量或参数 - Creating Array Variable or Parameters For Azure Data Factory Pipeline Using Terraform 如何修改 azure 管道中测试结果的存储库/存储位置 - How to modify the repository / storage location for Test Results in azure pipeline 无法让 web 应用写入 Azure 存储 Blob 中的 Terraform - Can not get web app to write to Azure Storage Blob in Terraform
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM