Skip to content

Commit dda06b8

Browse files
authored
Fix bugs in vpn,exception group and threat exception resources (#133)
1 parent 309894a commit dda06b8

7 files changed

+162
-39
lines changed

checkpoint/data_source_checkpoint_management_cloud_services.go

Lines changed: 70 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,39 @@ func dataSourceManagementCloudServices() *schema.Resource {
4141
Computed: true,
4242
Description: "The Management Server's public URL.",
4343
},
44+
"tenant_id": {
45+
Type: schema.TypeString,
46+
Computed: true,
47+
Description: "Tenant ID of Infinity Portal.",
48+
},
49+
"gateways_onboarding_settings": {
50+
Type: schema.TypeList,
51+
MaxItems: 1,
52+
Computed: true,
53+
Description: "Gateways on-boarding to Infinity Portal settings.",
54+
Elem: &schema.Resource{
55+
Schema: map[string]*schema.Schema{
56+
"connection_method": {
57+
Type: schema.TypeString,
58+
Computed: true,
59+
Description: "Indicate whether Gateways will be connected to Infinity Portal automatically or only after policy installation.",
60+
},
61+
"participant_gateways": {
62+
Type: schema.TypeString,
63+
Computed: true,
64+
Description: "Which Gateways will be connected to Infinity Portal.",
65+
},
66+
"specific_gateways": {
67+
Type: schema.TypeSet,
68+
Computed: true,
69+
Description: "Collection of targets identified by Name or UID.",
70+
Elem: &schema.Schema{
71+
Type: schema.TypeString,
72+
},
73+
},
74+
},
75+
},
76+
},
4477
},
4578
}
4679
}
@@ -62,7 +95,7 @@ func dataSourceManagementCloudServicesRead(d *schema.ResourceData, m interface{}
6295

6396
if v := showCloudServicesRes["status"]; v != nil {
6497
_ = d.Set("status", v)
65-
}else{
98+
} else {
6699
_ = d.Set("status", nil)
67100
}
68101

@@ -77,16 +110,50 @@ func dataSourceManagementCloudServicesRead(d *schema.ResourceData, m interface{}
77110
}
78111
_ = d.Set("connected_at", connectedAtState)
79112
}
80-
}else{
113+
} else {
81114
_ = d.Set("connected_at", nil)
82115
}
83116

84117
if v := showCloudServicesRes["management-url"]; v != nil {
85118
_ = d.Set("management_url", v)
86-
}else{
119+
} else {
87120
_ = d.Set("management_url", nil)
88121
}
89122

123+
if v := showCloudServicesRes["tenant-id"]; v != nil {
124+
_ = d.Set("tenant_id", v)
125+
} else {
126+
_ = d.Set("tenant_id", nil)
127+
}
128+
129+
if v := showCloudServicesRes["gateways-onboarding-settings"]; v != nil {
130+
gatewaysOnboardingSettingsMap := v.(map[string]interface{})
131+
gatewaysOnboardingSettings := make(map[string]interface{})
132+
133+
if v := gatewaysOnboardingSettingsMap["connection-method"]; v != nil {
134+
gatewaysOnboardingSettings["connection_method"] = v.(string)
135+
}
136+
137+
if v := gatewaysOnboardingSettingsMap["participant-gateways"]; v != nil {
138+
gatewaysOnboardingSettings["participant_gateways"] = v.(string)
139+
}
140+
141+
if v := gatewaysOnboardingSettingsMap["specific-gateways"]; v != nil {
142+
specificGatewaysJson, _ := v.([]interface{})
143+
specificGatewaysRes := make([]string, 0)
144+
if len(specificGatewaysJson) > 0 {
145+
for _, gw := range specificGatewaysJson {
146+
gw := gw.(map[string]interface{})
147+
specificGatewaysRes = append(specificGatewaysRes, gw["name"].(string))
148+
}
149+
}
150+
gatewaysOnboardingSettings["specific_gateways"] = specificGatewaysRes
151+
}
152+
_ = d.Set("gateways_onboarding_settings", []interface{}{gatewaysOnboardingSettings})
153+
} else {
154+
_ = d.Set("gateways_onboarding_settings", nil)
155+
}
156+
90157
d.SetId("show-cloud-services-" + acctest.RandString(5))
91158

92159
return nil

checkpoint/resource_checkpoint_management_exception_group.go

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,23 +140,45 @@ func createManagementExceptionGroup(d *schema.ResourceData, m interface{}) error
140140

141141
for i := range appliedThreatRulesList {
142142

143-
Payload := make(map[string]interface{})
143+
appliedThreatRule := make(map[string]interface{})
144144

145145
if v, ok := d.GetOk("applied_threat_rules." + strconv.Itoa(i) + ".layer"); ok {
146-
Payload["layer"] = v.(string)
146+
appliedThreatRule["layer"] = v.(string)
147147
}
148148
if v, ok := d.GetOk("applied_threat_rules." + strconv.Itoa(i) + ".name"); ok {
149-
Payload["name"] = v.(string)
149+
appliedThreatRule["name"] = v.(string)
150150
}
151151
if v, ok := d.GetOk("applied_threat_rules." + strconv.Itoa(i) + ".rule_number"); ok {
152-
Payload["rule-number"] = v.(string)
152+
appliedThreatRule["rule-number"] = v.(string)
153153
}
154-
if v, ok := d.GetOk("applied_threat_rules." + strconv.Itoa(i) + ".position"); ok {
155-
Payload["position"] = v.(string)
154+
if _, ok := d.GetOk("applied_threat_rules." + strconv.Itoa(i) + ".position"); ok {
155+
if v, ok := d.GetOk("applied_threat_rules." + strconv.Itoa(i) + ".position.top"); ok {
156+
if v.(string) == "top" {
157+
appliedThreatRule["position"] = "top"
158+
} else {
159+
appliedThreatRule["position"] = map[string]interface{}{"top": v.(string)}
160+
}
161+
}
162+
163+
if v, ok := d.GetOk("applied_threat_rules." + strconv.Itoa(i) + ".position.above"); ok {
164+
appliedThreatRule["position"] = map[string]interface{}{"above": v.(string)}
165+
}
166+
167+
if v, ok := d.GetOk("applied_threat_rules." + strconv.Itoa(i) + ".position.below"); ok {
168+
appliedThreatRule["position"] = map[string]interface{}{"below": v.(string)}
169+
}
170+
171+
if v, ok := d.GetOk("applied_threat_rules." + strconv.Itoa(i) + ".position.bottom"); ok {
172+
if v.(string) == "bottom" {
173+
appliedThreatRule["position"] = "bottom" // entire rule-base
174+
} else {
175+
appliedThreatRule["position"] = map[string]interface{}{"bottom": v.(string)} // section-name
176+
}
177+
}
156178
}
157-
appliedThreatRulesPayload = append(appliedThreatRulesPayload, Payload)
179+
appliedThreatRulesPayload = append(appliedThreatRulesPayload, appliedThreatRule)
158180
}
159-
exceptionGroup["appliedThreatRules"] = appliedThreatRulesPayload
181+
exceptionGroup["applied-threat-rules"] = appliedThreatRulesPayload
160182
}
161183
}
162184

checkpoint/resource_checkpoint_management_threat_exception.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func resourceManagementThreatException() *schema.Resource {
3737
},
3838
"layer": {
3939
Type: schema.TypeString,
40-
Required: true,
40+
Optional: true,
4141
Description: "Layer that the rule belongs to identified by the name or UID.",
4242
},
4343
"position": {

checkpoint/resource_checkpoint_management_vpn_community_star.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func resourceManagementVpnCommunityStar() *schema.Resource {
6767
Default: "aes-256",
6868
},
6969
"ike_p1_rekey_time": {
70-
Type: schema.TypeInt,
70+
Type: schema.TypeString,
7171
Optional: true,
7272
Description: "Indicates the time interval for IKE phase 1 renegotiation.",
7373
Default: 1440,
@@ -106,7 +106,7 @@ func resourceManagementVpnCommunityStar() *schema.Resource {
106106
Default: "group-2",
107107
},
108108
"ike_p2_rekey_time": {
109-
Type: schema.TypeInt,
109+
Type: schema.TypeString,
110110
Optional: true,
111111
Description: "Indicates the time interval for IKE phase 2 renegotiation.",
112112
Default: 1440,
@@ -180,7 +180,7 @@ func resourceManagementVpnCommunityStar() *schema.Resource {
180180
Schema: map[string]*schema.Schema{
181181
"internal_gateway": {
182182
Type: schema.TypeString,
183-
Required: true,
183+
Required: true,
184184
Description: "Internally managed Check Point gateway identified by name or UID, or 'Any' for all internal-gateways participants in this community.",
185185
},
186186
"external_gateway": {
@@ -223,7 +223,7 @@ func resourceManagementVpnCommunityStar() *schema.Resource {
223223
Default: "aes-256",
224224
},
225225
"ike_p1_rekey_time": {
226-
Type: schema.TypeInt,
226+
Type: schema.TypeString,
227227
Optional: true,
228228
Description: "Indicates the time interval for IKE phase 1 renegotiation.",
229229
Default: 1440,
@@ -262,7 +262,7 @@ func resourceManagementVpnCommunityStar() *schema.Resource {
262262
Default: "group-2",
263263
},
264264
"ike_p2_rekey_time": {
265-
Type: schema.TypeInt,
265+
Type: schema.TypeString,
266266
Optional: true,
267267
Description: "Indicates the time interval for IKE phase 2 renegotiation.",
268268
Default: 1440,
@@ -349,7 +349,7 @@ func createManagementVpnCommunityStar(d *schema.ResourceData, m interface{}) err
349349
res["encryption-algorithm"] = v.(string)
350350
}
351351
if v, ok := d.GetOk("ike_phase_1.ike_p1_rekey_time"); ok {
352-
res["ike-p1-rekey-time"] = v.(int)
352+
res["ike-p1-rekey-time"] = v.(string)
353353
}
354354
vpnCommunityStar["ike-phase-1"] = res
355355
}
@@ -371,7 +371,7 @@ func createManagementVpnCommunityStar(d *schema.ResourceData, m interface{}) err
371371
res["ike-p2-pfs-dh-grp"] = v.(bool)
372372
}
373373
if v, ok := d.GetOk("ike_phase_2.ike_p2_rekey_time"); ok {
374-
res["ike-p2-rekey-time"] = v.(int)
374+
res["ike-p2-rekey-time"] = v.(string)
375375
}
376376
vpnCommunityStar["ike-phase-2"] = res
377377
}
@@ -467,7 +467,7 @@ func createManagementVpnCommunityStar(d *schema.ResourceData, m interface{}) err
467467
ikePhase1Payload["diffie-hellman-group"] = v.(string)
468468
}
469469
if v, ok := d.GetOk("granular_encryptions." + strconv.Itoa(i) + ".ike_phase_1.ike_p1_rekey_time"); ok {
470-
ikePhase1Payload["ike-p1-rekey-time"] = v.(int)
470+
ikePhase1Payload["ike-p1-rekey-time"] = v.(string)
471471
}
472472
payload["ike-phase-1"] = ikePhase1Payload
473473
}
@@ -486,7 +486,7 @@ func createManagementVpnCommunityStar(d *schema.ResourceData, m interface{}) err
486486
ikePhase2Payload["ike-p2-pfs-dh-grp"] = v.(bool)
487487
}
488488
if v, ok := d.GetOk("granular_encryptions." + strconv.Itoa(i) + ".ike_phase_2.ike_p2_rekey_time"); ok {
489-
ikePhase2Payload["ike-p2-rekey-time"] = v.(int)
489+
ikePhase2Payload["ike-p2-rekey-time"] = v.(string)
490490
}
491491
payload["ike-phase-2"] = ikePhase2Payload
492492
}
@@ -603,7 +603,7 @@ func readManagementVpnCommunityStar(d *schema.ResourceData, m interface{}) error
603603
ikePhase1MapToReturn["encryption_algorithm"] = v
604604
}
605605
if v := ikePhase1Map["ike-p1-rekey-time"]; v != nil {
606-
ikePhase1MapToReturn["ike_p1_rekey_time"] = v
606+
ikePhase1MapToReturn["ike_p1_rekey_time"] = strconv.Itoa(int(v.(float64)))
607607
}
608608
_, ikePhase1InConf := d.GetOk("ike_phase_1")
609609
defaultIkePhase1 := map[string]interface{}{"encryption_algorithm": "aes-256", "diffie_hellman_group": "group-2", "data_integrity": "sha1"}
@@ -635,7 +635,7 @@ func readManagementVpnCommunityStar(d *schema.ResourceData, m interface{}) error
635635
ikePhase2MapToReturn["ike_p2_pfs_dh_grp"] = v
636636
}
637637
if v := ikePhase2Map["ike-p2-rekey-time"]; v != nil {
638-
ikePhase2MapToReturn["ike_p2_rekey_time"] = v
638+
ikePhase2MapToReturn["ike_p2_rekey_time"] = strconv.Itoa(int(v.(float64)))
639639
}
640640
_, ikePhase2InConf := d.GetOk("ike_phase_2")
641641
defaultIkePhase2 := map[string]interface{}{"encryption_algorithm": "aes-128", "data_integrity": "sha1"}
@@ -673,7 +673,7 @@ func readManagementVpnCommunityStar(d *schema.ResourceData, m interface{}) error
673673
}
674674
}
675675
_ = d.Set("override_vpn_domains", overrideVpnDomainsListToReturn)
676-
}else{
676+
} else {
677677
_ = d.Set("override_vpn_domains", nil)
678678
}
679679

@@ -726,7 +726,7 @@ func readManagementVpnCommunityStar(d *schema.ResourceData, m interface{}) error
726726
}
727727
}
728728
_ = d.Set("shared_secrets", sharedSecretsListToReturn)
729-
}else{
729+
} else {
730730
_ = d.Set("shared_secrets", nil)
731731
}
732732

@@ -749,7 +749,7 @@ func readManagementVpnCommunityStar(d *schema.ResourceData, m interface{}) error
749749
if obj["name"] != nil {
750750
internalGatewayName = obj["name"].(string)
751751
}
752-
}else if val, ok := v.(string); ok {
752+
} else if val, ok := v.(string); ok {
753753
internalGatewayName = val
754754
}
755755
granularEncryptionState["internal_gateway"] = internalGatewayName
@@ -762,7 +762,7 @@ func readManagementVpnCommunityStar(d *schema.ResourceData, m interface{}) error
762762
if obj["name"] != nil {
763763
externalGatewayName = obj["name"].(string)
764764
}
765-
}else if val, ok := v.(string); ok {
765+
} else if val, ok := v.(string); ok {
766766
externalGatewayName = val
767767
}
768768
granularEncryptionState["external_gateway"] = externalGatewayName
@@ -789,7 +789,7 @@ func readManagementVpnCommunityStar(d *schema.ResourceData, m interface{}) error
789789
ikePhase1State["diffie_hellman_group"] = v
790790
}
791791
if v := ikePhase1Show["ike-p1-rekey-time"]; v != nil {
792-
ikePhase1State["ike_p1_rekey_time"] = v
792+
ikePhase1State["ike_p1_rekey_time"] = strconv.Itoa(int(v.(float64)))
793793
}
794794
granularEncryptionState["ike_phase_1"] = ikePhase1State
795795
}
@@ -810,14 +810,14 @@ func readManagementVpnCommunityStar(d *schema.ResourceData, m interface{}) error
810810
ikePhase2State["ike_p2_pfs_dh_grp"] = v
811811
}
812812
if v := ikePhase2Show["ike-p2-rekey-time"]; v != nil {
813-
ikePhase2State["ike_p2_rekey_time"] = v
813+
ikePhase2State["ike_p2_rekey_time"] = strconv.Itoa(int(v.(float64)))
814814
}
815815
granularEncryptionState["ike_phase_2"] = ikePhase2State
816816
}
817817
granularEncryptionsState = append(granularEncryptionsState, granularEncryptionState)
818818
}
819819
_ = d.Set("granular_encryptions", granularEncryptionsState)
820-
}else{
820+
} else {
821821
_ = d.Set("granular_encryptions", nil)
822822
}
823823
}
@@ -1055,7 +1055,7 @@ func updateManagementVpnCommunityStar(d *schema.ResourceData, m interface{}) err
10551055
ikePhase1Payload["diffie-hellman-group"] = v.(string)
10561056
}
10571057
if v, ok := d.GetOk("granular_encryptions." + strconv.Itoa(i) + ".ike_phase_1.ike_p1_rekey_time"); ok {
1058-
ikePhase1Payload["ike-p1-rekey-time"] = v.(int)
1058+
ikePhase1Payload["ike-p1-rekey-time"] = v.(string)
10591059
}
10601060
payload["ike-phase-1"] = ikePhase1Payload
10611061
}
@@ -1074,15 +1074,15 @@ func updateManagementVpnCommunityStar(d *schema.ResourceData, m interface{}) err
10741074
ikePhase2Payload["ike-p2-pfs-dh-grp"] = v.(bool)
10751075
}
10761076
if v, ok := d.GetOk("granular_encryptions." + strconv.Itoa(i) + ".ike_phase_2.ike_p2_rekey_time"); ok {
1077-
ikePhase2Payload["ike-p2-rekey-time"] = v.(int)
1077+
ikePhase2Payload["ike-p2-rekey-time"] = v.(string)
10781078
}
10791079
payload["ike-phase-2"] = ikePhase2Payload
10801080
}
10811081
granularEncryptionsPayload = append(granularEncryptionsPayload, payload)
10821082
}
10831083
vpnCommunityStar["granular-encryptions"] = granularEncryptionsPayload
10841084
}
1085-
}else{
1085+
} else {
10861086
granularEncryptions, _ := d.GetChange("granular_encryptions")
10871087
oldValues := granularEncryptions.([]interface{})
10881088
if len(oldValues) > 0 {

website/checkpoint.erb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,15 @@
493493
<li<%= sidebar_current("docs-checkpoint-resource-checkpoint-management-radius-group") %>>
494494
<a href="/docs/providers/checkpoint/r/checkpoint_management_radius_group.html">checkpoint_management_radius_group</a>
495495
</li>
496+
<li<%= sidebar_current("docs-checkpoint-resource-checkpoint-management-gaia-best-practice") %>>
497+
<a href="/docs/providers/checkpoint/r/checkpoint_management_gaia_best_practice.html">checkpoint_management_gaia_best_practice</a>
498+
</li>
499+
<li<%= sidebar_current("docs-checkpoint-resource-checkpoint-management-dynamic-global-network-object") %>>
500+
<a href="/docs/providers/checkpoint/r/checkpoint_management_dynamic_global_network_object.html">checkpoint_management_dynamic_global_network_object</a>
501+
</li>
502+
<li<%= sidebar_current("docs-checkpoint-resource-checkpoint-management-global-assignment") %>>
503+
<a href="/docs/providers/checkpoint/r/checkpoint_management_global_assignment.html">checkpoint_management_global_assignment</a>
504+
</li>
496505
</ul>
497506
</li>
498507

@@ -853,6 +862,15 @@
853862
<li<%= sidebar_current("docs-checkpoint-data-source-checkpoint-management-radius-group") %>>
854863
<a href="/docs/providers/checkpoint/d/checkpoint_management_radius_group.html">checkpoint_management_radius_group</a>
855864
</li>
865+
<li<%= sidebar_current("docs-checkpoint-data-source-checkpoint-management-gaia-best-practice") %>>
866+
<a href="/docs/providers/checkpoint/d/checkpoint_management_gaia_best_practice.html">checkpoint_management_gaia_best_practice</a>
867+
</li>
868+
<li<%= sidebar_current("docs-checkpoint-data-source-checkpoint-management-dynamic-global-network-object") %>>
869+
<a href="/docs/providers/checkpoint/d/checkpoint_management_dynamic_global_network_object.html">checkpoint_management_dynamic_global_network_object</a>
870+
</li>
871+
<li<%= sidebar_current("docs-checkpoint-data-source-checkpoint-management-global-assignment") %>>
872+
<a href="/docs/providers/checkpoint/d/checkpoint_management_global_assignment.html">checkpoint_management_global_assignment</a>
873+
</li>
856874
</ul>
857875
</li>
858876
</ul>

0 commit comments

Comments
 (0)