github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/provider/ec2/internal/ec2instancetypes/instancetypes.go (about) 1 // Copyright 2016 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package ec2instancetypes 5 6 //go:generate go run process_cost_data.go -o generated.go index.json 7 8 import ( 9 "strings" 10 11 "github.com/juju/juju/environs/instances" 12 ) 13 14 // RegionInstanceTypes returns the instance types for the named region. 15 func RegionInstanceTypes(region string) []instances.InstanceType { 16 // NOTE(axw) at the time of writing, there is no cost 17 // information for China (Beijing). For any regions 18 // that we don't know about, we substitute us-east-1 19 // and hope that they're equivalent. 20 instanceTypes, ok := allInstanceTypes[region] 21 if !ok { 22 instanceTypes = allInstanceTypes["us-east-1"] 23 } 24 return instanceTypes 25 } 26 27 // SupportsClassic reports whether the instance type with the given 28 // name can be run in EC2-Classic. 29 // 30 // At the time of writing, we know that the following instance type 31 // families support only VPC: C4, M4, P2, T2, X1. However, rather 32 // than hard-coding that list, we assume that any new instance type 33 // families support VPC only, and so we hard-code the inverse of the 34 // list at the time of writing. 35 // 36 // See: 37 // http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-vpc.html#vpc-only-instance-types 38 func SupportsClassic(instanceType string) bool { 39 parts := strings.SplitN(instanceType, ".", 2) 40 if len(parts) < 2 { 41 return false 42 } 43 switch strings.ToLower(parts[0]) { 44 case 45 "c1", "c3", 46 "cc2", 47 "cg1", 48 "cr1", 49 "d2", 50 "g2", 51 "hi1", 52 "hs1", 53 "i2", 54 "m1", "m2", "m3", 55 "r3", 56 "t1": 57 return true 58 } 59 return false 60 }