Skip to content

Commit

Permalink
(fix) server group server list attribute (#244)
Browse files Browse the repository at this point in the history
* (fix) server group server list attribute
* (fix) App Connector Group
  • Loading branch information
willguibr authored Feb 15, 2023
1 parent 681edae commit 8e254d3
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 54 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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`` 🆕
6 changes: 3 additions & 3 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 17 additions & 2 deletions docs/guides/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
80 changes: 40 additions & 40 deletions zpa/data_source_zpa_app_connector_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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,
}
}

Expand Down
10 changes: 5 additions & 5 deletions zpa/resource_zpa_server_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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),
})
Expand Down

0 comments on commit 8e254d3

Please sign in to comment.