@@ -155,6 +155,37 @@ func TestAWSManagedMachinePoolValidateCreate(t *testing.T) {
155155 },
156156 wantErr : false ,
157157 },
158+ {
159+ name : "both instanceType and instanceTypes are specified" ,
160+ pool : & AWSManagedMachinePool {
161+ Spec : AWSManagedMachinePoolSpec {
162+ EKSNodegroupName : "eks-node-group-4" ,
163+ InstanceTypes : []string {"m5.xlarge" , "m5.2xlarge" },
164+ InstanceType : ptr .To ("m5.xlarge" ),
165+ },
166+ },
167+ wantErr : true ,
168+ },
169+ {
170+ name : "only instanceTypes is accepted" ,
171+ pool : & AWSManagedMachinePool {
172+ Spec : AWSManagedMachinePoolSpec {
173+ EKSNodegroupName : "eks-node-group-5" ,
174+ InstanceTypes : []string {"m5.xlarge" , "m5.2xlarge" },
175+ },
176+ },
177+ wantErr : false ,
178+ },
179+ {
180+ name : "only instanceType is accepted" ,
181+ pool : & AWSManagedMachinePool {
182+ Spec : AWSManagedMachinePoolSpec {
183+ EKSNodegroupName : "eks-node-group-6" ,
184+ InstanceType : ptr .To ("m5.xlarge" ),
185+ },
186+ },
187+ wantErr : false ,
188+ },
158189 }
159190 for _ , tt := range tests {
160191 t .Run (tt .name , func (t * testing.T ) {
@@ -693,6 +724,114 @@ func TestAWSManagedMachinePoolValidateUpdate(t *testing.T) {
693724 },
694725 wantErr : false ,
695726 },
727+ {
728+ name : "adding instanceType is rejected" ,
729+ old : & AWSManagedMachinePool {
730+ Spec : AWSManagedMachinePoolSpec {
731+ EKSNodegroupName : "eks-node-group-1" ,
732+ },
733+ },
734+ new : & AWSManagedMachinePool {
735+ Spec : AWSManagedMachinePoolSpec {
736+ EKSNodegroupName : "eks-node-group-1" ,
737+ InstanceType : ptr .To ("m5.xlarge" ),
738+ },
739+ },
740+ wantErr : true ,
741+ },
742+ {
743+ name : "removing instanceType is rejected" ,
744+ old : & AWSManagedMachinePool {
745+ Spec : AWSManagedMachinePoolSpec {
746+ EKSNodegroupName : "eks-node-group-1" ,
747+ InstanceType : ptr .To ("m5.xlarge" ),
748+ },
749+ },
750+ new : & AWSManagedMachinePool {
751+ Spec : AWSManagedMachinePoolSpec {
752+ EKSNodegroupName : "eks-node-group-1" ,
753+ },
754+ },
755+ wantErr : true ,
756+ },
757+ {
758+ name : "changing instanceType is rejected" ,
759+ old : & AWSManagedMachinePool {
760+ Spec : AWSManagedMachinePoolSpec {
761+ EKSNodegroupName : "eks-node-group-1" ,
762+ InstanceType : ptr .To ("m5.xlarge" ),
763+ },
764+ },
765+ new : & AWSManagedMachinePool {
766+ Spec : AWSManagedMachinePoolSpec {
767+ EKSNodegroupName : "eks-node-group-1" ,
768+ InstanceType : ptr .To ("m5.2xlarge" ),
769+ },
770+ },
771+ wantErr : true ,
772+ },
773+ {
774+ name : "adding instanceTypes is rejected" ,
775+ old : & AWSManagedMachinePool {
776+ Spec : AWSManagedMachinePoolSpec {
777+ EKSNodegroupName : "eks-node-group-1" ,
778+ },
779+ },
780+ new : & AWSManagedMachinePool {
781+ Spec : AWSManagedMachinePoolSpec {
782+ EKSNodegroupName : "eks-node-group-1" ,
783+ InstanceTypes : []string {"m5.xlarge" , "m5.2xlarge" },
784+ },
785+ },
786+ wantErr : true ,
787+ },
788+ {
789+ name : "removing instanceTypes is rejected" ,
790+ old : & AWSManagedMachinePool {
791+ Spec : AWSManagedMachinePoolSpec {
792+ EKSNodegroupName : "eks-node-group-1" ,
793+ InstanceTypes : []string {"m5.xlarge" , "m5.2xlarge" },
794+ },
795+ },
796+ new : & AWSManagedMachinePool {
797+ Spec : AWSManagedMachinePoolSpec {
798+ EKSNodegroupName : "eks-node-group-1" ,
799+ },
800+ },
801+ wantErr : true ,
802+ },
803+ {
804+ name : "changing instanceTypes is rejected" ,
805+ old : & AWSManagedMachinePool {
806+ Spec : AWSManagedMachinePoolSpec {
807+ EKSNodegroupName : "eks-node-group-1" ,
808+ InstanceTypes : []string {"m5.xlarge" , "m5.2xlarge" },
809+ },
810+ },
811+ new : & AWSManagedMachinePool {
812+ Spec : AWSManagedMachinePoolSpec {
813+ EKSNodegroupName : "eks-node-group-1" ,
814+ InstanceTypes : []string {"m5.xlarge" , "m6.xlarge" },
815+ },
816+ },
817+ wantErr : true ,
818+ },
819+ {
820+ name : "adding both instanceType and instanceTypes is rejected" ,
821+ old : & AWSManagedMachinePool {
822+ Spec : AWSManagedMachinePoolSpec {
823+ EKSNodegroupName : "eks-node-group-1" ,
824+ },
825+ },
826+ new : & AWSManagedMachinePool {
827+ Spec : AWSManagedMachinePoolSpec {
828+ EKSNodegroupName : "eks-node-group-1" ,
829+ InstanceType : ptr .To ("m5.xlarge" ),
830+ InstanceTypes : []string {"m5.xlarge" , "m6.xlarge" },
831+ },
832+ },
833+ wantErr : true ,
834+ },
696835 }
697836 for _ , tt := range tests {
698837 t .Run (tt .name , func (t * testing.T ) {
0 commit comments