diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a055fe..60d9c66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Changelog +## 0.3.2 (October 3, 2023) + +### Notes + +- Release date: **(October 3, 2023)** +- Supported Terraform version: **v1.x.x** + +### Bug Fixes + +- [PR #134](https://github.com/zscaler/zscaler-terraformer/pull/134) Implement condition to exclude ``applications`` block from the ZPA resources `zpa_segment_group` and `zpa_server_group`. + ## 0.3.1 (August 25, 2023) ### Notes diff --git a/README.md b/README.md index b0549b5..337b822 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ Usage: Available Commands: completion Generate the autocompletion script for the specified shell - generate Fetch resources from the Cloudflare API and generate the respective Terraform stanzas + generate Fetch resources from the ZPA and ZIA API and generate the respective Terraform stanzas help Help about any command import Output `terraform import` compatible commands in order to import resources into state version Print the version number of zscaler-terraformer diff --git a/go.mod b/go.mod index ff298ea..b412ad1 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/zscaler/zscaler-terraformer -go 1.19 +go 1.20 require ( github.com/dnaeon/go-vcr v1.2.0 @@ -15,7 +15,7 @@ require ( github.com/spf13/viper v1.16.0 github.com/stretchr/testify v1.8.4 github.com/zclconf/go-cty v1.14.0 - github.com/zscaler/zscaler-sdk-go/v2 v2.1.1 + github.com/zscaler/zscaler-sdk-go/v2 v2.1.2 ) require ( @@ -54,6 +54,6 @@ require ( golang.org/x/sys v0.12.0 // indirect golang.org/x/text v0.13.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v2 v2.2.8 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 829ed73..d6aa794 100644 --- a/go.sum +++ b/go.sum @@ -255,8 +255,8 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/zclconf/go-cty v1.14.0 h1:/Xrd39K7DXbHzlisFP9c4pHao4yyf+/Ug9LEz+Y/yhc= github.com/zclconf/go-cty v1.14.0/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= -github.com/zscaler/zscaler-sdk-go/v2 v2.1.1 h1:7PpU0fLUCJIx8R8ZIMnjwrWBrQPG6mtm2wdyRgmSlEE= -github.com/zscaler/zscaler-sdk-go/v2 v2.1.1/go.mod h1:PQscsdJVbmOXn7xqkRz3MdwYrt2UGHg37ZlON77iptg= +github.com/zscaler/zscaler-sdk-go/v2 v2.1.2 h1:b5/Z9qxYFZuI8cBhZ2Co+DdfwVLmuY0t0gJR4rONkbI= +github.com/zscaler/zscaler-sdk-go/v2 v2.1.2/go.mod h1:PQscsdJVbmOXn7xqkRz3MdwYrt2UGHg37ZlON77iptg= 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= @@ -591,9 +591,8 @@ gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/app/zscaler-terraformer/cmd/generate.go b/internal/app/zscaler-terraformer/cmd/generate.go index 82760fd..794f559 100644 --- a/internal/app/zscaler-terraformer/cmd/generate.go +++ b/internal/app/zscaler-terraformer/cmd/generate.go @@ -338,6 +338,7 @@ func generate(cmd *cobra.Command, writer io.Writer, resourceType string) { if i.Name == "Zscaler Deception" { continue } + i.Applications = nil // Suppress the applications block jsonPayload = append(jsonPayload, i) } resourceCount = len(jsonPayload) @@ -353,6 +354,7 @@ func generate(cmd *cobra.Command, writer io.Writer, resourceType string) { if i.Name == "Zscaler Deception" { continue } + i.Applications = nil // Suppress the applications block jsonPayload = append(jsonPayload, i) } resourceCount = len(jsonPayload) diff --git a/internal/app/zscaler-terraformer/cmd/generate_test.go b/internal/app/zscaler-terraformer/cmd/generate_test.go index f1ed012..30cab70 100644 --- a/internal/app/zscaler-terraformer/cmd/generate_test.go +++ b/internal/app/zscaler-terraformer/cmd/generate_test.go @@ -36,7 +36,7 @@ import ( "github.com/zscaler/zscaler-sdk-go/v2/zia/services/urlcategories" "github.com/zscaler/zscaler-sdk-go/v2/zia/services/urlfilteringpolicies" "github.com/zscaler/zscaler-sdk-go/v2/zia/services/user_authentication_settings" - "github.com/zscaler/zscaler-sdk-go/v2/zia/services/usermanagement" + "github.com/zscaler/zscaler-sdk-go/v2/zia/services/usermanagement/usermanagement" "github.com/zscaler/zscaler-sdk-go/v2/zpa" "github.com/zscaler/zscaler-sdk-go/v2/zpa/services/appconnectorcontroller" "github.com/zscaler/zscaler-sdk-go/v2/zpa/services/appconnectorgroup" @@ -269,7 +269,6 @@ func createClientMock(r http.RoundTripper, resourceType, zpaClientID, zpaClientS timewindow: timewindow.New(ziaClient), urlcategories: urlcategories.New(ziaClient), urlfilteringpolicies: urlfilteringpolicies.New(ziaClient), - usermanagement: usermanagement.New(ziaClient), virtualipaddresslist: virtualipaddresslist.New(ziaClient), vpncredentials: vpncredentials.New(ziaClient), gretunnels: gretunnels.New(ziaClient), @@ -286,6 +285,7 @@ func createClientMock(r http.RoundTripper, resourceType, zpaClientID, zpaClientS rule_labels: rule_labels.New(ziaClient), security_policy_settings: security_policy_settings.New(ziaClient), user_authentication_settings: user_authentication_settings.New(ziaClient), + usermanagement: usermanagement.New(ziaClient), }, } } diff --git a/internal/app/zscaler-terraformer/cmd/type.go b/internal/app/zscaler-terraformer/cmd/type.go index a1a387f..f020907 100644 --- a/internal/app/zscaler-terraformer/cmd/type.go +++ b/internal/app/zscaler-terraformer/cmd/type.go @@ -27,7 +27,7 @@ import ( "github.com/zscaler/zscaler-sdk-go/v2/zia/services/urlcategories" "github.com/zscaler/zscaler-sdk-go/v2/zia/services/urlfilteringpolicies" "github.com/zscaler/zscaler-sdk-go/v2/zia/services/user_authentication_settings" - "github.com/zscaler/zscaler-sdk-go/v2/zia/services/usermanagement" + "github.com/zscaler/zscaler-sdk-go/v2/zia/services/usermanagement/usermanagement" "github.com/zscaler/zscaler-sdk-go/v2/zpa" "github.com/zscaler/zscaler-sdk-go/v2/zpa/services/appconnectorcontroller" "github.com/zscaler/zscaler-sdk-go/v2/zpa/services/appconnectorgroup" diff --git a/internal/app/zscaler-terraformer/cmd/util.go b/internal/app/zscaler-terraformer/cmd/util.go index 9d99030..075c846 100644 --- a/internal/app/zscaler-terraformer/cmd/util.go +++ b/internal/app/zscaler-terraformer/cmd/util.go @@ -37,7 +37,7 @@ import ( "github.com/zscaler/zscaler-sdk-go/v2/zia/services/urlcategories" "github.com/zscaler/zscaler-sdk-go/v2/zia/services/urlfilteringpolicies" "github.com/zscaler/zscaler-sdk-go/v2/zia/services/user_authentication_settings" - "github.com/zscaler/zscaler-sdk-go/v2/zia/services/usermanagement" + "github.com/zscaler/zscaler-sdk-go/v2/zia/services/usermanagement/usermanagement" "github.com/zscaler/zscaler-sdk-go/v2/zpa/services/appconnectorcontroller" "github.com/zscaler/zscaler-sdk-go/v2/zpa/services/appconnectorgroup" "github.com/zscaler/zscaler-sdk-go/v2/zpa/services/applicationsegment" @@ -321,6 +321,11 @@ func nestBlocks(resourceType string, schemaBlock *tfjson.SchemaBlock, structData for _, block := range sortedNestedBlocks { apiBlock := mapTfFieldNameToApi(resourceType, block) + + // Skip 'applications' block for 'zpa_segment_group' resource + if (resourceType == "zpa_segment_group" || resourceType == "zpa_server_group") && block == "applications" { + continue // This skips the current iteration of the loop + } // special cases mapping if resourceType == "zia_admin_users" && block == "admin_scope" { output += "admin_scope {\n"