Migration of Terraform State file from Azure Storage Account to Terraform Cloud workspace
What is Terraform State file?
Terraform stores information about your infrastructure in a State file. This state file keeps track of resources created by your configuration and maps them to real-world resources.
Migration Steps involves:
- Download the latest State file from the Azure storage account, and rename it to
terraform.tfstate
. - Create a new directory/folder and create a new
main.tf
file with following configurations:
terraform {
cloud {
organization = "YOUR_TFC_ORGANIZATION"
workspaces {
name = "WORKSPACE_NAME"
}
}
}
- Copy the downloaded state file into this new directory/folder in which you created the new
main.tf
file. - Make sure that the local version of Terraform match with the Terraform version of your Terraform Cloud workspace. If not install the required version.
- Now run
terraform init
command. It will show you something similar:
Initializing Terraform Cloud
Do you wish
…