@@ -171,6 +171,13 @@ var (
171171 "vnic_selection" : acctest.Representation {RepType : acctest .Required , Create : `PrimaryVnic` },
172172 }
173173
174+ CoreInstancePoolLoadBalancers3Representation = map [string ]interface {}{
175+ "backend_set_name" : acctest.Representation {RepType : acctest .Required , Create : `${oci_load_balancer_backend_set.test_backend_set3.name}` },
176+ "load_balancer_id" : acctest.Representation {RepType : acctest .Required , Create : `${oci_load_balancer_load_balancer.test_load_balancer3.id}` },
177+ "port" : acctest.Representation {RepType : acctest .Required , Create : `10` },
178+ "vnic_selection" : acctest.Representation {RepType : acctest .Required , Create : `PrimaryVnic` },
179+ }
180+
174181 CoreInstancePoolConfigurationPoolRepresentation = map [string ]interface {}{
175182 "compartment_id" : acctest.Representation {RepType : acctest .Required , Create : `${var.compartment_id}` },
176183 "instance_details" : acctest.RepresentationGroup {RepType : acctest .Required , Group : CoreInstancePoolInstanceConfigurationInstanceDetailsPoolRepresentation },
@@ -240,9 +247,11 @@ var (
240247 DefinedTagsDependencies +
241248 acctest .GenerateResourceFromRepresentationMap ("oci_load_balancer_backend_set" , "test_backend_set" , acctest .Required , acctest .Create , backendSetRepresentation ) +
242249 acctest .GenerateResourceFromRepresentationMap ("oci_load_balancer_backend_set" , "test_backend_set2" , acctest .Required , acctest .Create , backendSet2Representation ) +
250+ acctest .GenerateResourceFromRepresentationMap ("oci_load_balancer_backend_set" , "test_backend_set3" , acctest .Required , acctest .Create , backendSet3Representation ) +
243251 acctest .GenerateResourceFromRepresentationMap ("oci_load_balancer_certificate" , "test_certificate" , acctest .Required , acctest .Create , certificateRepresentation ) +
244252 acctest .GenerateResourceFromRepresentationMap ("oci_load_balancer_load_balancer" , "test_load_balancer" , acctest .Required , acctest .Create , loadBalancerRepresentation ) +
245253 acctest .GenerateResourceFromRepresentationMap ("oci_load_balancer_load_balancer" , "test_load_balancer2" , acctest .Required , acctest .Create , loadBalancer2Representation ) +
254+ acctest .GenerateResourceFromRepresentationMap ("oci_load_balancer_load_balancer" , "test_load_balancer3" , acctest .Required , acctest .Create , loadBalancer3Representation ) +
246255 LoadBalancerSubnetDependencies
247256
248257 CoreInstancePoolResourceDependenciesIpv6 = utils .OciImageIdsVariable +
@@ -481,6 +490,93 @@ func TestCoreInstancePoolResource_basic(t *testing.T) {
481490 },
482491 ),
483492 },
493+ // verify unordered attach
494+ {
495+ Config : config + compartmentIdVariableStr + CoreInstancePoolResourceDependencies +
496+ acctest .GenerateResourceFromRepresentationMap ("oci_core_instance_pool" , "test_instance_pool" , acctest .Optional , acctest .Update , acctest .RepresentationCopyWithNewProperties (CoreInstancePoolRepresentation , map [string ]interface {}{
497+ "load_balancers" : []acctest.RepresentationGroup {{RepType : acctest .Optional , Group : CoreInstancePoolLoadBalancersRepresentation }, {RepType : acctest .Optional , Group : CoreInstancePoolLoadBalancers3Representation }, {RepType : acctest .Optional , Group : CoreInstancePoolLoadBalancers2Representation }},
498+ })),
499+ Check : acctest .ComposeAggregateTestCheckFuncWrapper (
500+ resource .TestCheckResourceAttr (resourceName , "compartment_id" , compartmentId ),
501+ resource .TestCheckResourceAttr (resourceName , "display_name" , "displayName2" ),
502+ resource .TestCheckResourceAttr (resourceName , "freeform_tags.%" , "1" ),
503+ resource .TestCheckResourceAttrSet (resourceName , "id" ),
504+ resource .TestCheckResourceAttrSet (resourceName , "instance_configuration_id" ),
505+ resource .TestCheckResourceAttr (resourceName , "load_balancers.#" , "3" ),
506+ resource .TestCheckResourceAttrSet (resourceName , "load_balancers.0.backend_set_name" ),
507+ resource .TestCheckResourceAttrSet (resourceName , "load_balancers.0.id" ),
508+ resource .TestCheckResourceAttrSet (resourceName , "load_balancers.0.instance_pool_id" ),
509+ resource .TestCheckResourceAttrSet (resourceName , "load_balancers.0.load_balancer_id" ),
510+ resource .TestCheckResourceAttr (resourceName , "load_balancers.0.port" , "10" ),
511+ resource .TestCheckResourceAttrSet (resourceName , "load_balancers.0.state" ),
512+ resource .TestCheckResourceAttr (resourceName , "load_balancers.0.vnic_selection" , "PrimaryVnic" ),
513+ resource .TestCheckResourceAttrSet (resourceName , "load_balancers.1.backend_set_name" ),
514+ resource .TestCheckResourceAttrSet (resourceName , "load_balancers.1.id" ),
515+ resource .TestCheckResourceAttrSet (resourceName , "load_balancers.1.instance_pool_id" ),
516+ resource .TestCheckResourceAttrSet (resourceName , "load_balancers.1.load_balancer_id" ),
517+ resource .TestCheckResourceAttr (resourceName , "load_balancers.1.port" , "10" ),
518+ resource .TestCheckResourceAttrSet (resourceName , "load_balancers.1.state" ),
519+ resource .TestCheckResourceAttr (resourceName , "load_balancers.1.vnic_selection" , "PrimaryVnic" ),
520+ resource .TestCheckResourceAttrSet (resourceName , "load_balancers.2.backend_set_name" ),
521+ resource .TestCheckResourceAttrSet (resourceName , "load_balancers.2.id" ),
522+ resource .TestCheckResourceAttrSet (resourceName , "load_balancers.2.instance_pool_id" ),
523+ resource .TestCheckResourceAttrSet (resourceName , "load_balancers.2.load_balancer_id" ),
524+ resource .TestCheckResourceAttr (resourceName , "load_balancers.2.port" , "10" ),
525+ resource .TestCheckResourceAttrSet (resourceName , "load_balancers.2.state" ),
526+ resource .TestCheckResourceAttr (resourceName , "load_balancers.2.vnic_selection" , "PrimaryVnic" ),
527+ resource .TestCheckResourceAttr (resourceName , "placement_configurations.#" , "1" ),
528+ resource .TestCheckResourceAttrSet (resourceName , "placement_configurations.0.availability_domain" ),
529+ resource .TestCheckResourceAttr (resourceName , "placement_configurations.0.fault_domains.#" , "1" ),
530+ resource .TestCheckResourceAttrSet (resourceName , "placement_configurations.0.primary_subnet_id" ),
531+ resource .TestCheckResourceAttr (resourceName , "size" , "3" ),
532+ resource .TestCheckResourceAttr (resourceName , "state" , "RUNNING" ),
533+ resource .TestCheckResourceAttrSet (resourceName , "time_created" ),
534+ ),
535+ },
536+ // verify unordered detach
537+ {
538+ Config : config + compartmentIdVariableStr + CoreInstancePoolResourceDependencies +
539+ acctest .GenerateResourceFromRepresentationMap ("oci_core_instance_pool" , "test_instance_pool" , acctest .Optional , acctest .Update , acctest .RepresentationCopyWithNewProperties (CoreInstancePoolRepresentation , map [string ]interface {}{
540+ "load_balancers" : []acctest.RepresentationGroup {{RepType : acctest .Optional , Group : CoreInstancePoolLoadBalancersRepresentation }, {RepType : acctest .Optional , Group : CoreInstancePoolLoadBalancers2Representation }},
541+ })),
542+ Check : acctest .ComposeAggregateTestCheckFuncWrapper (
543+ resource .TestCheckResourceAttr (resourceName , "compartment_id" , compartmentId ),
544+ resource .TestCheckResourceAttr (resourceName , "display_name" , "displayName2" ),
545+ resource .TestCheckResourceAttr (resourceName , "freeform_tags.%" , "1" ),
546+ resource .TestCheckResourceAttrSet (resourceName , "id" ),
547+ resource .TestCheckResourceAttrSet (resourceName , "instance_configuration_id" ),
548+ resource .TestCheckResourceAttr (resourceName , "load_balancers.#" , "2" ),
549+ resource .TestCheckResourceAttrSet (resourceName , "load_balancers.0.backend_set_name" ),
550+ resource .TestCheckResourceAttrSet (resourceName , "load_balancers.0.id" ),
551+ resource .TestCheckResourceAttrSet (resourceName , "load_balancers.0.instance_pool_id" ),
552+ resource .TestCheckResourceAttrSet (resourceName , "load_balancers.0.load_balancer_id" ),
553+ resource .TestCheckResourceAttr (resourceName , "load_balancers.0.port" , "10" ),
554+ resource .TestCheckResourceAttrSet (resourceName , "load_balancers.0.state" ),
555+ resource .TestCheckResourceAttr (resourceName , "load_balancers.0.vnic_selection" , "PrimaryVnic" ),
556+ resource .TestCheckResourceAttrSet (resourceName , "load_balancers.1.backend_set_name" ),
557+ resource .TestCheckResourceAttrSet (resourceName , "load_balancers.1.id" ),
558+ resource .TestCheckResourceAttrSet (resourceName , "load_balancers.1.instance_pool_id" ),
559+ resource .TestCheckResourceAttrSet (resourceName , "load_balancers.1.load_balancer_id" ),
560+ resource .TestCheckResourceAttr (resourceName , "load_balancers.1.port" , "10" ),
561+ resource .TestCheckResourceAttrSet (resourceName , "load_balancers.1.state" ),
562+ resource .TestCheckResourceAttr (resourceName , "load_balancers.1.vnic_selection" , "PrimaryVnic" ),
563+ resource .TestCheckResourceAttr (resourceName , "placement_configurations.#" , "1" ),
564+ resource .TestCheckResourceAttrSet (resourceName , "placement_configurations.0.availability_domain" ),
565+ resource .TestCheckResourceAttr (resourceName , "placement_configurations.0.fault_domains.#" , "1" ),
566+ resource .TestCheckResourceAttrSet (resourceName , "placement_configurations.0.primary_subnet_id" ),
567+ resource .TestCheckResourceAttr (resourceName , "size" , "3" ),
568+ resource .TestCheckResourceAttr (resourceName , "state" , "RUNNING" ),
569+ resource .TestCheckResourceAttrSet (resourceName , "time_created" ),
570+
571+ func (s * terraform.State ) (err error ) {
572+ resId2 , err = acctest .FromInstanceState (s , resourceName , "id" )
573+ if resId != resId2 {
574+ return fmt .Errorf ("Resource recreated when it was supposed to be updated." )
575+ }
576+ return err
577+ },
578+ ),
579+ },
484580 // verify detach
485581 {
486582 Config : config + compartmentIdVariableStr + CoreInstancePoolResourceDependencies +
0 commit comments