Skip to content

Commit

Permalink
fix: Fixed application segment match_style validation
Browse files Browse the repository at this point in the history
  • Loading branch information
willguibr committed Aug 15, 2024
1 parent a74ddce commit 5d3d3b3
Show file tree
Hide file tree
Showing 12 changed files with 186 additions and 62 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.32.2 (August, 16 2024)

### Notes

- Release date: **(August, 16 2024)**
- Supported Terraform version: **v1.x**

### Bug Fixes
- [PR #476](https://github.com/zscaler/terraform-provider-zpa/pull/476) - Fixed validation for the `match_style` attribute in the resource `zpa_application_segment`.
**NOTE**: Notice that `match_style` also known as [Multimatch](https://help.zscaler.com/zpa/using-app-segment-multimatch) cannot be configured when `ip_anchored` is enabled. Also, `match_style` is NOT supported for the following application segment resources: `zpa_application_segment_browser_access`, `zpa_application_segment_inspection` or `zpa_application_segment_pra`.

### Documentation
- [PR #476](https://github.com/zscaler/terraform-provider-zpa/pull/476) - Added documentation for resource and datasource: `zpa_service_edge_assistant_schedule`

## 3.32.1 (July, 31 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.321.0/$(GOOS)_$(GOARCH)
build13: DESTINATION=$(APPDATA)/terraform.d/plugins/$(ZPA_PROVIDER_NAMESPACE)/3.32.2/$(GOOS)_$(GOARCH)
else
build13: DESTINATION=$(HOME)/.terraform.d/plugins/$(ZPA_PROVIDER_NAMESPACE)/3.321.0/$(GOOS)_$(GOARCH)
build13: DESTINATION=$(HOME)/.terraform.d/plugins/$(ZPA_PROVIDER_NAMESPACE)/3.32.2/$(GOOS)_$(GOARCH)
endif
build13: fmtcheck
@echo "==> Installing plugin to $(DESTINATION)"
@mkdir -p $(DESTINATION)
go build -o $(DESTINATION)/terraform-provider-zpa_v3.321.0
go build -o $(DESTINATION)/terraform-provider-zpa_v3.32.2

vet:
@echo "==> Checking source code against go vet and staticcheck"
Expand Down
52 changes: 52 additions & 0 deletions docs/data-sources/zpa_service_edge_assistant_schedule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
page_title: "zpa_service_edge_assistant_schedule Data Source - terraform-provider-zpa"
subcategory: "Service Edge Controller"
description: |-
Official documentation https://help.zscaler.com/zpa/deleting-disconnected-app-connectors
documentation https://help.zscaler.com/zpa/configuring-auto-delete-disconnected-app-connectors-using-api
Get information about ZPA Service Edge Controller Assistant Schedule in Zscaler Private Access cloud.
---

# zpa_service_edge_assistant_schedule (Data Source)

* [Official documentation](https://help.zscaler.com/zpa/deleting-disconnected-app-connectors)
* [API documentation](https://help.zscaler.com/zpa/configuring-auto-delete-disconnected-app-connectors-using-api)

Use the **zpa_service_edge_assistant_schedule** data source to get information about Auto Delete frequency of the Service Edge for the specified customer in the Zscaler Private Access cloud.

~> **NOTE** - The `customer_id` attribute is optional and not required during the configuration.

## Example Usage

```terraform
// Retrieve All Assistant Schedules
data "zpa_service_edge_assistant_schedule" "this" {}
// Retrieve A Specific Assistant Schedule by ID
data "zpa_service_edge_assistant_schedule" "this" {
id = "1"
}
// Retrieve A Specific Assistant Schedule by the Customer ID
data "zpa_service_edge_assistant_schedule" "this" {
customer_id = "1234567891012"
}
```

## Schema

### Required

The following arguments are supported:

* `id` - (Number) The unique identifier for the Service Edge auto deletion configuration for a customer. This field is only required for the PUT request to update the frequency of the Service Edge Settings.
* `customer_id` - (Number) The unique identifier of the ZPA tenant.

### Read-Only

In addition to all arguments above, the following attributes are exported:

* `enabled` (Boolean) - Indicates if the setting for deleting Service Edge is enabled or disabled.
* `delete_disabled` (Boolean) - Indicates if the Service Edge are included for deletion if they are in a disconnected state based on frequencyInterval and frequency values.
* `frequency` (String) - The scheduled frequency at which the disconnected Service Edge are deleted. Supported value is: `days`
* `frequency_interval` - (String) - The interval for the configured frequency value. The minimum supported value is 5. Supported values are: `5`, `7`, `14`, `30`, `60` and `90`
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.32.1``
``Last updated: v3.32.2``

---

## 3.32.2 (August, 16 2024)

### Notes

- Release date: **(August, 16 2024)**
- Supported Terraform version: **v1.x**

### Bug Fixes
- [PR #476](https://github.com/zscaler/terraform-provider-zpa/pull/476) - Fixed validation for the `match_style` attribute in the resource `zpa_application_segment`.
**NOTE**: Notice that `match_style` also known as [Multimatch](https://help.zscaler.com/zpa/using-app-segment-multimatch) cannot be configured when `ip_anchored` is enabled. Also, `match_style` is NOT supported for the following application segment resources: `zpa_application_segment_browser_access`, `zpa_application_segment_inspection` or `zpa_application_segment_pra`.

### Documentation
- [PR #476](https://github.com/zscaler/terraform-provider-zpa/pull/476) - Added documentation for resource and datasource: `zpa_service_edge_assistant_schedule`

## 3.32.1 (July, 31 2024)

### Notes
Expand Down
33 changes: 17 additions & 16 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,26 +177,27 @@ The following arguments are supported:
* ``zpa_client_id`` - (Required) ZPA client ID, is equivalent to a username.
* ``zpa_client_secret`` - (Required) ZPA client secret, is equivalent to a secret password.
* ``zpa_customer_id`` - (Required) ZPA customer ID, is equivalent to your ZPA tenant identification.
* ``zpa_cloud`` - (Required) ZPA Cloud name `BETA`, `GOV`, `GOVUS` or `PREVIEW`.
* ``zpa_cloud`` - (Required) ZPA Cloud name `BETA`, `GOV`, `GOVUS`, `PREVIEW` or `ZPATWO` clouds.

### Optional

* `zpa_cloud` - (Optional) ZPA Cloud name `PRODUCTION`. Optional when running in the ZPA production cloud.

### Zscaler Private Access Microtenant

## Support

This template/solution is released under an as-is, best effort, support
policy. These scripts should be seen as community supported and Zscaler
Technology Alliances Team will contribute our expertise as and when possible.
We do not provide technical support or help in using or troubleshooting the components
of the project through our normal support options such as Zscaler support teams,
or ASC (Authorized Support Centers) partners and backline
support options. The underlying product used (Zscaler Private Access API) but the
scripts or templates are still supported, but the support is only for the
product functionality and not for help in deploying or using the template or
script itself. Unless explicitly tagged, all projects or work posted in our
[GitHub repository](https://github.com/zscaler) or sites other
than our official [Downloads page](https://help.zscaler.com/login-tickets)
are provided under the best effort policy.
A Microtenant is a delegated administrator responsibility that is assigned to an admin by an admin with Microtenant administrator privileges. Microtenants are defined by an authentication domain and assigned to admins based on country, department, and company for role-based administration control. A Microtenant is created within a tenant and is used when departments or subsidiaries within an organization want to manage their configurations independently.[Read More](https://help.zscaler.com/zpa/about-microtenants)

To manage a microtenant using the ZPA Terraform provider, the administrator for the parent or default tenant, must first provision the microtenant using the resource `zpa_microtenant_controller`. The resource will output the administrator credentials for the new microtenant, which can then be provided to the microtenant administrator.

The microtenant administrator can then create his own microtenant API credentials required to authenticate via API to the ZPA platform. From that point, the administrator can then individually manage his own resources in an isolated manner.
When authenticating to microtenant via API using the ZPA Terraform provider, the administrator must provide the following environment variable credentials: `ZPA_CLIENT_ID`, `ZPA_CLIENT_SECRET`, `ZPA_CUSTOMER_ID`, `ZPA_CLOUD`, `ZPA_MICROTENANT_ID`

~> **NOTE 1** Only environment variables are currently supported when authenticating to a Microtenant.

~> **NOTE 2** The environment variable `ZPA_MICROTENANT_ID` is mandatory when provisioning/managing resources exclusively within a Microtenant.

~> **NOTE 3** `ZPA_CLOUD` environment variable is an optional parameter when running this provider in production; however, this parameter is required to provision resources in the `BETA`, `GOV`, `GOVUS`, `PREVIEW` or `ZPATWO` clouds.

## Support Disclaimer

-> **Disclaimer:** Please refer to our [General Support Statement](guides/support.md) before proceeding with the use of this provider. You can also refer to our [troubleshooting guide](guides/troubleshooting.md) for guidance on typical problems.
61 changes: 61 additions & 0 deletions docs/resources/zpa_service_edge_assistant_schedule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
page_title: "zpa_service_edge_assistant_schedule Resource - terraform-provider-zpa"
subcategory: "Service Edge Controller"
description: |-
Official documentation https://help.zscaler.com/zpa/configuring-app-connectors-settings
documentation https://help.zscaler.com/zpa/configuring-auto-delete-disconnected-app-connectors-using-api
Configures Auto Delete for the specified disconnected Service Edge.
---

# zpa_service_edge_assistant_schedule (Resource)

* [Official documentation](https://help.zscaler.com/zpa/configuring-app-connectors-settings)
* [API documentation](https://help.zscaler.com/zpa/configuring-auto-delete-disconnected-app-connectors-using-api)

Use the **zpa_service_edge_assistant_schedule** resource sets the scheduled frequency at which the disconnected Service Edges are eligible for deletion. The supported value for frequency is days. The frequencyInterval field is the number of days after an Service Edge disconnects for it to become eligible for deletion. The minimum supported value for frequencyInterval is 5.

~> **NOTE** - When enabling the Assistant Schedule for the first time, you must provide the `customer_id` information. If you authenticated using environment variables and used `ZPA_CUSTOMER_ID` environment variable, you don't have to define the customer_id attribute in the HCL configuration, and the provider will automatically use the value from the environment variable `ZPA_CUSTOMER_ID`

## Example Usage - Defined Customer ID Value

```terraform
resource "zpa_service_edge_assistant_schedule" "this" {
customer_id = "123456789101112"
frequency = "days"
frequency_interval = "5"
enabled = true
delete_disabled = true
}
```

## Example Usage - Customer ID Via Environment Variable

```terraform
resource "zpa_service_edge_assistant_schedule" "this" {
frequency = "days"
frequency_interval = "5"
enabled = true
delete_disabled = true
}
```

## Schema

### Required

The following arguments are supported:

- `customer_id` - (String) - When enabling the Assistant Schedule for the first time, you must provide the `customer_id` information. If you authenticated using environment variables and used `ZPA_CUSTOMER_ID` environment variable, you don't have to define the customer_id attribute in the HCL configuration, and the provider will automatically use the value from the environment variable `ZPA_CUSTOMER_ID`
- `frequency_interval` - (String) - The interval for the configured frequency value. The minimum supported value is 5. Supported values are: `5`, `7`, `14`, `30`, `60` and `90`
- `frequency` (String) - The scheduled frequency at which the disconnected Service Edges are deleted. Supported value is: `days`

### Optional

In addition to all arguments above, the following attributes are exported:

- `enabled` (Boolean) - Indicates if the setting for deleting Service Edges is enabled or disabled. Supported values are: `true` or `false`
- `delete_disabled` (Boolean) - Indicates if the Service Edges are included for deletion if they are in a disconnected state based on frequencyInterval and frequency values. Supported values are: `true` or `false`

## Import

Import is not currently supported for this resource.
6 changes: 3 additions & 3 deletions 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.70.0
github.com/zscaler/zscaler-sdk-go/v2 v2.72.0
)

require (
Expand Down Expand Up @@ -79,9 +79,9 @@ require (
golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/text v0.17.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
Expand Down
12 changes: 6 additions & 6 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.70.0 h1:pabyVnCNIs+EOSqDK6ROR+8H9HHhrmFfzZPUTdbZ3GY=
github.com/zscaler/zscaler-sdk-go/v2 v2.70.0/go.mod h1:GDYmG+wN13d/chGX6r6T95Gqbqq3UejMxfDud6FORJc=
github.com/zscaler/zscaler-sdk-go/v2 v2.72.0 h1:VJNdLcZjd806cgVLrjvBVOhiNUTO6LC0HTwA/GiIDZw=
github.com/zscaler/zscaler-sdk-go/v2 v2.72.0/go.mod h1:dgtdfvnrFyuv1X3Knv5cjW1DNnQ3z/a4lU3uoYnxwcE=
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 Expand Up @@ -551,8 +551,8 @@ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down Expand Up @@ -613,8 +613,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand Down
15 changes: 15 additions & 0 deletions zpa/resource_zpa_application_segment.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package zpa

import (
"context"
"fmt"
"log"
"strconv"
Expand All @@ -23,6 +24,20 @@ func resourceApplicationSegment() *schema.Resource {
Read: resourceApplicationSegmentRead,
Update: resourceApplicationSegmentUpdate,
Delete: resourceApplicationSegmentDelete,
CustomizeDiff: func(ctx context.Context, d *schema.ResourceDiff, meta interface{}) error {
// Get the value of the ip_anchored attribute
ipAnchored := d.Get("ip_anchored").(bool)

// Check if match_style is set
if matchStyle, ok := d.GetOk("match_style"); ok {
// If ip_anchored is true and match_style is set, return an error
if ipAnchored && matchStyle != "" {
return fmt.Errorf("match_style cannot be set when ip_anchored is true")
}
}

return nil
},
Importer: &schema.ResourceImporter{
State: func(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
client := meta.(*Client)
Expand Down
11 changes: 0 additions & 11 deletions zpa/resource_zpa_application_segment_browser_access.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,6 @@ func resourceApplicationSegmentBrowserAccess() *schema.Resource {
"CONTINUOUS",
}, false),
},
"match_style": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{
"EXCLUSIVE",
"INCLUSIVE",
}, false),
},
"icmp_access_type": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -357,7 +348,6 @@ func resourceApplicationSegmentBrowserAccessRead(d *schema.ResourceData, meta in
_ = d.Set("health_check_type", resp.HealthCheckType)
_ = d.Set("is_cname_enabled", resp.IsCnameEnabled)
_ = d.Set("ip_anchored", resp.IPAnchored)
_ = d.Set("match_style", resp.MatchStyle)
_ = d.Set("microtenant_id", resp.MicroTenantID)
_ = d.Set("select_connector_close_to_app", resp.SelectConnectorCloseToApp)
_ = d.Set("use_in_dr_mode", resp.UseInDrMode)
Expand Down Expand Up @@ -462,7 +452,6 @@ func expandBrowserAccess(d *schema.ResourceData, zClient *Client, id string) bro
ConfigSpace: d.Get("config_space").(string),
ICMPAccessType: d.Get("icmp_access_type").(string),
Description: d.Get("description").(string),
MatchStyle: d.Get("match_style").(string),
MicroTenantID: d.Get("microtenant_id").(string),
DomainNames: SetToStringList(d, "domain_names"),
HealthCheckType: d.Get("health_check_type").(string),
Expand Down
11 changes: 0 additions & 11 deletions zpa/resource_zpa_application_segment_inspection.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,6 @@ func resourceApplicationSegmentInspection() *schema.Resource {
"CONTINUOUS",
}, false),
},
"match_style": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{
"EXCLUSIVE",
"INCLUSIVE",
}, false),
},
"passive_health_enabled": {
Type: schema.TypeBool,
Optional: true,
Expand Down Expand Up @@ -330,7 +321,6 @@ func resourceApplicationSegmentInspectionRead(d *schema.ResourceData, meta inter
_ = d.Set("enabled", resp.Enabled)
_ = d.Set("passive_health_enabled", resp.PassiveHealthEnabled)
_ = d.Set("double_encrypt", resp.DoubleEncrypt)
_ = d.Set("match_style", resp.MatchStyle)
_ = d.Set("health_check_type", resp.HealthCheckType)
_ = d.Set("is_cname_enabled", resp.IsCnameEnabled)
_ = d.Set("icmp_access_type", resp.ICMPAccessType)
Expand Down Expand Up @@ -437,7 +427,6 @@ func expandInspectionApplicationSegment(d *schema.ResourceData, zClient *Client,
Description: d.Get("description").(string),
HealthReporting: d.Get("health_reporting").(string),
HealthCheckType: d.Get("health_check_type").(string),
MatchStyle: d.Get("match_style").(string),
PassiveHealthEnabled: d.Get("passive_health_enabled").(bool),
DoubleEncrypt: d.Get("double_encrypt").(bool),
Enabled: d.Get("enabled").(bool),
Expand Down
Loading

0 comments on commit 5d3d3b3

Please sign in to comment.