@@ -93,6 +93,77 @@ func TestAccIBMISLBListenerPolicy_basic(t *testing.T) {
9393 })
9494}
9595
96+ func TestAccIBMISLBListenerPoolPolicy (t * testing.T ) {
97+ var policyID string
98+ vpcname := fmt .Sprintf ("tflblisuat-vpc-%d" , acctest .RandIntRange (10 , 100 ))
99+ subnetname := fmt .Sprintf ("tflblisuat-subnet-%d" , acctest .RandIntRange (10 , 100 ))
100+ lbname := fmt .Sprintf ("tflblisuat%d" , acctest .RandIntRange (10 , 100 ))
101+ lblistenerpolicyname1 := fmt .Sprintf ("tflblisuat-listener-policy-%d" , acctest .RandIntRange (10 , 100 ))
102+
103+ priority1 := "1"
104+ protocol := "http"
105+ port := "8080"
106+ actionPool := "forward_to_pool"
107+ // actionListener := "forward_to_listener"
108+
109+ resource .Test (t , resource.TestCase {
110+ PreCheck : func () { acc .TestAccPreCheck (t ) },
111+ Providers : acc .TestAccProviders ,
112+ CheckDestroy : testAccCheckIBMISLBListenerPolicyDestroy ,
113+ Steps : []resource.TestStep {
114+ {
115+ Config : testAccCheckIBMISLBListenerPoolPolicyConfig (vpcname , subnetname , acc .ISZoneName , acc .ISCIDR , lbname , port , protocol , lblistenerpolicyname1 , actionPool , priority1 ),
116+ Check : resource .ComposeTestCheckFunc (
117+ testAccCheckIBMISLBListenerPolicyExists ("ibm_is_lb_listener_policy.testacc_lb_listener_policy" , policyID ),
118+ resource .TestCheckResourceAttr (
119+ "ibm_is_lb.testacc_LB" , "name" , lbname ),
120+ resource .TestCheckResourceAttr (
121+ "ibm_is_lb_listener_policy.testacc_lb_listener_policy" , "name" , lblistenerpolicyname1 ),
122+
123+ resource .TestCheckResourceAttr (
124+ "ibm_is_lb_listener_policy.testacc_lb_listener_policy" , "priority" , priority1 ),
125+ ),
126+ },
127+ },
128+ })
129+ }
130+
131+ func TestAccIBMISLBListenerListenerPolicy (t * testing.T ) {
132+ var policyID string
133+ vpcname := fmt .Sprintf ("tflblisuat-vpc-%d" , acctest .RandIntRange (10 , 100 ))
134+ subnetname := fmt .Sprintf ("tflblisuat-subnet-%d" , acctest .RandIntRange (10 , 100 ))
135+ lbname := fmt .Sprintf ("tflblisuat%d" , acctest .RandIntRange (10 , 100 ))
136+ lblistenerpolicyname1 := fmt .Sprintf ("tflblisuat-listener-policy-%d" , acctest .RandIntRange (10 , 100 ))
137+
138+ priority1 := "1"
139+ protocol := "http"
140+ port := "8080"
141+ protocol1 := "tcp"
142+ port1 := "8081"
143+ actionlistener := "forward_to_listener"
144+
145+ resource .Test (t , resource.TestCase {
146+ PreCheck : func () { acc .TestAccPreCheck (t ) },
147+ Providers : acc .TestAccProviders ,
148+ CheckDestroy : testAccCheckIBMISLBListenerPolicyDestroy ,
149+ Steps : []resource.TestStep {
150+ {
151+ Config : testAccCheckIBMISLBListenerListenerPolicyConfig (vpcname , subnetname , acc .ISZoneName , acc .ISCIDR , lbname , port , protocol , port1 , protocol1 , lblistenerpolicyname1 , actionlistener , priority1 ),
152+ Check : resource .ComposeTestCheckFunc (
153+ testAccCheckIBMISLBListenerPolicyExists ("ibm_is_lb_listener_policy.testacc_lb_listener_policy" , policyID ),
154+ resource .TestCheckResourceAttr (
155+ "ibm_is_lb.testacc_LB" , "name" , lbname ),
156+ resource .TestCheckResourceAttr (
157+ "ibm_is_lb_listener_policy.testacc_lb_listener_policy" , "name" , lblistenerpolicyname1 ),
158+
159+ resource .TestCheckResourceAttr (
160+ "ibm_is_lb_listener_policy.testacc_lb_listener_policy" , "priority" , priority1 ),
161+ ),
162+ },
163+ },
164+ })
165+ }
166+
96167func TestAccIBMISLBListenerPolicyRedirect_basic (t * testing.T ) {
97168 var policyID string
98169 vpcname := fmt .Sprintf ("tflblisuat-vpc-%d" , acctest .RandIntRange (10 , 100 ))
@@ -459,6 +530,91 @@ func testAccCheckIBMISLBListenerPolicyConfig(vpcname, subnetname, zone, cidr, lb
459530
460531}
461532
533+ func testAccCheckIBMISLBListenerPoolPolicyConfig (vpcname , subnetname , zone , cidr , lbname , port , protocol , lblistenerpolicyname , action , priority string ) string {
534+ return fmt .Sprintf (`
535+ resource "ibm_is_vpc" "testacc_vpc" {
536+ name = "%s"
537+ }
538+
539+ resource "ibm_is_subnet" "testacc_subnet" {
540+ name = "%s"
541+ vpc = ibm_is_vpc.testacc_vpc.id
542+ zone = "%s"
543+ ipv4_cidr_block = "%s"
544+ }
545+ resource "ibm_is_lb" "testacc_LB" {
546+ name = "%s"
547+ subnets = [ibm_is_subnet.testacc_subnet.id]
548+ }
549+ resource "ibm_is_lb_listener" "testacc_lb_listener" {
550+ lb = ibm_is_lb.testacc_LB.id
551+ default_pool = ibm_is_lb_pool.testacc_pool.pool_id
552+ port = %s
553+ protocol = "%s"
554+ }
555+ resource "ibm_is_lb_pool" "testacc_pool" {
556+ name = "test"
557+ lb = ibm_is_lb.testacc_LB.id
558+ algorithm = "round_robin"
559+ protocol = "http"
560+ health_delay = 60
561+ health_retries = 5
562+ health_timeout = 30
563+ health_type = "http"
564+ }
565+
566+ resource "ibm_is_lb_listener_policy" "testacc_lb_listener_policy" {
567+ lb = ibm_is_lb.testacc_LB.id
568+ listener = ibm_is_lb_listener.testacc_lb_listener.listener_id
569+ action = "%s"
570+ priority = %s
571+ name = "%s"
572+ target_id = ibm_is_lb_pool.testacc_pool.pool_id
573+
574+ }` , vpcname , subnetname , zone , cidr , lbname , port , protocol , action , priority , lblistenerpolicyname )
575+
576+ }
577+
578+ func testAccCheckIBMISLBListenerListenerPolicyConfig (vpcname , subnetname , zone , cidr , lbname , port , protocol , port1 , protocol1 , lblistenerpolicyname , action , priority string ) string {
579+ return fmt .Sprintf (`
580+ resource "ibm_is_vpc" "testacc_vpc" {
581+ name = "%s"
582+ }
583+
584+ resource "ibm_is_subnet" "testacc_subnet" {
585+ name = "%s"
586+ vpc = ibm_is_vpc.testacc_vpc.id
587+ zone = "%s"
588+ ipv4_cidr_block = "%s"
589+ }
590+ resource "ibm_is_lb" "testacc_LB" {
591+ name = "%s"
592+ subnets = [ibm_is_subnet.testacc_subnet.id]
593+ }
594+ resource "ibm_is_lb_listener" "testacc_lb_listener" {
595+ lb = ibm_is_lb.testacc_LB.id
596+ port = %s
597+ protocol = "%s"
598+ }
599+
600+ resource "ibm_is_lb_listener" "testacc_lb_listener1" {
601+ lb = ibm_is_lb.testacc_LB.id
602+ port = %s
603+ protocol = "%s"
604+ }
605+
606+ resource "ibm_is_lb_listener_policy" "testacc_lb_listener_policy" {
607+ lb = ibm_is_lb.testacc_LB.id
608+ listener = ibm_is_lb_listener.testacc_lb_listener.listener_id
609+ action = "%s"
610+ priority = %s
611+ name = "%s"
612+ target_id = ibm_is_lb_listener.testacc_lb_listener1.listener_id
613+
614+ }` , vpcname , subnetname , zone , cidr , lbname , port , protocol , port1 , protocol1 , action , priority , lblistenerpolicyname )
615+
616+ }
617+
462618func testAccCheckIBMISLBListenerPolicyConfigUpdate (vpcname , subnetname , zone , cidr , lbname , port , protocol , lblistenerpolicyname , priority , action string ) string {
463619
464620 return fmt .Sprintf (`
0 commit comments