tf-azure-backend

Contributors Forks Stargazers Issues MIT License LinkedIn


Terraform & Azure

Deploy a Remote Backend to Azure with Terraform

Table of Contents

About The Project

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.

Deployment

Clone the repo

git clone https://github.com/adminph-de/tf-azure-backend.git

Azure Credential file

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"

Terraform Variables file

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"

Run Terraform Init

terraform init -backend-config=azurecreds.conf

Run Terraform Plan

terraform plan

Run Terraform Apply

terraform apply -auto-approve

  1. Check your result in your Azure Subscription

Contact

LinkedIN - Twitter - Email

Project Link: https://github.com/adminph-de/tf-azure-backend

Referenzes

Author of the scrpit source is Guillermo Musumeci. Find detaild docmentation and explainations in his article:

Addinaly to this article, check: