- Description
- Requirements
- How to
- Terraform backend on Azure
- Demo Architecture
- Terraform variables
- Execution Note
Demo XmasDev 2021
- Azure AD tenant and an Azure AD user within at least "Application Administrator" role (Microsoft Docs - How to)
- Azure subscription (Microsoft Docs - How to)
- Azure DevOps organization (Microsoft Docs - How to)
- Terraform version >= 1.0.0
- PowerShell (Core) >= 6.0.0
- Azure DevOps personal access token as "full access" (used to create resources in Azure DevOps) (Microsoft Docs - How to)
-
Launch PowerShell script to setup terraform backend on Azure (see more)
-
Launch in the
iac
folder and runterraform init
,terraform plan -out=stage1
andterraform apply stage1
. this step will setup your Azure AD creating a service principal. To deploy this stage, please comment "az" and "az_devops" module in terraform main file ("aad" and "data" modules will remain uncommented). -
Launch in the
iac
folder and runterraform init
,terraform plan -out=stage2
andterraform apply stage2
. This step will create all needed Azure infrastructure (see architecture. To deploy this stage, please comment "az_devops" module in terraform main file ("aad", "data", "az" modules will remain uncommented). -
Launch in the
iac
folder and runterraform init
,terraform plan -out=stage3
andterraform apply stage3
. This step will create nearly all Azure DevOps infrastructure (only resources not covered by the actual version of Azure DevOps provider in Terraform are: ServiceHook and Agent Pool). To deploy this stage, please comment "az_devops" module in terraform main file ("aad", "data", "az" modules will remain uncommented).
The script Run-TerraformBackendOnAzure.ps1
will configure the main.tf
file to store Terraform states on Azure blob storage, it need as in input file the main Terraform file.
Run-TerraformBackendOnAzure.ps1
in the folder iac
can be used like this:
Run-TerraformBackendOnAzure.ps1 -ResourcePrefix "XmasDev21demo" -AzRegion "northeurope" -MainTerraformFileName ".\main.tf"
Whitin an output like this:
Following an example of the Terraform input variables:
################
# Azure DevOps #
################
project_name = "<PROJECT-NAME>"
url = "https://dev.azure.com/<AZ-DEVOPS-ORG-NAME>"
devops_pat = "<DEVOPS-PERSONAL-ACCESS-TOKEN>"
username = "<AZURE-AD-USER-TO-ADD-TO-AZ-DEVOPS-AS-SERVICE-ADMIN>"
devops_license = "basic"
################
# Azure #
################
admin_username = "<VM-ADMIN-USER>"
admin_password = "<VM-ADMIN-PASSWORD>"
vm_sku = "Standard_B1s"
The Run-TerraformBackendOnAzure.ps1
script is tested to be executed both on Windows or Linux or WSL, the only requirement is to have installed PowerShell >= 6.x (how to)