forked from kbavx/terraform-provider-aviatrix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaviatrix.tf
63 lines (54 loc) · 1.9 KB
/
aviatrix.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Sample Aviatrix terraform configuration to create a full mesh network on AWS
# This configuration creates a cloud account on 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 = "52.66.90.40"
username = "admin"
password = "Aviatrix123%23"
}
# 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"
account_password = "Aviatrix123"
account_email = "[email protected]"
cloud_type = 1
aws_account_number = "123456789012"
aws_iam = "true"
aws_role_arn = "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"]
}