Skip to content
This repository was archived by the owner on Jan 9, 2023. It is now read-only.

Commit 81297b5

Browse files
committed
Include list of possible instance types for validation
1 parent 726f3d7 commit 81297b5

1 file changed

Lines changed: 54 additions & 1 deletion

File tree

pkg/tarmak/provider/amazon/amazon.go

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,18 @@ func (a *Amazon) InstanceType(typeIn string) (typeOut string, err error) {
587587
return "m4.xlarge", nil
588588
}
589589

590-
// TODO: Validate custom instance type here
590+
found := false
591+
for _, t := range a.instanceTypes() {
592+
if t == typeIn {
593+
found = true
594+
break
595+
}
596+
}
597+
598+
if !found {
599+
return "", fmt.Errorf("'%s' is not a supported intance type", typeIn)
600+
}
601+
591602
return typeIn, nil
592603
}
593604

@@ -603,3 +614,45 @@ func (a *Amazon) VolumeType(typeIn string) (typeOut string, err error) {
603614
// TODO: Validate custom instance type here
604615
return typeIn, nil
605616
}
617+
618+
func (a *Amazon) instanceTypes() []string {
619+
return []string{
620+
"c1.medium",
621+
"c1.xlarge",
622+
"c3.2xlarge",
623+
"c3.4xlarge",
624+
"c3.8xlarge",
625+
"c3.large",
626+
"c3.xlarge",
627+
"cc2.8xlarge",
628+
"cg1.4xlarge",
629+
"cr1.8xlarge",
630+
"g2.2xlarge",
631+
"hi1.4xlarge",
632+
"hs1.8xlarge",
633+
"i2.2xlarge",
634+
"i2.4xlarge",
635+
"i2.8xlarge",
636+
"i2.xlarge",
637+
"m1.large",
638+
"m1.medium",
639+
"m1.small",
640+
"m1.xlarge",
641+
"m2.2xlarge",
642+
"m2.4xlarge",
643+
"m2.xlarge",
644+
"m3.2xlarge",
645+
"m3.large",
646+
"m3.medium",
647+
"m3.xlarge",
648+
"r3.2xlarge",
649+
"r3.4xlarge",
650+
"r3.8xlarge",
651+
"r3.large",
652+
"r3.xlarge",
653+
"t1.micro",
654+
"t2.medium",
655+
"t2.micro",
656+
"t2.small",
657+
}
658+
}

0 commit comments

Comments
 (0)