From 8e254d37621817ce1c71333ff4bd81b628d93751 Mon Sep 17 00:00:00 2001 From: William Guilherme Date: Wed, 15 Feb 2023 11:15:00 -0800 Subject: [PATCH] (fix) server group server list attribute (#244) * (fix) server group server list attribute * (fix) App Connector Group --- CHANGELOG.md | 3 +- GNUmakefile | 6 +- docs/guides/release-notes.md | 19 ++++- go.mod | 2 +- go.sum | 4 +- zpa/data_source_zpa_app_connector_group.go | 80 +++++++++++----------- zpa/resource_zpa_server_group.go | 10 +-- 7 files changed, 70 insertions(+), 54 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b58c400..471dc0ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ ### Bug Fix - [PR #244](https://github.com/zscaler/terraform-provider-zpa/pull/244) - Fixed ``zpa_server_groups`` resource ``servers`` attribute to support typeSet instead of typeList. +- [PR #244](https://github.com/zscaler/terraform-provider-zpa/pull/244) - Fixed ``zpa_app_connector_group`` resource ``connectors`` attribute to support typeSet instead of typeList. # 2.5.5 (January, 24 2023) @@ -624,4 +625,4 @@ Note: To import resources not currently supported, the resource numeric ID is re - New Data Source: ``data_source_zpa_scim_group`` 🆕 - New Data Source: ``data_source_zpa_segment_group`` 🆕 - New Data Source: ``data_source_zpa_server_group`` 🆕 -- New Data Source: ``data_source_zpa_trusted_network`` 🆕 +- New Data Source: ``data_source_zpa_trusted_network`` 🆕 \ No newline at end of file diff --git a/GNUmakefile b/GNUmakefile index 2d504e07..0f4f243e 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -16,15 +16,15 @@ build: fmtcheck 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)/2.5.6/$(GOOS)_$(GOARCH) +build13: DESTINATION=$(APPDATA)/terraform.d/plugins/$(ZPA_PROVIDER_NAMESPACE)/2.6.0/$(GOOS)_$(GOARCH) else -build13: DESTINATION=$(HOME)/.terraform.d/plugins/$(ZPA_PROVIDER_NAMESPACE)/2.5.6/$(GOOS)_$(GOARCH) +build13: DESTINATION=$(HOME)/.terraform.d/plugins/$(ZPA_PROVIDER_NAMESPACE)/2.6.0/$(GOOS)_$(GOARCH) endif build13: fmtcheck go mod tidy && go mod vendor @echo "==> Installing plugin to $(DESTINATION)" @mkdir -p $(DESTINATION) - go build -o $(DESTINATION)/terraform-provider-zpa_v2.5.6 + go build -o $(DESTINATION)/terraform-provider-zpa_v2.6.0 test: fmtcheck go test $(TEST) || exit 1 diff --git a/docs/guides/release-notes.md b/docs/guides/release-notes.md index 3b036a79..6f585e8b 100644 --- a/docs/guides/release-notes.md +++ b/docs/guides/release-notes.md @@ -12,11 +12,26 @@ Track all ZPA Terraform provider's releases. New resources, features, and bug fi --- -``Last updated: v2.5.5`` +``Last updated: v2.6.0`` --- -# 2.5.5 (January, 24 2023) +### Notes + +- Release date: **(February, 3 2023)** +- Supported Terraform version: **v1.x** + +### Enhacements + +- [PR #242](https://github.com/zscaler/terraform-provider-zpa/pull/242) - Added new data source and resources below: + - ``zpa_isolation_profile`` - This data source gets all isolation profiles for the specified customer. The Isolation Profile ID can then be referenced in a ``zpa_policy_isolation_rule`` when the ``action`` is set to ``ISOLATE`` + - ``zpa_policy_isolation_rule`` - This resource, creates an Isolation Rule. Notice that in order to create an isolation policy the ZPA tenant must be licensed accordingly. ``zpa_policy_isolation_rule`` when the ``action`` is set to ``ISOLATE`` + +### Bug Fix + +- [PR #244](https://github.com/zscaler/terraform-provider-zpa/pull/244) - Fixed ``zpa_server_groups`` resource ``servers`` attribute to support typeSet instead of typeList. + +# 2.5.6 (January, 24 2023) ### Notes diff --git a/go.mod b/go.mod index 7b50c43c..1e5c8266 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/hashicorp/terraform-plugin-docs v0.13.0 github.com/hashicorp/terraform-plugin-sdk v1.17.2 github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1 - github.com/zscaler/zscaler-sdk-go v1.0.5 + github.com/zscaler/zscaler-sdk-go v1.0.6 ) require ( diff --git a/go.sum b/go.sum index ca88ab2a..c9551e24 100644 --- a/go.sum +++ b/go.sum @@ -424,8 +424,8 @@ github.com/zclconf/go-cty v1.12.1 h1:PcupnljUm9EIvbgSHQnHhUr3fO6oFmkOrvs2BAFNXXY github.com/zclconf/go-cty v1.12.1/go.mod h1:s9IfD1LK5ccNMSWCVFCE2rJfHiZgi7JijgeWIMfhLvA= 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 v1.0.5 h1:t6wfd5CLcX7gmBACCwdoIYMt8q10+nn5PuQirZxb1TA= -github.com/zscaler/zscaler-sdk-go v1.0.5/go.mod h1:ta9P9guhFY1ivEhesMUjdJ3+40AHsJOR4dEUDXLQ6z8= +github.com/zscaler/zscaler-sdk-go v1.0.6 h1:qLGEsALwwLjKE/WQgUIcQmcut4gMmlUBHdIBJBJqfMA= +github.com/zscaler/zscaler-sdk-go v1.0.6/go.mod h1:ta9P9guhFY1ivEhesMUjdJ3+40AHsJOR4dEUDXLQ6z8= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= diff --git a/zpa/data_source_zpa_app_connector_group.go b/zpa/data_source_zpa_app_connector_group.go index 39732c2d..907ea93b 100644 --- a/zpa/data_source_zpa_app_connector_group.go +++ b/zpa/data_source_zpa_app_connector_group.go @@ -363,7 +363,7 @@ func dataSourceConnectorGroupRead(d *schema.ResourceData, m interface{}) error { _ = d.Set("upgrade_time_in_secs", resp.UpgradeTimeInSecs) _ = d.Set("version_profile_id", resp.VersionProfileID) _ = d.Set("version_profile_name", resp.VersionProfileName) - _ = d.Set("connectors", flattenConnectors(resp)) + _ = d.Set("connectors", flattenConnectors(resp.Connectors)) if err := d.Set("server_groups", flattenServerGroups(resp)); err != nil { return fmt.Errorf("failed to read server groups %s", err) @@ -375,46 +375,46 @@ func dataSourceConnectorGroupRead(d *schema.ResourceData, m interface{}) error { return nil } -func flattenConnectors(appConnector *appconnectorgroup.AppConnectorGroup) []interface{} { - appConnectors := make([]interface{}, len(appConnector.Connectors)) - for i, appConnector := range appConnector.Connectors { +func flattenConnectors(appConnector []appconnectorgroup.Connector) []interface{} { + appConnectors := make([]interface{}, len(appConnector)) + for i, appConnectorItem := range appConnector { appConnectors[i] = map[string]interface{}{ - "application_start_time": appConnector.ApplicationStartTime, - "appconnector_group_id": appConnector.AppConnectorGroupID, - "appconnector_group_name": appConnector.AppConnectorGroupName, - "control_channel_status": appConnector.ControlChannelStatus, - "creation_time": appConnector.CreationTime, - "ctrl_broker_name": appConnector.CtrlBrokerName, - "current_version": appConnector.CurrentVersion, - "description": appConnector.Description, - "enabled": appConnector.Enabled, - "expected_upgrade_time": appConnector.ExpectedUpgradeTime, - "expected_version": appConnector.ExpectedVersion, - "fingerprint": appConnector.Fingerprint, - "id": appConnector.ID, - "ipacl": appConnector.IPACL, - "issued_cert_id": appConnector.IssuedCertID, - "last_broker_connect_time": appConnector.LastBrokerConnectTime, - "last_broker_connect_time_duration": appConnector.LastBrokerConnectTimeDuration, - "last_broker_disconnect_time": appConnector.LastBrokerDisconnectTime, - "last_broker_disconnect_time_duration": appConnector.LastBrokerDisconnectTimeDuration, - "last_upgrade_time": appConnector.LastUpgradeTime, - "latitude": appConnector.Latitude, - "location": appConnector.Location, - "longitude": appConnector.Longitude, - "modifiedby": appConnector.ModifiedBy, - "modified_time": appConnector.ModifiedTime, - "name": appConnector.Name, - "provisioning_key_id": appConnector.ProvisioningKeyID, - "provisioning_key_name": appConnector.ProvisioningKeyName, - "platform": appConnector.Platform, - "previous_version": appConnector.PreviousVersion, - "private_ip": appConnector.PrivateIP, - "public_ip": appConnector.PublicIP, - "sarge_version": appConnector.SargeVersion, - "enrollment_cert": appConnector.EnrollmentCert, - "upgrade_attempt": appConnector.UpgradeAttempt, - "upgrade_status": appConnector.UpgradeStatus, + "application_start_time": appConnectorItem.ApplicationStartTime, + "appconnector_group_id": appConnectorItem.AppConnectorGroupID, + "appconnector_group_name": appConnectorItem.AppConnectorGroupName, + "control_channel_status": appConnectorItem.ControlChannelStatus, + "creation_time": appConnectorItem.CreationTime, + "ctrl_broker_name": appConnectorItem.CtrlBrokerName, + "current_version": appConnectorItem.CurrentVersion, + "description": appConnectorItem.Description, + "enabled": appConnectorItem.Enabled, + "expected_upgrade_time": appConnectorItem.ExpectedUpgradeTime, + "expected_version": appConnectorItem.ExpectedVersion, + "fingerprint": appConnectorItem.Fingerprint, + "id": appConnectorItem.ID, + "ipacl": appConnectorItem.IPACL, + "issued_cert_id": appConnectorItem.IssuedCertID, + "last_broker_connect_time": appConnectorItem.LastBrokerConnectTime, + "last_broker_connect_time_duration": appConnectorItem.LastBrokerConnectTimeDuration, + "last_broker_disconnect_time": appConnectorItem.LastBrokerDisconnectTime, + "last_broker_disconnect_time_duration": appConnectorItem.LastBrokerDisconnectTimeDuration, + "last_upgrade_time": appConnectorItem.LastUpgradeTime, + "latitude": appConnectorItem.Latitude, + "location": appConnectorItem.Location, + "longitude": appConnectorItem.Longitude, + "modifiedby": appConnectorItem.ModifiedBy, + "modified_time": appConnectorItem.ModifiedTime, + "name": appConnectorItem.Name, + "provisioning_key_id": appConnectorItem.ProvisioningKeyID, + "provisioning_key_name": appConnectorItem.ProvisioningKeyName, + "platform": appConnectorItem.Platform, + "previous_version": appConnectorItem.PreviousVersion, + "private_ip": appConnectorItem.PrivateIP, + "public_ip": appConnectorItem.PublicIP, + "sarge_version": appConnectorItem.SargeVersion, + "enrollment_cert": appConnectorItem.EnrollmentCert, + "upgrade_attempt": appConnectorItem.UpgradeAttempt, + "upgrade_status": appConnectorItem.UpgradeStatus, } } diff --git a/zpa/resource_zpa_server_group.go b/zpa/resource_zpa_server_group.go index 1df6bb4f..0afaf1fa 100644 --- a/zpa/resource_zpa_server_group.go +++ b/zpa/resource_zpa_server_group.go @@ -85,7 +85,7 @@ func resourceServerGroup() *schema.Resource { Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "id": { - Type: schema.TypeList, + Type: schema.TypeSet, Optional: true, Elem: &schema.Schema{ Type: schema.TypeString, @@ -315,12 +315,12 @@ func expandApplicationServers(d *schema.ResourceData) []servergroup.ApplicationS applicationServersInterface, ok := d.GetOk("servers") if ok { applicationServer := applicationServersInterface.(*schema.Set) - log.Printf("[INFO] server group application data: %+v\n", applicationServer) + log.Printf("[INFO] servers data: %+v\n", applicationServer) var applicationServers []servergroup.ApplicationServer for _, applicationServer := range applicationServer.List() { - applicationServer, _ := applicationServer.(map[string]interface{}) - if applicationServer != nil { - for _, id := range applicationServer["id"].([]interface{}) { + applicationServer, ok := applicationServer.(map[string]interface{}) + if ok { + for _, id := range applicationServer["id"].(*schema.Set).List() { applicationServers = append(applicationServers, servergroup.ApplicationServer{ ID: id.(string), })