Skip to content

Commit

Permalink
Merge pull request #167 from zscaler/zt-#167-new-resources
Browse files Browse the repository at this point in the history
feat: Added Import capability to new supported resources
  • Loading branch information
willguibr authored Jan 31, 2024
2 parents a360577 + bb05209 commit 9e4a418
Show file tree
Hide file tree
Showing 9 changed files with 304 additions and 22 deletions.
1 change: 0 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Release
on:
push:
branches: [ master ]
tags:
- 'v*'
jobs:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:
- 'LICENSE'

schedule:
- cron: '0 13 * * 1-5' # UTC
- cron: '0 14 * * 1-5' # UTC
workflow_dispatch:

jobs:
Expand All @@ -37,6 +37,7 @@ jobs:
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}

- name: Download Go Dependencies
run: go mod tidy && go mod vendor
- name: Vet
Expand Down
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# Changelog

## 1.0.0 (January, 30 2024)

### Notes

- Release date: **(January, 30 2024)**
- Supported Terraform version: **v1.x.x**

### Enhacements

- [PR #167](https://github.com/zscaler/zscaler-terraformer/pull/167) ✨ Added support for ZIA Custom ZPA Gateway import.
- [PR #167](https://github.com/zscaler/zscaler-terraformer/pull/167) ✨ Added support for ZIA Forwarding Control Rule import.
- [PR #167](https://github.com/zscaler/zscaler-terraformer/pull/167) ✨ Added support for ZIA DLP Engine import.
- [PR #167](https://github.com/zscaler/zscaler-terraformer/pull/167) ✨ Added support for ZPA Microtenant import.
- [PR #167](https://github.com/zscaler/zscaler-terraformer/pull/167) ✨ Added support for ZPA Browser Access import.
- [PR #167](https://github.com/zscaler/zscaler-terraformer/pull/167) ✨ Added support for ZPA Cloud Browser Isolation Banner import.
- [PR #167](https://github.com/zscaler/zscaler-terraformer/pull/167) ✨ Added support for ZPA Cloud Browser Isolation Certificate import.
- [PR #167](https://github.com/zscaler/zscaler-terraformer/pull/167) ✨ Added support for ZPA Cloud Browser Isolation External Profile import.

### Bug Fixes

- [PR #167](https://github.com/zscaler/zscaler-terraformer/pull/167) Fixed license error for ZPA unlicensed .

## 0.3.4 (December, 11 2023)

### Notes
Expand Down
24 changes: 23 additions & 1 deletion docs/guides/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,32 @@ Track all Zscaler Terraformer Tool releases. New resources, features, and bug fi

---

``Last updated: v0.3.4``
``Last updated: v1.0.0``

---

## 1.0.0 (January, 30 2024)

### Notes

- Release date: **(January, 30 2024)**
- Supported Terraform version: **v1.x.x**

### Enhacements

- [PR #167](https://github.com/zscaler/zscaler-terraformer/pull/167) ✨ Added support for ZIA Custom ZPA Gateway import.
- [PR #167](https://github.com/zscaler/zscaler-terraformer/pull/167) ✨ Added support for ZIA Forwarding Control Rule import.
- [PR #167](https://github.com/zscaler/zscaler-terraformer/pull/167) ✨ Added support for ZIA DLP Engine import.
- [PR #167](https://github.com/zscaler/zscaler-terraformer/pull/167) ✨ Added support for ZPA Microtenant import.
- [PR #167](https://github.com/zscaler/zscaler-terraformer/pull/167) ✨ Added support for ZPA Browser Access import.
- [PR #167](https://github.com/zscaler/zscaler-terraformer/pull/167) ✨ Added support for ZPA Cloud Browser Isolation Banner import.
- [PR #167](https://github.com/zscaler/zscaler-terraformer/pull/167) ✨ Added support for ZPA Cloud Browser Isolation Certificate import.
- [PR #167](https://github.com/zscaler/zscaler-terraformer/pull/167) ✨ Added support for ZPA Cloud Browser Isolation External Profile import.

### Bug Fixes

- [PR #167](https://github.com/zscaler/zscaler-terraformer/pull/167) Fixed license error for ZPA unlicensed .

## 0.3.4 (December, 11 2023)

### Notes
Expand Down
79 changes: 79 additions & 0 deletions internal/app/zscaler-terraformer/cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/zclconf/go-cty/cty"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/dlp/dlp_engines"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/dlp/dlpdictionaries"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/firewallpolicies/filteringrules"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/firewallpolicies/networkapplicationgroups"
Expand All @@ -45,6 +46,10 @@ var allGeneratableResources = []string{
"zpa_application_segment_pra",
"zpa_application_segment_inspection",
"zpa_application_segment_browser_access",
"zpa_ba_certificate",
"zpa_cloud_browser_isolation_banner",
"zpa_cloud_browser_isolation_certificate",
"zpa_cloud_browser_isolation_external_profile",
"zpa_segment_group",
"zpa_server_group",
"zpa_policy_access_rule",
Expand All @@ -56,8 +61,10 @@ var allGeneratableResources = []string{
"zpa_lss_config_controller",
"zpa_inspection_custom_controls",
"zpa_inspection_profile",
"zpa_microtenant_controller",
"zia_admin_users",
"zia_dlp_dictionaries",
"zia_dlp_engines",
"zia_dlp_notification_templates",
"zia_dlp_web_rules",
"zia_firewall_filtering_rule",
Expand Down Expand Up @@ -332,6 +339,38 @@ func generate(cmd *cobra.Command, writer io.Writer, resourceType string) {
resourceCount = len(jsonPayload)
m, _ := json.Marshal(jsonPayload)
_ = json.Unmarshal(m, &jsonStructData)
case "zpa_ba_certificate":
jsonPayload, _, err := api.zpa.bacertificate.GetAll()
if err != nil {
log.Fatal(err)
}
resourceCount = len(jsonPayload)
m, _ := json.Marshal(jsonPayload)
_ = json.Unmarshal(m, &jsonStructData)
case "zpa_cloud_browser_isolation_banner":
jsonPayload, _, err := api.zpa.cbibannercontroller.GetAll()
if err != nil {
log.Fatal(err)
}
resourceCount = len(jsonPayload)
m, _ := json.Marshal(jsonPayload)
_ = json.Unmarshal(m, &jsonStructData)
case "zpa_cloud_browser_isolation_certificate":
jsonPayload, _, err := api.zpa.cbicertificatecontroller.GetAll()
if err != nil {
log.Fatal(err)
}
resourceCount = len(jsonPayload)
m, _ := json.Marshal(jsonPayload)
_ = json.Unmarshal(m, &jsonStructData)
case "zpa_cloud_browser_isolation_external_profile":
jsonPayload, _, err := api.zpa.cbiprofilecontroller.GetAll()
if err != nil {
log.Fatal(err)
}
resourceCount = len(jsonPayload)
m, _ := json.Marshal(jsonPayload)
_ = json.Unmarshal(m, &jsonStructData)
case "zpa_segment_group":
list, _, err := api.zpa.segmentgroup.GetAll()
if err != nil {
Expand Down Expand Up @@ -472,6 +511,15 @@ func generate(cmd *cobra.Command, writer io.Writer, resourceType string) {
resourceCount = len(jsonPayload)
m, _ := json.Marshal(jsonPayload)
_ = json.Unmarshal(m, &jsonStructData)
case "zpa_microtenant_controller":
jsonPayload, _, err := api.zpa.microtenants.GetAll()
if err != nil {
log.Fatal(err)
}
resourceCount = len(jsonPayload)
m, _ := json.Marshal(jsonPayload)
_ = json.Unmarshal(m, &jsonStructData)

case "zia_admin_users":
jsonPayload, err := api.zia.admins.GetAllAdminUsers()
if err != nil {
Expand All @@ -495,6 +543,21 @@ func generate(cmd *cobra.Command, writer io.Writer, resourceType string) {
resourceCount = len(jsonPayload)
m, _ := json.Marshal(jsonPayload)
_ = json.Unmarshal(m, &jsonStructData)
case "zia_dlp_engines":
list, err := api.zia.dlp_engines.GetAll()
if err != nil {
log.Fatal(err)
}
jsonPayload := []dlp_engines.DLPEngines{}
for _, i := range list {
if !i.CustomDlpEngine {
continue
}
jsonPayload = append(jsonPayload, i)
}
resourceCount = len(jsonPayload)
m, _ := json.Marshal(jsonPayload)
_ = json.Unmarshal(m, &jsonStructData)
case "zia_dlp_notification_templates":
jsonPayload, err := api.zia.dlp_notification_templates.GetAll()
if err != nil {
Expand Down Expand Up @@ -695,6 +758,22 @@ func generate(cmd *cobra.Command, writer io.Writer, resourceType string) {
resourceCount = len(jsonPayload)
m, _ := json.Marshal(jsonPayload)
_ = json.Unmarshal(m, &jsonStructData)
case "zia_forwarding_control_rule":
jsonPayload, err := api.zia.forwarding_rules.GetAll()
if err != nil {
log.Fatal(err)
}
resourceCount = len(jsonPayload)
m, _ := json.Marshal(jsonPayload)
_ = json.Unmarshal(m, &jsonStructData)
case "zia_forwarding_control_zpa_gateway":
jsonPayload, err := api.zia.zpa_gateways.GetAll()
if err != nil {
log.Fatal(err)
}
resourceCount = len(jsonPayload)
m, _ := json.Marshal(jsonPayload)
_ = json.Unmarshal(m, &jsonStructData)
default:
fmt.Fprintf(cmd.OutOrStdout(), "%q is not yet supported for automatic generation", resourceType)
return
Expand Down
54 changes: 37 additions & 17 deletions internal/app/zscaler-terraformer/cmd/generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/firewallpolicies/networkservicegroups"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/firewallpolicies/networkservices"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/firewallpolicies/timewindow"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/forwarding_control_policy/forwarding_rules"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/forwarding_control_policy/zpa_gateways"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/location/locationgroups"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/location/locationmanagement"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/rule_labels"
Expand All @@ -47,6 +49,9 @@ import (
"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"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/cloudconnectorgroup"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/customerversionprofile"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/enrollmentcert"
Expand All @@ -56,6 +61,7 @@ import (
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/inspectioncontrol/inspection_profile"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/lssconfigcontroller"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/machinegroup"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/microtenants"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/policysetcontroller"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/postureprofile"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/provisioningkey"
Expand Down Expand Up @@ -134,27 +140,33 @@ func TestResourceGeneration(t *testing.T) {
testdataFilename string
}{
// ZPA Resource
"zpa app connector group": {identiferType: "group", resourceType: "zpa_app_connector_group", testdataFilename: "zpa_app_connector_group"},
"zpa application server": {identiferType: "server", resourceType: "zpa_application_server", testdataFilename: "zpa_application_server"},
"zpa application segment": {identiferType: "appsegment", resourceType: "zpa_application_segment", testdataFilename: "zpa_application_segment"},
"zpa application segment pra": {identiferType: "appsegment", resourceType: "zpa_application_segment_pra", testdataFilename: "zpa_application_segment_pra"},
"zpa application segment inspection": {identiferType: "appsegment", resourceType: "zpa_application_segment_inspection", testdataFilename: "zpa_application_segment_inspection"},
"zpa segment group": {identiferType: "group", resourceType: "zpa_segment_group", testdataFilename: "zpa_segment_group"},
"zpa server group": {identiferType: "group", resourceType: "zpa_server_group", testdataFilename: "zpa_server_group"},
"zpa application segment browser access": {identiferType: "appsegment", resourceType: "zpa_application_segment_browser_access", testdataFilename: "zpa_application_segment_browser_access"},
"zpa policy access rule": {identiferType: "policy", resourceType: "zpa_policy_access_rule", testdataFilename: "zpa_policy_access_rule"},
"zpa policy inspection rule": {identiferType: "policy", resourceType: "zpa_policy_inspection_rule", testdataFilename: "zpa_policy_inspection_rule"},
"zpa policy timeout rule": {identiferType: "policy", resourceType: "zpa_policy_timeout_rule", testdataFilename: "zpa_policy_timeout_rule"},
"zpa policy forwarding rule": {identiferType: "policy", resourceType: "zpa_policy_forwarding_rule", testdataFilename: "zpa_policy_forwarding_rule"},
"zpa provisioning key": {identiferType: "key", resourceType: "zpa_provisioning_key", testdataFilename: "zpa_provisioning_key"},
"zpa service edge group": {identiferType: "group", resourceType: "zpa_service_edge_group", testdataFilename: "zpa_service_edge_group"},
"zpa lss config controller": {identiferType: "lss", resourceType: "zpa_lss_config_controller", testdataFilename: "zpa_lss_config_controller"},
"zpa inspection custom controls": {identiferType: "inspection", resourceType: "zpa_inspection_custom_controls", testdataFilename: "zpa_inspection_custom_controls"},
"zpa inspection profile": {identiferType: "inspection", resourceType: "zpa_inspection_profile", testdataFilename: "zpa_inspection_profile"},
"zpa app connector group": {identiferType: "group", resourceType: "zpa_app_connector_group", testdataFilename: "zpa_app_connector_group"},
"zpa application server": {identiferType: "server", resourceType: "zpa_application_server", testdataFilename: "zpa_application_server"},
"zpa application segment": {identiferType: "appsegment", resourceType: "zpa_application_segment", testdataFilename: "zpa_application_segment"},
"zpa application segment pra": {identiferType: "appsegment", resourceType: "zpa_application_segment_pra", testdataFilename: "zpa_application_segment_pra"},
"zpa application segment inspection": {identiferType: "appsegment", resourceType: "zpa_application_segment_inspection", testdataFilename: "zpa_application_segment_inspection"},
"zpa cloud browser isolation banner": {identiferType: "isolation", resourceType: "zpa_cloud_browser_isolation_banner", testdataFilename: "zpa_cloud_browser_isolation_banner"},
"zpa cloud browser isolation certificate": {identiferType: "isolation", resourceType: "zpa_cloud_browser_isolation_certificate", testdataFilename: "zpa_cloud_browser_isolation_certificate"},
"zpa cloud browser isolation profile": {identiferType: "isolation", resourceType: "zpa_cloud_browser_isolation_external_profile", testdataFilename: "zpa_cloud_browser_isolation_external_profile"},
"zpa segment group": {identiferType: "group", resourceType: "zpa_segment_group", testdataFilename: "zpa_segment_group"},
"zpa server group": {identiferType: "group", resourceType: "zpa_server_group", testdataFilename: "zpa_server_group"},
"zpa application segment browser access": {identiferType: "appsegment", resourceType: "zpa_application_segment_browser_access", testdataFilename: "zpa_application_segment_browser_access"},
"zpa policy access rule": {identiferType: "policy", resourceType: "zpa_policy_access_rule", testdataFilename: "zpa_policy_access_rule"},
"zpa policy inspection rule": {identiferType: "policy", resourceType: "zpa_policy_inspection_rule", testdataFilename: "zpa_policy_inspection_rule"},
"zpa policy timeout rule": {identiferType: "policy", resourceType: "zpa_policy_timeout_rule", testdataFilename: "zpa_policy_timeout_rule"},
"zpa policy forwarding rule": {identiferType: "policy", resourceType: "zpa_policy_forwarding_rule", testdataFilename: "zpa_policy_forwarding_rule"},
"zpa policy isolation rule": {identiferType: "policy", resourceType: "zpa_policy_isolation_rule", testdataFilename: "zpa_policy_isolation_rule"},
"zpa provisioning key": {identiferType: "key", resourceType: "zpa_provisioning_key", testdataFilename: "zpa_provisioning_key"},
"zpa service edge group": {identiferType: "group", resourceType: "zpa_service_edge_group", testdataFilename: "zpa_service_edge_group"},
"zpa lss config controller": {identiferType: "lss", resourceType: "zpa_lss_config_controller", testdataFilename: "zpa_lss_config_controller"},
"zpa inspection custom controls": {identiferType: "inspection", resourceType: "zpa_inspection_custom_controls", testdataFilename: "zpa_inspection_custom_controls"},
"zpa inspection profile": {identiferType: "inspection", resourceType: "zpa_inspection_profile", testdataFilename: "zpa_inspection_profile"},
"zpa microtenant controller": {identiferType: "microtenant", resourceType: "zpa_microtenant_controller", testdataFilename: "zpa_microtenant_controller"},

// ZIA Resource
"zia admin users": {identiferType: "users", resourceType: "zia_admin_users", testdataFilename: "zia_admin_users"},
"zia dlp dictionaries": {identiferType: "dlp", resourceType: "zia_dlp_dictionaries", testdataFilename: "zia_dlp_dictionaries"},
"zia dlp engines": {identiferType: "dlp", resourceType: "zia_dlp_engines", testdataFilename: "zia_dlp_engines"},
"zia dlp notification templates": {identiferType: "dlp", resourceType: "zia_dlp_notification_templates", testdataFilename: "zia_dlp_notification_templates"},
"zia dlp web rules": {identiferType: "dlp", resourceType: "zia_dlp_web_rules", testdataFilename: "zia_dlp_web_rules"},
"zia firewall filtering rule": {identiferType: "rule", resourceType: "zia_firewall_filtering_rule", testdataFilename: "zia_firewall_filtering_rule"},
Expand All @@ -173,6 +185,8 @@ func TestResourceGeneration(t *testing.T) {
"zia rule labels": {identiferType: "rule", resourceType: "zia_rule_labels", testdataFilename: "zia_rule_labels"},
"zia auth settings urls": {identiferType: "auth", resourceType: "zia_auth_settings_urls", testdataFilename: "zia_auth_settings_urls"},
"zia security settings": {identiferType: "security", resourceType: "zia_security_settings", testdataFilename: "zia_security_settings"},
"zia forward control rule": {identiferType: "forward", resourceType: "zia_forwarding_control_rule", testdataFilename: "zia_forwarding_control_rule"},
"zia zpa gateway": {identiferType: "forward", resourceType: "zia_forwarding_control_zpa_gateway", testdataFilename: "zia_forwarding_control_zpa_gateway"},
}

for name, tc := range tests {
Expand Down Expand Up @@ -226,6 +240,9 @@ func createClientMock(r http.RoundTripper, resourceType, zpaClientID, zpaClientS
applicationsegment: applicationsegment.New(zpaClient),
applicationsegmentpra: applicationsegmentpra.New(zpaClient),
applicationsegmentinspection: applicationsegmentinspection.New(zpaClient),
cbibannercontroller: cbibannercontroller.New(zpaClient),
cbicertificatecontroller: cbicertificatecontroller.New(zpaClient),
cbiprofilecontroller: cbiprofilecontroller.New(zpaClient),
appservercontroller: appservercontroller.New(zpaClient),
bacertificate: bacertificate.New(zpaClient),
cloudconnectorgroup: cloudconnectorgroup.New(zpaClient),
Expand All @@ -249,6 +266,7 @@ func createClientMock(r http.RoundTripper, resourceType, zpaClientID, zpaClientS
inspection_custom_controls: inspection_custom_controls.New(zpaClient),
inspection_predefined_controls: inspection_predefined_controls.New(zpaClient),
inspection_profile: inspection_profile.New(zpaClient),
microtenants: microtenants.New(zpaClient),
},
}
} else if strings.HasPrefix(resourceType, "zia_") {
Expand Down Expand Up @@ -288,6 +306,8 @@ func createClientMock(r http.RoundTripper, resourceType, zpaClientID, zpaClientS
security_policy_settings: security_policy_settings.New(ziaClient),
user_authentication_settings: user_authentication_settings.New(ziaClient),
users: users.New(ziaClient),
forwarding_rules: forwarding_rules.New(ziaClient),
zpa_gateways: zpa_gateways.New(ziaClient),
},
}
}
Expand Down
Loading

0 comments on commit 9e4a418

Please sign in to comment.