Skip to content

Commit 111a60f

Browse files
authored
fix: Added missing attribute source_countries to ZIA zia_firewall_filtering_rule (#375)
1 parent 45a003a commit 111a60f

12 files changed

+82
-27
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Changelog
22

3+
## 3.0.6 (October, 8 2024)
4+
5+
### Notes
6+
7+
- Release date: **(October, 8 2024)**
8+
- Supported Terraform version: **v1.x**
9+
10+
### Bug Fixes
11+
12+
- [PR #374](https://github.com/zscaler/terraform-provider-zia/pull/374) - Added missing attribute `sourceCountries` to ZIA `firewallfilteringrule`
13+
314
## 3.0.5 (October, 4 2024)
415

516
### Notes

GNUmakefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,14 +196,14 @@ test\:integration\:zscalertwo:
196196
build13: GOOS=$(shell go env GOOS)
197197
build13: GOARCH=$(shell go env GOARCH)
198198
ifeq ($(OS),Windows_NT) # is Windows_NT on XP, 2000, 7, Vista, 10...
199-
build13: DESTINATION=$(APPDATA)/terraform.d/plugins/$(ZIA_PROVIDER_NAMESPACE)/3.0.5/$(GOOS)_$(GOARCH)
199+
build13: DESTINATION=$(APPDATA)/terraform.d/plugins/$(ZIA_PROVIDER_NAMESPACE)/3.0.6/$(GOOS)_$(GOARCH)
200200
else
201-
build13: DESTINATION=$(HOME)/.terraform.d/plugins/$(ZIA_PROVIDER_NAMESPACE)/3.0.5/$(GOOS)_$(GOARCH)
201+
build13: DESTINATION=$(HOME)/.terraform.d/plugins/$(ZIA_PROVIDER_NAMESPACE)/3.0.6/$(GOOS)_$(GOARCH)
202202
endif
203203
build13: fmtcheck
204204
@echo "==> Installing plugin to $(DESTINATION)"
205205
@mkdir -p $(DESTINATION)
206-
go build -o $(DESTINATION)/terraform-provider-zia_v3.0.5
206+
go build -o $(DESTINATION)/terraform-provider-zia_v3.0.6
207207

208208
coverage: test
209209
@echo "✓ Opening coverage for unit tests ..."

docs/guides/release-notes.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,21 @@ description: |-
1212
Track all ZIA Terraform provider's releases. New resources, features, and bug fixes will be tracked here.
1313

1414
---
15-
``Last updated: v3.0.5``
15+
``Last updated: v3.0.6``
1616

1717
---
1818

19+
## 3.0.6 (October, 8 2024)
20+
21+
### Notes
22+
23+
- Release date: **(October, 8 2024)**
24+
- Supported Terraform version: **v1.x**
25+
26+
### Bug Fixes
27+
28+
- [PR #374](https://github.com/zscaler/terraform-provider-zia/pull/374) - Added missing attribute `sourceCountries` to ZIA `firewallfilteringrule`
29+
1930
## 3.0.5 (October, 4 2024)
2031

2132
### Notes

docs/resources/zia_firewall_filtering_rule.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,17 @@ The following arguments are supported:
9797
* `src_ips` - (Optional) You can enter individual IP addresses, subnets, or address ranges.
9898

9999
* `dest_addresses`** - (Optional) - IP addresses and fully qualified domain names (FQDNs), if the domain has multiple destination IP addresses or if its IP addresses may change. For IP addresses, you can enter individual IP addresses, subnets, or address ranges.
100+
100101
**NOTE**: PLEASE BE AWARE. The API supports ONLY `IPv4` addresses. `IPV6` addresses are not supported.
101-
* `dest_countries`** - (Optional) Identify destinations based on the location of a server, select Any to apply the rule to all countries or select the countries to which you want to control traffic.
102+
103+
* `dest_countries`** - (Optional) Destination countries for which the rule is applicable. If not set, the rule is not restricted to specific destination countries.
104+
105+
**NOTE**: Provide a 2 letter [ISO3166 Alpha2 Country code](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes). i.e ``"US"``, ``"CA"``
106+
107+
* `source_countries`** - (Optional) The list of source countries that must be included or excluded from the rule based on the excludeSrcCountries field value. If no value is set, this field is ignored during policy evaluation and the rule is applied to all source countries.
108+
109+
**NOTE**: Provide a 2 letter [ISO3166 Alpha2 Country code](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes). i.e ``"US"``, ``"CA"``
110+
102111
* `dest_ip_categories`** - (Optional) identify destinations based on the URL category of the domain, select Any to apply the rule to all categories or select the specific categories you want to control.
103112
- `id` - (String) Identifier that uniquely identifies an entity
104113
* `dest_ip_groups`** - (Optional) Any number of destination IP address groups that you want to control with this rule.

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require (
1111
github.com/hashicorp/go-hclog v1.6.3
1212
github.com/hashicorp/terraform-plugin-sdk v1.17.2
1313
github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0
14-
github.com/zscaler/zscaler-sdk-go/v2 v2.72.3
14+
github.com/zscaler/zscaler-sdk-go/v2 v2.72.5
1515
)
1616

1717
require (
@@ -60,7 +60,7 @@ require (
6060
golang.org/x/net v0.26.0 // indirect
6161
golang.org/x/sync v0.8.0 // indirect
6262
golang.org/x/sys v0.21.0 // indirect
63-
golang.org/x/text v0.18.0 // indirect
63+
golang.org/x/text v0.19.0 // indirect
6464
golang.org/x/tools v0.22.0 // indirect
6565
google.golang.org/appengine v1.6.8 // indirect
6666
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,8 @@ github.com/zclconf/go-cty v1.14.4/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgr
388388
github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b h1:FosyBZYxY34Wul7O/MSKey3txpPYyCqVO5ZyceuQJEI=
389389
github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8=
390390
github.com/zclconf/go-cty-yaml v1.0.2/go.mod h1:IP3Ylp0wQpYm50IHK8OZWKMu6sPJIUgKa8XhiVHura0=
391-
github.com/zscaler/zscaler-sdk-go/v2 v2.72.3 h1:tkevJxm0QjZMuw2OQJBG12P5/xjQIbhcgLPo+6JOrtA=
392-
github.com/zscaler/zscaler-sdk-go/v2 v2.72.3/go.mod h1:DW8JW8Cv2uxsfdlPN/Szk+CX9/nPyjhk/aERtTbJVYo=
391+
github.com/zscaler/zscaler-sdk-go/v2 v2.72.5 h1:IL9eFbcvDEoS6x17ipy/kThgubdiknIeXtA37hn7SQY=
392+
github.com/zscaler/zscaler-sdk-go/v2 v2.72.5/go.mod h1:ugDudbyESUrANGw74moJypgVnWuOyLm8NyIJgfUzNNo=
393393
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
394394
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
395395
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
@@ -551,8 +551,8 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
551551
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
552552
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
553553
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
554-
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
555-
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
554+
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
555+
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
556556
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
557557
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
558558
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=

zia/common.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -636,13 +636,13 @@ func getLocationManagementTimeZones() *schema.Schema {
636636
}
637637
}
638638

639-
func getDestinationCountries() *schema.Schema {
639+
func getISOCountryCodes() *schema.Schema {
640640
return &schema.Schema{
641641
Type: schema.TypeSet,
642642
Description: "Destination countries for which the rule is applicable. If not set, the rule is not restricted to specific destination countries.",
643643
Elem: &schema.Schema{
644644
Type: schema.TypeString,
645-
ValidateFunc: validateDestinationCountries,
645+
ValidateFunc: validateISOCountryCodes,
646646
},
647647
Optional: true,
648648
Computed: true,

zia/resource_zia_firewall_filtering_rules.go

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ func resourceFirewallFilteringRules() *schema.Resource {
160160
"workload_groups": setIdNameSchemaCustom(255, "The list of preconfigured workload groups to which the policy must be applied"),
161161
"nw_services": setIDsSchemaTypeCustom(intPtr(1024), "list of nw services"),
162162
"zpa_app_segments": setExtIDNameSchemaCustom(intPtr(255), "The list of ZPA Application Segments for which this rule is applicable. This field is applicable only for the ZPA Gateway forwarding method."),
163-
"dest_countries": getDestinationCountries(),
163+
"dest_countries": getISOCountryCodes(),
164+
"source_countries": getISOCountryCodes(),
164165
"nw_applications": getCloudFirewallNwApplications(),
165166
"device_trust_levels": getDeviceTrustLevels(),
166167
},
@@ -296,6 +297,11 @@ func resourceFirewallFilteringRulesRead(d *schema.ResourceData, m interface{}) e
296297
processedDestCountries[i] = strings.TrimPrefix(country, "COUNTRY_")
297298
}
298299

300+
processedSrcCountries := make([]string, len(resp.SourceCountries))
301+
for i, country := range resp.SourceCountries {
302+
processedSrcCountries[i] = strings.TrimPrefix(country, "COUNTRY_")
303+
}
304+
299305
log.Printf("[INFO] Getting firewall filtering rule:\n%+v\n", resp)
300306

301307
d.SetId(fmt.Sprintf("%d", resp.ID))
@@ -312,6 +318,7 @@ func resourceFirewallFilteringRulesRead(d *schema.ResourceData, m interface{}) e
312318
_ = d.Set("dest_addresses", resp.DestAddresses)
313319
_ = d.Set("dest_ip_categories", resp.DestIpCategories)
314320
_ = d.Set("dest_countries", processedDestCountries)
321+
_ = d.Set("source_countries", processedSrcCountries)
315322
_ = d.Set("nw_applications", resp.NwApplications)
316323
_ = d.Set("default_rule", resp.DefaultRule)
317324
_ = d.Set("predefined", resp.Predefined)
@@ -508,16 +515,19 @@ func resourceFirewallFilteringRulesDelete(d *schema.ResourceData, m interface{})
508515
func expandFirewallFilteringRules(d *schema.ResourceData) filteringrules.FirewallFilteringRules {
509516
id, _ := getIntFromResourceData(d, "rule_id")
510517

511-
// Process the DestCountries to add the prefix where needed
512-
rawDestCountries := SetToStringList(d, "dest_countries")
513-
processedDestCountries := make([]string, len(rawDestCountries))
514-
for i, country := range rawDestCountries {
515-
if country != "ANY" && country != "NONE" && len(country) == 2 { // Assuming the 2 letter code is an ISO Alpha-2 Code
516-
processedDestCountries[i] = "COUNTRY_" + country
517-
} else {
518-
processedDestCountries[i] = country
519-
}
520-
}
518+
// // Process the DestCountries to add the prefix where needed
519+
// rawDestCountries := SetToStringList(d, "dest_countries")
520+
// processedDestCountries := make([]string, len(rawDestCountries))
521+
// for i, country := range rawDestCountries {
522+
// if country != "ANY" && country != "NONE" && len(country) == 2 { // Assuming the 2 letter code is an ISO Alpha-2 Code
523+
// processedDestCountries[i] = "COUNTRY_" + country
524+
// } else {
525+
// processedDestCountries[i] = country
526+
// }
527+
// }
528+
// Process DestCountries and SourceCountries using the helper function
529+
processedDestCountries := processCountries(SetToStringList(d, "dest_countries"))
530+
processedSourceCountries := processCountries(SetToStringList(d, "source_countries"))
521531

522532
result := filteringrules.FirewallFilteringRules{
523533
ID: id,
@@ -532,6 +542,7 @@ func expandFirewallFilteringRules(d *schema.ResourceData) filteringrules.Firewal
532542
DestIpCategories: SetToStringList(d, "dest_ip_categories"),
533543
DeviceTrustLevels: SetToStringList(d, "device_trust_levels"),
534544
DestCountries: processedDestCountries,
545+
SourceCountries: processedSourceCountries,
535546
NwApplications: SetToStringList(d, "nw_applications"),
536547
EnableFullLogging: d.Get("enable_full_logging").(bool),
537548
DefaultRule: d.Get("default_rule").(bool),

zia/resource_zia_forwarding_control_rule.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ func resourceForwardingControlRule() *schema.Resource {
220220
"zpa_app_segments": setExtIDNameSchemaCustom(intPtr(255), "The list of ZPA Application Segments for which this rule is applicable. This field is applicable only for the ZPA Gateway forwarding method."),
221221
"zpa_application_segments": setIDsSchemaTypeCustom(intPtr(255), "List of ZPA Application Segments for which this rule is applicable. This field is applicable only for the ECZPA forwarding method (used for Zscaler Cloud Connector)."),
222222
"zpa_application_segment_groups": setIDsSchemaTypeCustom(intPtr(255), "List of ZPA Application Segment Groups for which this rule is applicable. This field is applicable only for the ECZPA forwarding method (used for Zscaler Cloud Connector)."),
223-
"dest_countries": getDestinationCountries(),
223+
"dest_countries": getISOCountryCodes(),
224224
},
225225
}
226226
}

zia/resource_zia_fw_filtering_ip_destination_groups.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func resourceFWIPDestinationGroups() *schema.Resource {
8787
Description: "Destination IP addresses within the group",
8888
},
8989
"ip_categories": getURLCategories(),
90-
"countries": getDestinationCountries(),
90+
"countries": getISOCountryCodes(),
9191
},
9292
}
9393
}

0 commit comments

Comments
 (0)