Skip to content

Commit 94a6b8d

Browse files
add cloudlb example (#172)
1 parent 243e3ec commit 94a6b8d

File tree

4 files changed

+203
-0
lines changed

4 files changed

+203
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
resource "time_sleep" "wait_for_cloudLB" {
3+
depends_on = [aci_rest.appliedServiceGraph]
4+
create_duration = "10s"
5+
}
6+
7+
data "aws_lb" "wwwalb" {
8+
depends_on = [time_sleep.wait_for_cloudLB]
9+
name = "${var.name}-${join("", regex("ctxprofile-(.*?)/", var.subnet_a_dn))}"
10+
}
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
resource "aci_rest" "cloudALB" {
2+
path = "/api/node/mo/${join("", regex("(uni/tn-.*?)/", var.epg_dn))}/clb-${var.name}.json"
3+
payload = <<EOF
4+
cloudLB:
5+
attributes:
6+
scheme: internet
7+
type: application
8+
children:
9+
- cloudRsLDevToCloudSubnet:
10+
attributes:
11+
tDn: ${var.subnet_a_dn}
12+
- cloudRsLDevToCloudSubnet:
13+
attributes:
14+
tDn: ${var.subnet_b_dn}
15+
EOF
16+
}
17+
18+
resource "aci_rest" "serviceGraphCreate" {
19+
path = "/api/node/mo/${join("", regex("(uni/tn-.*?)/", var.epg_dn))}/AbsGraph-${var.name}.json"
20+
depends_on = [aci_rest.cloudALB]
21+
payload = <<EOF
22+
vnsAbsGraph:
23+
attributes:
24+
name: ${var.name}
25+
type: cloud
26+
children:
27+
- vnsAbsTermNodeProv:
28+
attributes:
29+
name: T2
30+
children:
31+
- vnsAbsTermConn:
32+
attributes:
33+
name: ProvTermConn
34+
- vnsAbsTermNodeCon:
35+
attributes:
36+
name: T1
37+
children:
38+
- vnsAbsTermConn:
39+
attributes:
40+
name: ConsTermConn
41+
- vnsAbsNode:
42+
attributes:
43+
name: N0
44+
managed: "yes"
45+
funcType: GoTo
46+
funcTemplateType: ADC_ONE_ARM
47+
children:
48+
- vnsRsNodeToCloudLDev:
49+
attributes:
50+
tDn: ${join("", regex("(uni/tn-.*?)/", var.epg_dn))}/clb-${var.name}
51+
- vnsAbsFuncConn:
52+
attributes:
53+
name: provider
54+
attNotify: "no"
55+
connType: none
56+
- vnsAbsFuncConn:
57+
attributes:
58+
name: consumer
59+
attNotify: "no"
60+
connType: none
61+
- vnsAbsConnection:
62+
attributes:
63+
connDir: provider
64+
connType: external
65+
name: CON1
66+
adjType: L3
67+
children:
68+
- vnsRsAbsConnectionConns:
69+
attributes:
70+
tDn: ${join("", regex("(uni/tn-.*?)/", var.epg_dn))}/AbsGraph-${var.name}/AbsNode-N0/AbsFConn-provider
71+
- vnsRsAbsConnectionConns:
72+
attributes:
73+
tDn: ${join("", regex("(uni/tn-.*?)/", var.epg_dn))}/AbsGraph-${var.name}/AbsTermNodeProv-T2/AbsTConn
74+
- vnsAbsConnection:
75+
attributes:
76+
connDir: provider
77+
connType: external
78+
name: CON0
79+
children:
80+
- vnsRsAbsConnectionConns:
81+
attributes:
82+
tDn: ${join("", regex("(uni/tn-.*?)/", var.epg_dn))}/AbsGraph-${var.name}/AbsNode-N0/AbsFConn-consumer
83+
- vnsRsAbsConnectionConns:
84+
attributes:
85+
tDn: ${join("", regex("(uni/tn-.*?)/", var.epg_dn))}/AbsGraph-${var.name}/AbsTermNodeCon-T1/AbsTConn
86+
EOF
87+
}
88+
89+
resource "aci_rest" "appliedServiceGraph" {
90+
path = "/api/node/mo/${join("", regex("(uni/tn-.*?)/", var.epg_dn))}.json"
91+
depends_on = [aci_rest.serviceGraphCreate]
92+
payload = <<EOF
93+
fvTenant:
94+
attributes:
95+
name: ${join("", regex("/tn-(.*?)/", var.epg_dn))}
96+
children:
97+
- vnsAbsGraph:
98+
attributes:
99+
name: ${var.name}
100+
children:
101+
- vnsAbsNode:
102+
attributes:
103+
name: N0
104+
children:
105+
- cloudSvcPolicy:
106+
attributes:
107+
contractName: ${join("", regex("/brc-(.*?)/", var.contract_subject_dn))}
108+
subjectName: ${join("", regex("/subj-(.*)", var.contract_subject_dn))}
109+
tenantName: ${join("", regex("/tn-(.*?)/", var.epg_dn))}
110+
children:
111+
- cloudListener:
112+
attributes:
113+
name: http_listener
114+
port: "${var.listenerPort}"
115+
protocol: http
116+
children:
117+
- cloudListenerRule:
118+
attributes:
119+
default: "yes"
120+
name: forward
121+
priority: "999"
122+
children:
123+
- cloudRuleAction:
124+
attributes:
125+
epgdn: ${var.epg_dn}
126+
port: "${var.hostPort}"
127+
protocol: http
128+
type: forward
129+
- vzBrCP:
130+
attributes:
131+
name: ${join("", regex("/brc-(.*?)/", var.contract_subject_dn))}
132+
children:
133+
- vzSubj:
134+
attributes:
135+
name: ${join("", regex("/subj-(.*)", var.contract_subject_dn))}
136+
children:
137+
- vzRsSubjGraphAtt:
138+
attributes:
139+
tnVnsAbsGraphName: ${var.name}
140+
EOF
141+
}
142+
143+
output "dnsname" {
144+
value = data.aws_lb.wwwalb.dns_name
145+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
terraform {
3+
required_providers {
4+
aws = {
5+
source = "hashicorp/aws"
6+
version = "3.12.0"
7+
}
8+
aci = {
9+
source = "CiscoDevNet/aci"
10+
version = "0.5.0"
11+
}
12+
}
13+
14+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
variable "name" {
2+
description = "Name to assign to the cloud boad balancer"
3+
type = string
4+
}
5+
6+
variable "epg_dn" {
7+
description = "DN for the target EPG where the loadbalancer should send traffic"
8+
type = string
9+
}
10+
11+
variable "contract_subject_dn" {
12+
description = "DN for the contract subject where the loadbalancer should be attached"
13+
type = string
14+
}
15+
16+
variable "subnet_a_dn" {
17+
description = "Dn for the ACI subnet A"
18+
type = string
19+
}
20+
21+
variable "subnet_b_dn" {
22+
description = "Dn for the ACI subnet B"
23+
type = string
24+
}
25+
26+
variable "listenerPort" {
27+
description = "External TCP port number for the http listener (ex. 80)"
28+
type = string
29+
}
30+
31+
variable "hostPort" {
32+
description = "Internal TCP port number for the http server (ex. 80)"
33+
type = string
34+
}

0 commit comments

Comments
 (0)