Aviatrix Terraform Provider

Aviatrix Terraform Provider is used to interact with Aviatrix resources.

Read the Aviatrix Terraform Provider Tutorial to setup the environment.

The provider allows you to manage Aviatrix resources such as account, gateway, peering, etc. It needs to be configured with valid Aviatrix UCC/CloudN’s IP, and account credentials. For Aviatrix Transit Network deployment, please click here to read how to setup transit VPC using Terraform.

Example Usage

# Configure Aviatrix provider
provider "aviatrix" {
  controller_ip = "1.2.3.4"
  username = "admin"
  password = "password"
}

# Create a record
resource "aviatrix_account" "myacc" {
  # ...
}

Resources

The complete documentation for all the resources are available here

Data Sources

The complete documentation for all the data sources are available here

Sample configuration to launch a full mesh network on AWS

# Sample Aviatrix terraform configuration to create a full mesh network on AWS
# This configuration creates a cloud account on the Aviatrix controller,
# launches 3 gateways with the created account and establishes tunnels
# between each gateway.


# Edit to enter your controller's IP, username and password to login with.
provider "aviatrix" {
  controller_ip = "w.x.y.z"
  username = "admin"
  password = "Aviatrix123"
}

# Increase count default value to add more VPCs and subnets to launch more gateways together.

variable "count" {
  default = 3
}

# Enter VPCs where you want to launch gateways.
variable "vpcs" {
  description = "Launch gateways in different VPCs."
  type = "list"
  default = ["vpc-7a6b2513", "vpc-2ee4a147", "vpc-0d7b3664"]
}

# Enter Subnets within VPCs added above.
variable "vpc_nets" {
  description = "Launch gateways in different VPC Subnets."
  type = "list"
  default = ["10.1.0.0/24", "10.2.0.0/24", "10.3.0.0/24"]
}

resource "aviatrix_account" "test_acc" {
  account_name = "devops"
  cloud_type = 1
  aws_account_number = "123456789012"
  aws_iam = "true"
  aws_role_app = "arn:aws:iam::123456789012:role/aviatrix-role-app"
  aws_role_ec2 = "arn:aws:iam::123456789012:role/aviatrix-role-ec2"
}

# Create count number of gateways
resource "aviatrix_gateway" "test_gw" {
  count = "${var.count}"
  cloud_type = 1
  account_name = "devops"
  gw_name = "avtxgw-${count.index}"
  vpc_id = "${element(var.vpcs, count.index)}"
  vpc_reg = "ap-south-1"
  vpc_size = "t2.micro"
  vpc_net = "${element(var.vpc_nets, count.index)}"
  depends_on = ["aviatrix_account.test_acc"]
}

# Create tunnels between above created gateways.
resource "aviatrix_tunnel" "test_tunnel" {
  count = "${var.count * (var.count - 1)/2}"
  vpc_name1 = "avtxgw-${count.index}"
  vpc_name2 = "avtxgw-${(count.index+1)%3}"
  depends_on = ["aviatrix_gateway.test_gw"]
}