@@ -12,6 +12,8 @@ Creates network ACL rules for a given network ACL.
1212
1313## Example Usage
1414
15+ ### Basic Example with Port
16+
1517``` hcl
1618resource "cloudstack_network_acl_rule" "default" {
1719 acl_id = "f3843ce0-334c-4586-bbd3-0c2e2bc946c6"
@@ -20,12 +22,112 @@ resource "cloudstack_network_acl_rule" "default" {
2022 action = "allow"
2123 cidr_list = ["10.0.0.0/8"]
2224 protocol = "tcp"
23- ports = ["80", "1000-2000"]
25+ port = "80"
26+ traffic_type = "ingress"
27+ }
28+ }
29+ ```
30+
31+ ### Example with Port Range
32+
33+ ``` hcl
34+ resource "cloudstack_network_acl_rule" "port_range" {
35+ acl_id = "f3843ce0-334c-4586-bbd3-0c2e2bc946c6"
36+
37+ rule {
38+ action = "allow"
39+ cidr_list = ["192.168.1.0/24"]
40+ protocol = "tcp"
41+ port = "8000-8010"
42+ traffic_type = "ingress"
43+ }
44+ }
45+ ```
46+
47+ ### Example with No Port (Allow All Ports)
48+
49+ ``` hcl
50+ resource "cloudstack_network_acl_rule" "all_ports" {
51+ acl_id = "f3843ce0-334c-4586-bbd3-0c2e2bc946c6"
52+
53+ rule {
54+ action = "allow"
55+ cidr_list = ["10.0.0.0/16"]
56+ protocol = "tcp"
57+ traffic_type = "ingress"
58+ description = "Allow all TCP traffic from internal network"
59+ }
60+ }
61+ ```
62+
63+ ### Example with ICMP
64+
65+ ``` hcl
66+ resource "cloudstack_network_acl_rule" "icmp" {
67+ acl_id = "f3843ce0-334c-4586-bbd3-0c2e2bc946c6"
68+
69+ rule {
70+ action = "allow"
71+ cidr_list = ["0.0.0.0/0"]
72+ protocol = "icmp"
73+ icmp_type = 8
74+ icmp_code = 0
2475 traffic_type = "ingress"
76+ description = "Allow ping"
2577 }
2678}
2779```
2880
81+ ### Complete Example with Multiple Rules
82+
83+ ``` hcl
84+ resource "cloudstack_network_acl_rule" "web_server" {
85+ acl_id = "f3843ce0-334c-4586-bbd3-0c2e2bc946c6"
86+
87+ # HTTP traffic
88+ rule {
89+ rule_number = 10
90+ action = "allow"
91+ cidr_list = ["0.0.0.0/0"]
92+ protocol = "tcp"
93+ port = "80"
94+ traffic_type = "ingress"
95+ description = "Allow HTTP"
96+ }
97+
98+ # HTTPS traffic
99+ rule {
100+ rule_number = 20
101+ action = "allow"
102+ cidr_list = ["0.0.0.0/0"]
103+ protocol = "tcp"
104+ port = "443"
105+ traffic_type = "ingress"
106+ description = "Allow HTTPS"
107+ }
108+
109+ # SSH from management network
110+ rule {
111+ rule_number = 30
112+ action = "allow"
113+ cidr_list = ["192.168.100.0/24"]
114+ protocol = "tcp"
115+ port = "22"
116+ traffic_type = "ingress"
117+ description = "Allow SSH from management"
118+ }
119+
120+ # Allow all outbound traffic
121+ rule {
122+ rule_number = 100
123+ action = "allow"
124+ cidr_list = ["0.0.0.0/0"]
125+ protocol = "tcp"
126+ traffic_type = "egress"
127+ description = "Allow all outbound TCP"
128+ }
129+ }
130+
29131## Argument Reference
30132
31133The following arguments are supported:
@@ -64,8 +166,15 @@ The `rule` block supports:
64166* `icmp_code` - (Optional) The ICMP code to allow, or `-1` to allow `any`. This
65167 can only be specified if the protocol is ICMP. (defaults 0)
66168
67- * ` ports ` - (Optional) List of ports and/or port ranges to allow. This can only
68- be specified if the protocol is TCP, UDP, ALL or a valid protocol number.
169+ * `port` - (Optional) Port or port range to allow. This can only be specified if
170+ the protocol is TCP, UDP, ALL or a valid protocol number. Valid formats are:
171+ - Single port: `"80"`
172+ - Port range: `"8000-8010"`
173+ - If not specified for TCP/UDP, allows all ports for that protocol
174+
175+ * `ports` - (Optional) **DEPRECATED**: Use `port` instead. List of ports and/or
176+ port ranges to allow. This field is deprecated and will be removed in a future
177+ version. For backward compatibility only.
69178
70179* `traffic_type` - (Optional) The traffic type for the rule. Valid options are:
71180 `ingress` or `egress` (defaults ingress).
0 commit comments