This repo demonstrates how to build and install STIR on an Azure VM using Terraform. The VM is described in Terraform files (.tf
). Terraform deploys a VM in the cloud and then copies and executes a bash script to perform the actual building of STIR.
An Azure account is required for deployment.
- Query your Azure account to get a list of subscription and tenant ID values:
az account show --query "{subscriptionId:id, tenantId:tenantId}"
- Note the
subscriptionId
andtenantId
for future use. - Set the environment variable
SUBSCRIPTION_ID
to the subscription ID returned by theaz account show
command. In Bash, this would be:
export SUBSCRIPTION_ID=your_subscription_id
- Create an Azure service prinicpal for Terraform to use:
az ad sp create-for-rbac --role="Contributor" --scopes="/subscriptions/${SUBSCRIPTION_ID}"
- Make a note of the
appId
andpassword
- Copy
var_values.tfvars.example
tovar_values.tfvars
- Edit
var_values.tfvars
such thatYOUR_SUBSCRIPTION_ID_HERE
,YOUR_APPLICATION_ID_HERE
,YOUR_SECRET_KEY_HERE
andYOUR_TENANT_ID_HERE
are replaced by yoursubscriptionId
,appId
,password
andtenantId
respectively.
- Initialise Terraform:
terraform init
- To preview the actions that Terraform will take, run:
terraform plan -var-file var_values.tfvars
- To run the script:
terraform apply -var-file var_values.tfvars
- If this succeeded, a virtual machine will be running on Azure.
- Find the public IP address of the machine:
az vm show --resource-group stirGroup --name stirVM -d --query [publicIps] --o tsv
- Make a note of the IP address.
- To access the machine via ssh:
ssh USERNAME@PUBLICIP
where USERNAME
is the value set for vm_username
(default: stiruser
) and PUBLICIP
is the public IP address found with the previous command.
terraform destroy -var-file var_values.tfvars
To avoid incurring unexpected costs, it is highly recommended that you check the Azure web portal to ensure that all resources have successfully been destroyed.
If you get an error related to SkuNotAvailable
, try to display all available machine types and see if the chosen machine exists in the region:
az vm list-skus --output table