- Print
- Comment
- DarkLight
- PDF
Step 1 - Deploying Infrastructure - Local Development
In this step I will use Terraform to setup most of the infrastructure in Azure for my PaaS solution. It will setup the following:
- Configure APIM
- Setup Service Bus
- Setup empty Logic Apps
- Setup Function App and its config settings
The process to do this is discussed below.
Terraform Commands
The Terraform commands to setup all of the infrastructure is as follows:
cd .
az login
az account set --subscription "[Subscription ID]"
Terraform init
Terraform validate
Terraform plan -var-file=Terraform.Variables.Local.tfvars
Terraform apply -var-file=Terraform.Variables.Local.tfvars
terraform output -json > outputs.json
At the end of running these scripts you will have all of the Azure Resources created and the majority of the configuration done.
Terraform State File
In this instance I am just using the local default for the terraform state file which will create a file in the directory called Terraform.tfstate. This will maintain the state between executions of the code.
There is an interesting discussion about managing terraform state files in a team scenario in the common problems section of this article.
Terraform Output Variables
At the end of the Terraform execution there may be some variables I wish to output. These may be used elsewhere in my solution to configure components.
An example is where I may spin up an Azure Service Bus instance and create an authorization rule. The connection string for this Service Bus access needs to be configured as a parameter later in my Logic App. I can use Terraform output variables to output the variables to a file from where I can use them elsewhere in my process.
The command that outputs the variables is:
terraform output -json > outputs.json
For local development I can output them to a file and then I can just manually configure the Logic App parameters file. Because Terraform is managing the infrastructure state I do not need to change this setting everytime, only when I want to.
A point to note here is that I may want to pass the key as an input to the setup from something like a DevOps pipeline variable. For many settings this is possible and you will see this used elsewhere as the preferred approach but in the case of a Service Bus key this is not supported. The key is generated and I need to take it as an output to use it elsewhere.