-
Notifications
You must be signed in to change notification settings - Fork 658
/
resource_ibm_is_lb_listener_policy_rule.go
685 lines (567 loc) · 19.2 KB
/
resource_ibm_is_lb_listener_policy_rule.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
// Copyright IBM Corp. 2017, 2021 All Rights Reserved.
// Licensed under the Mozilla Public License v2.0
package vpc
import (
"fmt"
"strings"
"time"
"github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns"
"github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex"
"github.com/IBM-Cloud/terraform-provider-ibm/ibm/validate"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/IBM/vpc-go-sdk/vpcv1"
)
const (
isLBListenerPolicyRuleLBID = "lb"
isLBListenerPolicyRuleListenerID = "listener"
isLBListenerPolicyRulePolicyID = "policy"
isLBListenerPolicyRuleid = "rule"
isLBListenerPolicyRulecondition = "condition"
isLBListenerPolicyRuletype = "type"
isLBListenerPolicyRulevalue = "value"
isLBListenerPolicyRulefield = "field"
isLBListenerPolicyRuleStatus = "provisioning_status"
isLBListenerPolicyRuleAvailable = "active"
isLBListenerPolicyRuleFailed = "failed"
isLBListenerPolicyRulePending = "pending"
isLBListenerPolicyRuleDeleting = "deleting"
isLBListenerPolicyRuleDeleted = "done"
isLBListenerPolicyRuleRetry = "retry"
isLBListenerPolicyRuleProvisioning = "provisioning"
isLBListenerPolicyRuleProvisioningDone = "done"
)
func ResourceIBMISLBListenerPolicyRule() *schema.Resource {
return &schema.Resource{
Create: resourceIBMISLBListenerPolicyRuleCreate,
Read: resourceIBMISLBListenerPolicyRuleRead,
Update: resourceIBMISLBListenerPolicyRuleUpdate,
Delete: resourceIBMISLBListenerPolicyRuleDelete,
Exists: resourceIBMISLBListenerPolicyRuleExists,
Importer: &schema.ResourceImporter{},
Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(10 * time.Minute),
Update: schema.DefaultTimeout(10 * time.Minute),
Delete: schema.DefaultTimeout(10 * time.Minute),
},
Schema: map[string]*schema.Schema{
isLBListenerPolicyRuleLBID: {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: "Loadbalancer ID",
},
isLBListenerPolicyRuleListenerID: {
Type: schema.TypeString,
Required: true,
ForceNew: true,
DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool {
if o == "" {
return false
}
// if state file entry and tf file entry matches
if strings.Compare(n, o) == 0 {
return true
}
if strings.Contains(n, "/") {
//Split lbID/listenerID and fetch listenerID
new := strings.Split(n, "/")
if strings.Compare(new[1], o) == 0 {
return true
}
}
return false
},
Description: "Listener ID.",
},
isLBListenerPolicyRulePolicyID: {
Type: schema.TypeString,
Required: true,
ForceNew: true,
DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool {
if o == "" {
return false
}
// if state file entry and tf file entry matches
if strings.Compare(n, o) == 0 {
return true
}
if strings.Contains(n, "/") {
//Split lbID/listenerID and fetch listenerID
new := strings.Split(n, "/")
if strings.Compare(new[2], o) == 0 {
return true
}
}
return false
},
Description: "Listener Policy ID",
},
isLBListenerPolicyRulecondition: {
Type: schema.TypeString,
Required: true,
ValidateFunc: validate.InvokeValidator("ibm_is_lb_listener_policy_rule", isLBListenerPolicyRulecondition),
Description: "Condition info of the rule.",
},
isLBListenerPolicyRuletype: {
Type: schema.TypeString,
Required: true,
ValidateFunc: validate.InvokeValidator("ibm_is_lb_listener_policy_rule", isLBListenerPolicyRuletype),
Description: "Policy rule type.",
},
isLBListenerPolicyRulevalue: {
Type: schema.TypeString,
Required: true,
ValidateFunc: validate.ValidateStringLength,
Description: "policy rule value info",
},
isLBListenerPolicyRulefield: {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validate.ValidateStringLength,
},
isLBListenerPolicyRuleid: {
Type: schema.TypeString,
Computed: true,
},
isLBListenerPolicyStatus: {
Type: schema.TypeString,
Computed: true,
},
flex.RelatedCRN: {
Type: schema.TypeString,
Computed: true,
Description: "The crn of the LB resource",
},
},
}
}
func ResourceIBMISLBListenerPolicyRuleValidator() *validate.ResourceValidator {
validateSchema := make([]validate.ValidateSchema, 0)
condition := "contains, equals, matches_regex"
ruletype := "header, hostname, path, body, query"
validateSchema = append(validateSchema,
validate.ValidateSchema{
Identifier: isLBListenerPolicyRulecondition,
ValidateFunctionIdentifier: validate.ValidateAllowedStringValue,
Type: validate.TypeString,
Required: true,
AllowedValues: condition})
validateSchema = append(validateSchema,
validate.ValidateSchema{
Identifier: isLBListenerPolicyRuletype,
ValidateFunctionIdentifier: validate.ValidateAllowedStringValue,
Type: validate.TypeString,
Required: true,
AllowedValues: ruletype})
ibmISLBListenerPolicyRuleResourceValidator := validate.ResourceValidator{ResourceName: "ibm_is_lb_listener_policy_rule", Schema: validateSchema}
return &ibmISLBListenerPolicyRuleResourceValidator
}
func resourceIBMISLBListenerPolicyRuleCreate(d *schema.ResourceData, meta interface{}) error {
//Read lb, listerner, policy IDs
var field string
lbID := d.Get(isLBListenerPolicyRuleLBID).(string)
listenerID, err := getLbListenerID(d.Get(isLBListenerPolicyRuleListenerID).(string))
if err != nil {
return err
}
policyID, err := getLbPolicyID(d.Get(isLBListenerPolicyRulePolicyID).(string))
if err != nil {
return err
}
condition := d.Get(isLBListenerPolicyRulecondition).(string)
ty := d.Get(isLBListenerPolicyRuletype).(string)
value := d.Get(isLBListenerPolicyRulevalue).(string)
if n, ok := d.GetOk(isLBListenerPolicyRulefield); ok {
field = n.(string)
}
err = lbListenerPolicyRuleCreate(d, meta, lbID, listenerID, policyID, condition, ty, value, field)
if err != nil {
return err
}
return resourceIBMISLBListenerPolicyRuleRead(d, meta)
}
func getLbListenerID(id string) (string, error) {
if strings.Contains(id, "/") {
parts, err := flex.IdParts(id)
if err != nil {
return "", err
}
return parts[1], nil
} else {
return id, nil
}
}
func getLbPolicyID(id string) (string, error) {
if strings.Contains(id, "/") {
parts, err := flex.IdParts(id)
if err != nil {
return "", err
}
return parts[2], nil
} else {
return id, nil
}
}
func vpcSdkClient(meta interface{}) (*vpcv1.VpcV1, error) {
sess, err := meta.(conns.ClientSession).VpcV1API()
return sess, err
}
func lbListenerPolicyRuleCreate(d *schema.ResourceData, meta interface{}, lbID, listenerID, policyID, condition, ty, value, field string) error {
sess, err := vpcSdkClient(meta)
if err != nil {
return err
}
options := &vpcv1.CreateLoadBalancerListenerPolicyRuleOptions{
LoadBalancerID: &lbID,
ListenerID: &listenerID,
PolicyID: &policyID,
Condition: &condition,
Type: &ty,
Value: &value,
Field: &field,
}
isLBKey := "load_balancer_key_" + lbID
conns.IbmMutexKV.Lock(isLBKey)
defer conns.IbmMutexKV.Unlock(isLBKey)
_, err = isWaitForLoadbalancerAvailable(sess, lbID, d.Timeout(schema.TimeoutCreate))
if err != nil {
return fmt.Errorf(
"LB-LP Error checking for load balancer (%s) is active: %s", lbID, err)
}
rule, response, err := sess.CreateLoadBalancerListenerPolicyRule(options)
if err != nil {
return fmt.Errorf("[ERROR] Error while creating lb listener policy for LB %s: Error %v Response %v", lbID, err, *response)
}
d.SetId(fmt.Sprintf("%s/%s/%s/%s", lbID, listenerID, policyID, *(rule.ID)))
_, err = isWaitForLbListenerPolicyRuleAvailable(sess, d.Id(), d.Timeout(schema.TimeoutCreate))
if err != nil {
return err
}
return nil
}
func isWaitForLoadbalancerAvailable(vpc *vpcv1.VpcV1, id string, timeout time.Duration) (interface{}, error) {
stateConf := &resource.StateChangeConf{
Pending: []string{isLBListenerPolicyRulePending},
Target: []string{isLBProvisioningDone},
Refresh: isLoadbalancerRefreshFunc(vpc, id),
Timeout: timeout,
Delay: 10 * time.Second,
MinTimeout: 10 * time.Second,
}
return stateConf.WaitForState()
}
func isLoadbalancerRefreshFunc(vpc *vpcv1.VpcV1, id string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
getLbOptions := &vpcv1.GetLoadBalancerOptions{
ID: &id,
}
lb, _, err := vpc.GetLoadBalancer(getLbOptions)
if err != nil {
return nil, "", err
}
if *(lb.ProvisioningStatus) == isLBListenerPolicyAvailable {
return lb, isLBProvisioningDone, nil
}
return lb, isLBProvisioning, nil
}
}
func isWaitForLbListenerPolicyRuleAvailable(vpc *vpcv1.VpcV1, id string, timeout time.Duration) (interface{}, error) {
stateConf := &resource.StateChangeConf{
Pending: []string{"retry", isLBListenerPolicyRuleProvisioning, "create_pending", "update_pending", "maintenance_pending"},
Target: []string{isLBListenerPolicyRuleProvisioningDone},
Refresh: isLbListenerPolicyRuleRefreshFunc(vpc, id),
Timeout: timeout,
Delay: 10 * time.Second,
MinTimeout: 10 * time.Second,
}
return stateConf.WaitForState()
}
func isLbListenerPolicyRuleRefreshFunc(vpc *vpcv1.VpcV1, id string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
parts, err := flex.IdParts(id)
if err != nil {
return nil, "", err
}
lbID := parts[0]
listenerID := parts[1]
policyID := parts[2]
ruleID := parts[3]
getLbListenerPolicyRuleOptions := &vpcv1.GetLoadBalancerListenerPolicyRuleOptions{
LoadBalancerID: &lbID,
ListenerID: &listenerID,
PolicyID: &policyID,
ID: &ruleID,
}
rule, _, err := vpc.GetLoadBalancerListenerPolicyRule(getLbListenerPolicyRuleOptions)
if err != nil {
return rule, "", err
}
if *rule.ProvisioningStatus == isLBListenerPolicyRuleAvailable || *rule.ProvisioningStatus == isLBListenerPolicyRuleFailed {
return rule, isLBListenerPolicyRuleProvisioningDone, nil
}
return rule, *rule.ProvisioningStatus, nil
}
}
func resourceIBMISLBListenerPolicyRuleRead(d *schema.ResourceData, meta interface{}) error {
ID := d.Id()
parts, err := flex.IdParts(ID)
if err != nil {
return err
}
lbID := parts[0]
listenerID := parts[1]
policyID := parts[2]
ruleID := parts[3]
err = lbListenerPolicyRuleGet(d, meta, lbID, listenerID, policyID, ruleID)
if err != nil {
return err
}
return nil
}
func resourceIBMISLBListenerPolicyRuleExists(d *schema.ResourceData, meta interface{}) (bool, error) {
ID := d.Id()
exists, err := lbListenerPolicyRuleExists(d, meta, ID)
return exists, err
}
func lbListenerPolicyRuleExists(d *schema.ResourceData, meta interface{}, ID string) (bool, error) {
sess, err := vpcSdkClient(meta)
if err != nil {
return false, err
}
parts, err := flex.IdParts(d.Id())
if err != nil {
return false, err
}
if len(parts) != 4 {
return false, fmt.Errorf("[ERROR] Incorrect ID %s: ID should be a combination of lbID/listenerID/policyID/ruleID", d.Id())
}
lbID := parts[0]
listenerID := parts[1]
policyID := parts[2]
ruleID := parts[3]
getLbListenerPolicyRuleOptions := &vpcv1.GetLoadBalancerListenerPolicyRuleOptions{
LoadBalancerID: &lbID,
ListenerID: &listenerID,
PolicyID: &policyID,
ID: &ruleID,
}
//Getting lb listener policy
_, response, err := sess.GetLoadBalancerListenerPolicyRule(getLbListenerPolicyRuleOptions)
if err != nil {
if response != nil && response.StatusCode == 404 {
return false, nil
}
return false, fmt.Errorf("[ERROR] Error getting policy: %s\n%s", err, response)
}
return true, nil
}
func resourceIBMISLBListenerPolicyRuleUpdate(d *schema.ResourceData, meta interface{}) error {
parts, err := flex.IdParts(d.Id())
if err != nil {
return err
}
lbID := parts[0]
listenerID := parts[1]
policyID := parts[2]
ruleID := parts[3]
err = lbListenerPolicyRuleUpdate(d, meta, lbID, listenerID, policyID, ruleID)
if err != nil {
return err
}
return resourceIBMISLBListenerPolicyRuleRead(d, meta)
}
func lbListenerPolicyRuleUpdate(d *schema.ResourceData, meta interface{}, lbID, listenerID, policyID, ID string) error {
sess, err := vpcSdkClient(meta)
if err != nil {
return err
}
hasChanged := false
updatePolicyRuleOptions := vpcv1.UpdateLoadBalancerListenerPolicyRuleOptions{}
updatePolicyRuleOptions.LoadBalancerID = &lbID
updatePolicyRuleOptions.ListenerID = &listenerID
updatePolicyRuleOptions.PolicyID = &policyID
updatePolicyRuleOptions.ID = &ID
loadBalancerListenerPolicyRulePatchModel := &vpcv1.LoadBalancerListenerPolicyRulePatch{}
if d.HasChange(isLBListenerPolicyRulecondition) {
condition := d.Get(isLBListenerPolicyRulecondition).(string)
loadBalancerListenerPolicyRulePatchModel.Condition = &condition
hasChanged = true
}
if d.HasChange(isLBListenerPolicyRuletype) {
ty := d.Get(isLBListenerPolicyRuletype).(string)
loadBalancerListenerPolicyRulePatchModel.Type = &ty
hasChanged = true
}
if d.HasChange(isLBListenerPolicyRulevalue) {
value := d.Get(isLBListenerPolicyRulevalue).(string)
loadBalancerListenerPolicyRulePatchModel.Value = &value
hasChanged = true
}
if d.HasChange(isLBListenerPolicyRulefield) {
field := d.Get(isLBListenerPolicyRulefield).(string)
loadBalancerListenerPolicyRulePatchModel.Field = &field
hasChanged = true
}
if hasChanged {
loadBalancerListenerPolicyRulePatch, err := loadBalancerListenerPolicyRulePatchModel.AsPatch()
if err != nil {
return fmt.Errorf("[ERROR] Error calling asPatch for LoadBalancerListenerPolicyRulePatch: %s", err)
}
updatePolicyRuleOptions.LoadBalancerListenerPolicyRulePatch = loadBalancerListenerPolicyRulePatch
isLBKey := "load_balancer_key_" + lbID
conns.IbmMutexKV.Lock(isLBKey)
defer conns.IbmMutexKV.Unlock(isLBKey)
_, err = isWaitForLoadbalancerAvailable(sess, lbID, d.Timeout(schema.TimeoutCreate))
if err != nil {
return fmt.Errorf(
"LB-LP Error checking for load balancer (%s) is active: %s", lbID, err)
}
_, response, err := sess.UpdateLoadBalancerListenerPolicyRule(&updatePolicyRuleOptions)
if err != nil {
return fmt.Errorf("[ERROR] Error Updating in policy : %s\n%s", err, response)
}
_, err = isWaitForLbListenerPolicyRuleAvailable(sess, d.Id(), d.Timeout(schema.TimeoutCreate))
if err != nil {
return err
}
}
return nil
}
func resourceIBMISLBListenerPolicyRuleDelete(d *schema.ResourceData, meta interface{}) error {
//Retrieve lbId, listenerId and policyID
parts, err := flex.IdParts(d.Id())
if err != nil {
return err
}
lbID := parts[0]
listenerID := parts[1]
policyID := parts[2]
ruleID := parts[3]
isLBKey := "load_balancer_key_" + lbID
conns.IbmMutexKV.Lock(isLBKey)
defer conns.IbmMutexKV.Unlock(isLBKey)
err = lbListenerPolicyRuleDelete(d, meta, lbID, listenerID, policyID, ruleID)
if err != nil {
return err
}
d.SetId("")
return nil
}
func lbListenerPolicyRuleDelete(d *schema.ResourceData, meta interface{}, lbID, listenerID, policyID, ID string) error {
sess, err := vpcSdkClient(meta)
if err != nil {
return err
}
//Getting rule optins
getLbListenerPolicyRuleOptions := &vpcv1.GetLoadBalancerListenerPolicyRuleOptions{
LoadBalancerID: &lbID,
ListenerID: &listenerID,
PolicyID: &policyID,
ID: &ID,
}
//Getting lb listener policy
_, response, err := sess.GetLoadBalancerListenerPolicyRule(getLbListenerPolicyRuleOptions)
if err != nil {
if response != nil && response.StatusCode == 404 {
d.SetId("")
return nil
}
return fmt.Errorf("[ERROR] Error in LbListenerPolicyGet : %s\n%s", err, response)
}
deleteLbListenerPolicyRuleOptions := &vpcv1.DeleteLoadBalancerListenerPolicyRuleOptions{
LoadBalancerID: &lbID,
ListenerID: &listenerID,
PolicyID: &policyID,
ID: &ID,
}
response, err = sess.DeleteLoadBalancerListenerPolicyRule(deleteLbListenerPolicyRuleOptions)
if err != nil {
return fmt.Errorf("[ERROR] Error in lbListenerPolicyRuleDelete: %s\n%s", err, response)
}
_, err = isWaitForLbListnerPolicyRuleDeleted(sess, d.Id(), d.Timeout(schema.TimeoutDelete))
if err != nil {
return err
}
return nil
}
func isWaitForLbListnerPolicyRuleDeleted(vpc *vpcv1.VpcV1, id string, timeout time.Duration) (interface{}, error) {
stateConf := &resource.StateChangeConf{
Pending: []string{isLBListenerPolicyRuleRetry, isLBListenerPolicyRuleDeleting},
Target: []string{isLBListenerPolicyRuleDeleted, isLBListenerPolicyRuleFailed},
Refresh: isLbListenerPolicyRuleDeleteRefreshFunc(vpc, id),
Timeout: timeout,
Delay: 10 * time.Second,
MinTimeout: 10 * time.Second,
}
return stateConf.WaitForState()
}
func isLbListenerPolicyRuleDeleteRefreshFunc(vpc *vpcv1.VpcV1, id string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
//Retrieve lbId, listenerId and policyID
parts, err := flex.IdParts(id)
if err != nil {
return nil, isLBListenerPolicyFailed, nil
}
lbID := parts[0]
listenerID := parts[1]
policyID := parts[2]
ruleID := parts[3]
getLbListenerPolicyRuleOptions := &vpcv1.GetLoadBalancerListenerPolicyRuleOptions{
LoadBalancerID: &lbID,
ListenerID: &listenerID,
PolicyID: &policyID,
ID: &ruleID,
}
//Getting lb listener policy
rule, response, err := vpc.GetLoadBalancerListenerPolicyRule(getLbListenerPolicyRuleOptions)
if err != nil {
if response != nil && response.StatusCode == 404 {
return rule, isLBListenerPolicyRuleDeleted, nil
}
return rule, isLBListenerPolicyRuleFailed, err
}
return nil, isLBListenerPolicyRuleDeleting, err
}
}
func lbListenerPolicyRuleGet(d *schema.ResourceData, meta interface{}, lbID, listenerID, policyID, id string) error {
sess, err := vpcSdkClient(meta)
if err != nil {
return err
}
//Getting rule optins
getLbListenerPolicyRuleOptions := &vpcv1.GetLoadBalancerListenerPolicyRuleOptions{
LoadBalancerID: &lbID,
ListenerID: &listenerID,
PolicyID: &policyID,
ID: &id,
}
//Getting lb listener policy
rule, response, err := sess.GetLoadBalancerListenerPolicyRule(getLbListenerPolicyRuleOptions)
if err != nil {
if response != nil && response.StatusCode == 404 {
d.SetId("")
return nil
}
return err
}
//set the argument values
d.Set(isLBListenerPolicyRuleLBID, lbID)
d.Set(isLBListenerPolicyRuleListenerID, listenerID)
d.Set(isLBListenerPolicyRulePolicyID, policyID)
d.Set(isLBListenerPolicyRuleid, id)
d.Set(isLBListenerPolicyRulecondition, rule.Condition)
d.Set(isLBListenerPolicyRuletype, rule.Type)
d.Set(isLBListenerPolicyRulevalue, rule.Value)
d.Set(isLBListenerPolicyRulefield, rule.Field)
d.Set(isLBListenerPolicyRuleStatus, rule.ProvisioningStatus)
getLoadBalancerOptions := &vpcv1.GetLoadBalancerOptions{
ID: &lbID,
}
lb, response, err := sess.GetLoadBalancer(getLoadBalancerOptions)
if err != nil {
return fmt.Errorf("[ERROR] Error Getting Load Balancer : %s\n%s", err, response)
}
d.Set(flex.RelatedCRN, *lb.CRN)
return nil
}