Skip to content

UCL/terraform-azure-sirf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

terraform-azure-sirf

DOI

This repo demonstrates how to build and install SIRF 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 SIRF.

An Azure account is required for deployment.

Configure Terraform access to Azure

  • 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 and tenantId for future use.
  • Set the environment variable SUBSCRIPTION_ID to the subscription ID returned by the az 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 and password

Configure Terraform environment variables

  • Copy var_values.tfvars.example to var_values.tfvars
  • Edit var_values.tfvars such that YOUR_SUBSCRIPTION_ID_HERE, YOUR_APPLICATION_ID_HERE,YOUR_SECRET_KEY_HERE and YOUR_TENANT_ID_HERE are replaced by your subscriptionId, appId, password and tenantId respectively.

Running the Terraform script

  • 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 <RESGROUP> --name <VMNAME> -d --query [publicIps] --o tsv

where RESGROUP is the value set for vm_prefix followed by Group (default: sirfGroup) and VMNAME is the vm_prefix value followed by VM (default: sirfVM).

  • 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: sirfuser) and PUBLICIP is the public IP address found with the previous command. The password for access to the virtual machine is the value of vm_password (default: sirf%1).

Jupyter

Once built, a Jupyter notebook will be running. The URL can be accessed from a web browser:

https://<PUBLICIP>:<JUPPORT>

where PUBLICIP is the IP address found previously and JUPPORT is the Jupyter server port set by vm_jupyter_port (default: 9999). The password for access to the notebook is controlled by the variable vm_jupyter_pwd (default: virtual%1).

Remote desktop

A remote desktop to the VM is available. See the instructions on the wiki.

Removing the infrastructure

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.

Troubleshooting

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