@@ -23,25 +23,15 @@ func TestAccCloudStackEgressFirewall_basic(t *testing.T) {
2323 resource .TestCheckResourceAttr (
2424 "cloudstack_egress_firewall.foo" , "network_id" , CLOUDSTACK_NETWORK_1 ),
2525 resource .TestCheckResourceAttr (
26- "cloudstack_egress_firewall.foo" , "rule.#" , "2 " ),
26+ "cloudstack_egress_firewall.foo" , "rule.#" , "1 " ),
2727 resource .TestCheckResourceAttr (
2828 "cloudstack_egress_firewall.foo" ,
29- "rule.1081385056 .cidr_list.3378711023" ,
29+ "rule.2905891128 .cidr_list.3378711023" ,
3030 CLOUDSTACK_NETWORK_1_IPADDRESS1 + "/32" ),
3131 resource .TestCheckResourceAttr (
32- "cloudstack_egress_firewall.foo" , "rule.1081385056.protocol" , "tcp" ),
33- resource .TestCheckResourceAttr (
34- "cloudstack_egress_firewall.foo" , "rule.1081385056.ports.32925333" , "8080" ),
35- resource .TestCheckResourceAttr (
36- "cloudstack_egress_firewall.foo" ,
37- "rule.1129999216.source_cidr" ,
38- CLOUDSTACK_NETWORK_1_IPADDRESS1 + "/32" ),
32+ "cloudstack_egress_firewall.foo" , "rule.2905891128.protocol" , "tcp" ),
3933 resource .TestCheckResourceAttr (
40- "cloudstack_egress_firewall.foo" , "rule.1129999216.protocol" , "tcp" ),
41- resource .TestCheckResourceAttr (
42- "cloudstack_egress_firewall.foo" , "rule.1129999216.ports.1209010669" , "1000-2000" ),
43- resource .TestCheckResourceAttr (
44- "cloudstack_egress_firewall.foo" , "rule.1129999216.ports.1889509032" , "80" ),
34+ "cloudstack_egress_firewall.foo" , "rule.2905891128.ports.32925333" , "8080" ),
4535 ),
4636 },
4737 },
@@ -61,25 +51,15 @@ func TestAccCloudStackEgressFirewall_update(t *testing.T) {
6151 resource .TestCheckResourceAttr (
6252 "cloudstack_egress_firewall.foo" , "network_id" , CLOUDSTACK_NETWORK_1 ),
6353 resource .TestCheckResourceAttr (
64- "cloudstack_egress_firewall.foo" , "rule.#" , "2 " ),
54+ "cloudstack_egress_firewall.foo" , "rule.#" , "1 " ),
6555 resource .TestCheckResourceAttr (
6656 "cloudstack_egress_firewall.foo" ,
67- "rule.1081385056 .cidr_list.3378711023" ,
57+ "rule.2905891128 .cidr_list.3378711023" ,
6858 CLOUDSTACK_NETWORK_1_IPADDRESS1 + "/32" ),
6959 resource .TestCheckResourceAttr (
70- "cloudstack_egress_firewall.foo" , "rule.1081385056.protocol" , "tcp" ),
71- resource .TestCheckResourceAttr (
72- "cloudstack_egress_firewall.foo" , "rule.1081385056.ports.32925333" , "8080" ),
60+ "cloudstack_egress_firewall.foo" , "rule.2905891128.protocol" , "tcp" ),
7361 resource .TestCheckResourceAttr (
74- "cloudstack_egress_firewall.foo" ,
75- "rule.1129999216.source_cidr" ,
76- CLOUDSTACK_NETWORK_1_IPADDRESS1 + "/32" ),
77- resource .TestCheckResourceAttr (
78- "cloudstack_egress_firewall.foo" , "rule.1129999216.protocol" , "tcp" ),
79- resource .TestCheckResourceAttr (
80- "cloudstack_egress_firewall.foo" , "rule.1129999216.ports.1209010669" , "1000-2000" ),
81- resource .TestCheckResourceAttr (
82- "cloudstack_egress_firewall.foo" , "rule.1129999216.ports.1889509032" , "80" ),
62+ "cloudstack_egress_firewall.foo" , "rule.2905891128.ports.32925333" , "8080" ),
8363 ),
8464 },
8565
@@ -90,37 +70,27 @@ func TestAccCloudStackEgressFirewall_update(t *testing.T) {
9070 resource .TestCheckResourceAttr (
9171 "cloudstack_egress_firewall.foo" , "network_id" , CLOUDSTACK_NETWORK_1 ),
9272 resource .TestCheckResourceAttr (
93- "cloudstack_egress_firewall.foo" , "rule.#" , "3 " ),
73+ "cloudstack_egress_firewall.foo" , "rule.#" , "2 " ),
9474 resource .TestCheckResourceAttr (
9575 "cloudstack_egress_firewall.foo" ,
96- "rule.59731059 .cidr_list.1910468234" ,
76+ "rule.3593527682 .cidr_list.1910468234" ,
9777 CLOUDSTACK_NETWORK_1_IPADDRESS2 + "/32" ),
9878 resource .TestCheckResourceAttr (
9979 "cloudstack_egress_firewall.foo" ,
100- "rule.59731059 .cidr_list.3378711023" ,
80+ "rule.3593527682 .cidr_list.3378711023" ,
10181 CLOUDSTACK_NETWORK_1_IPADDRESS1 + "/32" ),
10282 resource .TestCheckResourceAttr (
103- "cloudstack_egress_firewall.foo" , "rule.59731059 .protocol" , "tcp" ),
83+ "cloudstack_egress_firewall.foo" , "rule.3593527682 .protocol" , "tcp" ),
10484 resource .TestCheckResourceAttr (
105- "cloudstack_egress_firewall.foo" , "rule.59731059 .ports.32925333" , "8080" ),
85+ "cloudstack_egress_firewall.foo" , "rule.3593527682 .ports.32925333" , "8080" ),
10686 resource .TestCheckResourceAttr (
10787 "cloudstack_egress_firewall.foo" ,
108- "rule.1052669680.source_cidr " ,
88+ "rule.739924765.cidr_list.3378711023 " ,
10989 CLOUDSTACK_NETWORK_1_IPADDRESS1 + "/32" ),
11090 resource .TestCheckResourceAttr (
111- "cloudstack_egress_firewall.foo" , "rule.1052669680 .protocol" , "tcp" ),
91+ "cloudstack_egress_firewall.foo" , "rule.739924765 .protocol" , "tcp" ),
11292 resource .TestCheckResourceAttr (
113- "cloudstack_egress_firewall.foo" , "rule.1052669680.ports.3638101695" , "443" ),
114- resource .TestCheckResourceAttr (
115- "cloudstack_egress_firewall.foo" ,
116- "rule.1129999216.source_cidr" ,
117- CLOUDSTACK_NETWORK_1_IPADDRESS1 + "/32" ),
118- resource .TestCheckResourceAttr (
119- "cloudstack_egress_firewall.foo" , "rule.1129999216.protocol" , "tcp" ),
120- resource .TestCheckResourceAttr (
121- "cloudstack_egress_firewall.foo" , "rule.1129999216.ports.1209010669" , "1000-2000" ),
122- resource .TestCheckResourceAttr (
123- "cloudstack_egress_firewall.foo" , "rule.1129999216.ports.1889509032" , "80" ),
93+ "cloudstack_egress_firewall.foo" , "rule.739924765.ports.1889509032" , "80" ),
12494 ),
12595 },
12696 },
@@ -139,7 +109,7 @@ func testAccCheckCloudStackEgressFirewallRulesExist(n string) resource.TestCheck
139109 }
140110
141111 for k , id := range rs .Primary .Attributes {
142- if ! strings .Contains (k , ".uuids." ) || strings .HasSuffix (k , ".uuids.# " ) {
112+ if ! strings .Contains (k , ".uuids." ) || strings .HasSuffix (k , ".uuids.% " ) {
143113 continue
144114 }
145115
@@ -172,7 +142,7 @@ func testAccCheckCloudStackEgressFirewallDestroy(s *terraform.State) error {
172142 }
173143
174144 for k , id := range rs .Primary .Attributes {
175- if ! strings .Contains (k , ".uuids." ) || strings .HasSuffix (k , ".uuids.# " ) {
145+ if ! strings .Contains (k , ".uuids." ) || strings .HasSuffix (k , ".uuids.% " ) {
176146 continue
177147 }
178148
@@ -195,15 +165,8 @@ resource "cloudstack_egress_firewall" "foo" {
195165 protocol = "tcp"
196166 ports = ["8080"]
197167 }
198-
199- rule {
200- source_cidr = "%s/32"
201- protocol = "tcp"
202- ports = ["80", "1000-2000"]
203- }
204168}` ,
205169 CLOUDSTACK_NETWORK_1 ,
206- CLOUDSTACK_NETWORK_1_IPADDRESS1 ,
207170 CLOUDSTACK_NETWORK_1_IPADDRESS1 )
208171
209172var testAccCloudStackEgressFirewall_update = fmt .Sprintf (`
@@ -217,19 +180,12 @@ resource "cloudstack_egress_firewall" "foo" {
217180 }
218181
219182 rule {
220- source_cidr = "%s/32"
183+ cidr_list = [ "%s/32"]
221184 protocol = "tcp"
222185 ports = ["80", "1000-2000"]
223186 }
224-
225- rule {
226- source_cidr = "%s/32"
227- protocol = "tcp"
228- ports = ["443"]
229- }
230187}` ,
231188 CLOUDSTACK_NETWORK_1 ,
232189 CLOUDSTACK_NETWORK_1_IPADDRESS1 ,
233190 CLOUDSTACK_NETWORK_1_IPADDRESS2 ,
234- CLOUDSTACK_NETWORK_1_IPADDRESS1 ,
235191 CLOUDSTACK_NETWORK_1_IPADDRESS1 )
0 commit comments