Skip to content

Commit

Permalink
fix: Fixed ZPA Specialized Application Segments Update Functions (#500)
Browse files Browse the repository at this point in the history
  • Loading branch information
willguibr authored Oct 31, 2024
1 parent a976d51 commit 3d73333
Show file tree
Hide file tree
Showing 18 changed files with 507 additions and 393 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## 3.33.9 (October, 31 2024)

### Notes

- Release date: **(October, 31 2024)**
- Supported Terraform version: **v1.x**

### Bug Fixes
- [PR #500](https://github.com/zscaler/terraform-provider-zpa/pull/500) - Implemented a fix to the update function across all specialized application segment resources:
- `zpa_application_segment_browser_access` - The fix now automatically includes the attributes `app_id` and `ba_app_id` in the payload during updates
- `zpa_application_segment_inspection` - The fix now automatically includes the attributes `app_id` and `inspect_app_id` in the payload during updates
- `zpa_application_segment_pra` - The fix now automatically includes the attributes `app_id` and `pra_app_id` in the payload during updates.
**NOTE:** This update/fix is required to ensure the ZPA API can properly identify the Browser Access, Inspection App and PRA App, based on its specific custom ID. The fix also includes the removal of the `ForceNew` option previously included in the schema to force the resource replacement in case of changes. Issue [PR #498](https://github.com/zscaler/terraform-provider-zpa/pull/498)

## 3.33.8 (October, 29 2024)

### Notes
Expand Down
6 changes: 3 additions & 3 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ test\:integration\:zpa:
build13: GOOS=$(shell go env GOOS)
build13: GOARCH=$(shell go env GOARCH)
ifeq ($(OS),Windows_NT) # is Windows_NT on XP, 2000, 7, Vista, 10...
build13: DESTINATION=$(APPDATA)/terraform.d/plugins/$(ZPA_PROVIDER_NAMESPACE)/3.33.8/$(GOOS)_$(GOARCH)
build13: DESTINATION=$(APPDATA)/terraform.d/plugins/$(ZPA_PROVIDER_NAMESPACE)/3.33.9/$(GOOS)_$(GOARCH)
else
build13: DESTINATION=$(HOME)/.terraform.d/plugins/$(ZPA_PROVIDER_NAMESPACE)/3.33.8/$(GOOS)_$(GOARCH)
build13: DESTINATION=$(HOME)/.terraform.d/plugins/$(ZPA_PROVIDER_NAMESPACE)/3.33.9/$(GOOS)_$(GOARCH)
endif
build13: fmtcheck
@echo "==> Installing plugin to $(DESTINATION)"
@mkdir -p $(DESTINATION)
go build -o $(DESTINATION)/terraform-provider-zpa_v3.33.8
go build -o $(DESTINATION)/terraform-provider-zpa_v3.33.9

vet:
@echo "==> Checking source code against go vet and staticcheck"
Expand Down
16 changes: 15 additions & 1 deletion docs/guides/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,24 @@ Track all ZPA Terraform provider's releases. New resources, features, and bug fi

---

``Last updated: v3.33.8``
``Last updated: v3.33.9``

---

## 3.33.9 (October, 31 2024)

### Notes

- Release date: **(October, 31 2024)**
- Supported Terraform version: **v1.x**

### Bug Fixes
- [PR #500](https://github.com/zscaler/terraform-provider-zpa/pull/500) - Implemented a fix to the update function across all specialized application segment resources:
- `zpa_application_segment_browser_access` - The fix now automatically includes the attributes `app_id` and `ba_app_id` in the payload during updates
- `zpa_application_segment_inspection` - The fix now automatically includes the attributes `app_id` and `inspect_app_id` in the payload during updates
- `zpa_application_segment_pra` - The fix now automatically includes the attributes `app_id` and `pra_app_id` in the payload during updates.
**NOTE:** This update/fix is required to ensure the ZPA API can properly identify the Browser Access, Inspection App and PRA App, based on its specific custom ID. The fix also includes the removal of the `ForceNew` option previously included in the schema to force the resource replacement in case of changes. Issue [PR #498](https://github.com/zscaler/terraform-provider-zpa/pull/498)

## 3.33.8 (October, 29 2024)

### Notes
Expand Down
3 changes: 0 additions & 3 deletions docs/resources/zpa_application_segment_pra.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ The following arguments are supported:
- `segment_group_id` - (String) The unique identifier of the Segment Group.
- `common_apps_dto` (Block Set, Min: 1) List of applications (e.g., Inspection, Browser Access or Privileged Remote Access)
- `apps_config:` (Block Set, Min: 1) List of applications to be configured
- `name` - (String) Name of the Privileged Remote Access
- `domain` - (String) Domain name of the Privileged Remote Access
- `application_protocol` - (String) Protocol for the Privileged Remote Access. Supported values: `RDP` and `SSH`
- `application_port` - (String) Port for the Privileged Remote Access
Expand All @@ -74,8 +73,6 @@ The following arguments are supported:
- `tcp_port_ranges` - (List of String) TCP port ranges used to access the app.
- `udp_port_ranges` - (List of String) UDP port ranges used to access the app.

!> **WARNING:** Removing PRA applications from the `common_apps_dto.apps_config` block will cause the provider to force a replacement of the application segment.

-> **NOTE:** TCP and UDP ports can also be defined using the following model:

- `tcp_port_range` - (Block Set) TCP port ranges used to access the app.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/hashicorp/terraform-plugin-docs v0.19.4
github.com/hashicorp/terraform-plugin-sdk v1.17.2
github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0
github.com/zscaler/zscaler-sdk-go/v2 v2.72.5
github.com/zscaler/zscaler-sdk-go/v2 v2.732.0
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,8 @@ github.com/zclconf/go-cty v1.14.4/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgr
github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b h1:FosyBZYxY34Wul7O/MSKey3txpPYyCqVO5ZyceuQJEI=
github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8=
github.com/zclconf/go-cty-yaml v1.0.2/go.mod h1:IP3Ylp0wQpYm50IHK8OZWKMu6sPJIUgKa8XhiVHura0=
github.com/zscaler/zscaler-sdk-go/v2 v2.72.5 h1:IL9eFbcvDEoS6x17ipy/kThgubdiknIeXtA37hn7SQY=
github.com/zscaler/zscaler-sdk-go/v2 v2.72.5/go.mod h1:ugDudbyESUrANGw74moJypgVnWuOyLm8NyIJgfUzNNo=
github.com/zscaler/zscaler-sdk-go/v2 v2.732.0 h1:oyESzPJJswG9dTSH0VcCeZH1ebYUmhIOKeTQg0sLu+w=
github.com/zscaler/zscaler-sdk-go/v2 v2.732.0/go.mod h1:ugDudbyESUrANGw74moJypgVnWuOyLm8NyIJgfUzNNo=
go.abhg.dev/goldmark/frontmatter v0.2.0 h1:P8kPG0YkL12+aYk2yU3xHv4tcXzeVnN+gU0tJ5JnxRw=
go.abhg.dev/goldmark/frontmatter v0.2.0/go.mod h1:XqrEkZuM57djk7zrlRUB02x8I5J0px76YjkOzhB4YlU=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
Expand Down
21 changes: 0 additions & 21 deletions zpa/data_source_zpa_application_segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,24 +224,3 @@ func dataSourceApplicationSegmentRead(d *schema.ResourceData, meta interface{})

return nil
}

/*
func flattenAppServerGroups(serverGroup *applicationsegment.ApplicationSegmentResource) []interface{} {
serverGroups := make([]interface{}, len(serverGroup.ServerGroups))
for i, val := range serverGroup.ServerGroups {
serverGroups[i] = map[string]interface{}{
"name": val.Name,
"id": val.ID,
"config_space": val.ConfigSpace,
"creation_time": val.CreationTime,
"description": val.Description,
"enabled": val.Enabled,
"dynamic_discovery": val.DynamicDiscovery,
"modifiedby": val.ModifiedBy,
"modified_time": val.ModifiedTime,
}
}
return serverGroups
}
*/
8 changes: 4 additions & 4 deletions zpa/data_source_zpa_application_segment_browser_access.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"log"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/browseraccess"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/applicationsegmentbrowseraccess"
)

func dataSourceApplicationSegmentBrowserAccess() *schema.Resource {
Expand Down Expand Up @@ -208,11 +208,11 @@ func dataSourceApplicationSegmentBrowserAccessRead(d *schema.ResourceData, meta
service = service.WithMicroTenant(microTenantID)
}

var resp *browseraccess.BrowserAccess
var resp *applicationsegmentbrowseraccess.BrowserAccess
id, ok := d.Get("id").(string)
if ok && id != "" {
log.Printf("[INFO] Getting data for browser access application %s\n", id)
res, _, err := browseraccess.Get(service, id)
res, _, err := applicationsegmentbrowseraccess.Get(service, id)
if err != nil {
return err
}
Expand All @@ -221,7 +221,7 @@ func dataSourceApplicationSegmentBrowserAccessRead(d *schema.ResourceData, meta
name, ok := d.Get("name").(string)
if id == "" && ok && name != "" {
log.Printf("[INFO] Getting data for browser access application name %s\n", name)
res, _, err := browseraccess.GetByName(service, name)
res, _, err := applicationsegmentbrowseraccess.GetByName(service, name)
if err != nil {
return err
}
Expand Down
32 changes: 21 additions & 11 deletions zpa/data_source_zpa_application_segment_inspection.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,16 +255,26 @@ func dataSourceApplicationSegmentInspectionRead(d *schema.ResourceData, meta int
return nil
}

/*
func flattenInspectionAppServerGroups(appServerGroup []applicationsegmentinspection.AppServerGroups) []interface{} {
result := make([]interface{}, 1)
mapIds := make(map[string]interface{})
ids := make([]string, len(appServerGroup))
for i, serverGroup := range appServerGroup {
ids[i] = serverGroup.ID
func flattenInspectionApps(apps []applicationsegmentinspection.InspectionAppDto) []interface{} {
if len(apps) == 0 {
return []interface{}{}
}
mapIds["id"] = ids
result[0] = mapIds
return result

appsConfig := make([]interface{}, len(apps))
for i, app := range apps {
appConfigMap := map[string]interface{}{
"id": app.ID,
"name": app.Name,
"enabled": app.Enabled,
"application_port": app.ApplicationPort,
"application_protocol": app.ApplicationProtocol,
"certificate_id": app.CertificateID,
"certificate_name": app.CertificateName,
"domain": app.Domain,
"app_id": app.AppID,
"trusted_untrusted_cert": app.TrustUntrustedCert,
}
appsConfig[i] = appConfigMap
}
return appsConfig
}
*/
6 changes: 3 additions & 3 deletions zpa/provider_sweeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import (
"github.com/zscaler/terraform-provider-zpa/v3/zpa/common/resourcetype"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/appconnectorgroup"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/applicationsegment"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/applicationsegmentbrowseraccess"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/applicationsegmentinspection"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/applicationsegmentpra"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/appservercontroller"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/bacertificate"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/browseraccess"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/cloudbrowserisolation/cbibannercontroller"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/cloudbrowserisolation/cbicertificatecontroller"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/cloudbrowserisolation/cbiprofilecontroller"
Expand Down Expand Up @@ -210,7 +210,7 @@ func sweepTestApplicationSegment(client *testClient) error {

func sweepTestApplicationSegmentBA(client *testClient) error {
var errorList []error
appSegmentBA, _, err := browseraccess.GetAll(client.sdkClient.BrowserAccess)
appSegmentBA, _, err := applicationsegmentbrowseraccess.GetAll(client.sdkClient.BrowserAccess)
if err != nil {
return err
}
Expand All @@ -219,7 +219,7 @@ func sweepTestApplicationSegmentBA(client *testClient) error {
for _, b := range appSegmentBA {
// Check if the resource name has the required prefix before deleting it
if strings.HasPrefix(b.Name, testResourcePrefix) || strings.HasPrefix(b.Name, updateResourcePrefix) {
if _, err := browseraccess.Delete(client.sdkClient.BrowserAccess, b.ID); err != nil {
if _, err := applicationsegmentbrowseraccess.Delete(client.sdkClient.BrowserAccess, b.ID); err != nil {
errorList = append(errorList, err)
continue
}
Expand Down
Loading

0 comments on commit 3d73333

Please sign in to comment.