Terraform is perfect for deploying a StorageAccount in Azure to use it as a Terraform Remote Backend to store your future tfstate files. Part of the repository is a folder called .devcontainer
; it contains the Docker container configuration to use it with Microsoft Visial Studio Code and the Remote-Container technologies. Terraform, and Azure CLI got pre- installed to run the container. You need apart of Microsoft Visial Studio Code in addition to run the container Docker Desktop installed on your PC, MAC or Linux to use Remote-Container. It is only optional and not required to run the Terraform scripts.
git clone https://github.com/adminph-de/tf-azure-backend.git
Switch to the tf-azure-backend/terraform
folder
$ cd terraform
Create an addinal file in your cloned repo, called: azurecert.conf
with your spezific TENANT_ID
, SUBSCRIPTION_ID
and a Azure Service Principal (SPN)
CLIENT_ID
and CLIENT_SECRET
variable. Find the HowToBuild a SPN in the referenzes below.
Content of the file
ARM_TENANT_ID="0000000-0000-0000-0000-000000000000"
ARM_SUBSCRIPTION_ID="0000000-0000-0000-0000-000000000000"
ARM_CLIENT_ID="0000000-0000-0000-0000-000000000000"
ARM_CLIENT_SECRET="0000000-0000-0000-0000-000000000000"
Create a terraform.tfvars
file in your cloned repo with the variable values like this:
project = "Remote Backend for tfstate files"
environment = "PROD"
location = "westus2"
terraform init -backend-config=azurecreds.conf
terraform plan
terraform apply -auto-approve
- Check your result in your Azure Subscription
Project Link: https://github.com/adminph-de/tf-azure-backend
Author of the scrpit source is Guillermo Musumeci. Find detaild docmentation and explainations in his article:
Addinaly to this article, check: