Hound
Hound

Reputation: 947

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. We are using Azure cloud so the default choice is to use Azure blob storage. We were initially thinking of creating one storage continaer per pipeline and store the state there. But then there was another thought wherein create one container and create directory structure per pipeline and store the state there. I understand blob storage by default is the flat file system. But Azure storage also gives an option to enable hierarchical file structure with ADLS2. Did anyone attempt to store terraform states by enabling hierarchical file system structure in Azure? Is that a valid option at all? Also, can anyone suggest what would be the recommended apporach in my scenario?

Thanks Tintu

Upvotes: 0

Views: 737

Answers (1)

Srishti Gawande
Srishti Gawande

Reputation: 81

Never tried with ADLS2 by using its hierarchical feature. 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

terraform init backend-config "key=$somePath/<tfstate-file-name>.tfstate" 

And pass different somePath values from a different backend.tfvars files.

I hope this answers your question!

Upvotes: 1

Related Questions