Deploy cloudSwXtch with Terraform on Azure

Prev Next

WHAT TO EXPECT

By default, the terraform script will spin up a "small" cloudSwXtch. You can make edits to the Azure/terraform/terraform.tfvarse file to declare a different cloudSwXtch size. There is also an option to delegate static ip addresses on your cloudSwXtch. Further details on how to do this can be found at the end of this article.

Deploying cloudSwXtch with Terraform on Azure

  1. Sign-in to your Azure portal under the subscription where you want to deploy the cloudSwXtch.

  2. Open the Azure Cloud Shell interface and select the Bash environment as shown.

shell11
  1. Clone the example repository from GitHub.

You can do this either via SSH (requires setting up your SSH authentication with GitHub ):

$ git clone git@github.com:swxtchio/cloudSwXtch-support.git

or via HTTPS:

$ git clone https://github.com/swxtchio/cloudSwXtch-support.git
  1. Update the values in the Azure/terraform/terraform.tfvarse file to match your existing azure resources such as: resource group, virtual network, subnets, etc.

The format of the key file that the scripts can process is the ssh-rsa type. The content of the file should start with "ssh-rsa AAAAB3..."

  1. In the Cloud Shell terminal, cd into the Azure/terraform directory and initialize the terraform environment:

$ cd Azure/terraform
$ terraform init
image.png
  1. Now that Terraform has been initialized, run this command to evaluate the config and confirm the desired output which will be shown:

$ terraform plan
image.png

Since you are using all pre-existing resources to deploy your cloudSwXtch, there should only be 3 resources added - 1 cloudSwxtch, and 2 NICs - as can be seen at the bottom of the screenshot, “Plan: 3 to add, 0 to change, 0 to destroy.”

  1. Run the Terraform apply command (followed by “yes” when prompted) to approve the action.

Terraform apply
yes
  1. Once the resources have applied successfully you can view the resources created from your Azure portal as confirmation of a successful deployment.

STATIC IPs

If you'd like to deploy a cloudSwXtch using Static IPs, then you just need to make some small changes to the azure_deployswxtch.tf & terraform.tfvars  files.

  1. Un-comment the Parameter  private_ip_address in the azure_deployswxtch.tf code file for both your data_network_interface & control_network_interface resources.

networkinterface_staticip1
  1. Set the parameter private_ip_address_allocation to "Static".

Your 2 lines of code should look like below for both network interface resources:

private_ip_address_allocation = “Static”
private_ip_address = var.datanic_staticip

Your terraform.tfvars file will have variables defined for your control and data NIC StaticIP definitions. You can update those values based on your subnet setup.

Note: This static IP address allocation will only work for swxtch_count of 1.