Skip to content

Commit 42ea818

Browse files
authored
treat amd64 the same as x86_64 (#35)
1 parent 039a9ac commit 42ea818

File tree

5 files changed

+25
-3
lines changed

5 files changed

+25
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ Filter Flags:
139139
-z, --availability-zones strings Availability zones or zone ids to check EC2 capacity offered in specific AZs
140140
--baremetal Bare Metal instance types (.metal instances)
141141
-b, --burst-support Burstable instance types
142-
-a, --cpu-architecture string CPU architecture [x86_64, i386, or arm64]
142+
-a, --cpu-architecture string CPU architecture [x86_64/amd64, i386, or arm64]
143143
--current-generation Current generation instance types (explicitly set this to false to not return current generation instance types)
144144
--deny-list string List of instance types which should be excluded w/ regex syntax (Example: m[1-2]\.*)
145145
-e, --ena-support Instance types where ENA is supported or required

cmd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Full docs can be found at github.com/aws/amazon-` + binName
118118
cli.IntMinMaxRangeFlags(vcpus, cli.StringMe("c"), nil, "Number of vcpus available to the instance type.")
119119
cli.IntMinMaxRangeFlags(memory, cli.StringMe("m"), nil, "Amount of Memory available in MiB (Example: 4096)")
120120
cli.RatioFlag(vcpusToMemoryRatio, nil, nil, "The ratio of vcpus to memory in MiB. (Example: 1:2)")
121-
cli.StringFlag(cpuArchitecture, cli.StringMe("a"), nil, "CPU architecture [x86_64, i386, or arm64]", nil)
121+
cli.StringFlag(cpuArchitecture, cli.StringMe("a"), nil, "CPU architecture [x86_64/amd64, i386, or arm64]", nil)
122122
cli.IntMinMaxRangeFlags(gpus, cli.StringMe("g"), nil, "Total Number of GPUs (Example: 4)")
123123
cli.IntMinMaxRangeFlags(gpuMemoryTotal, nil, nil, "Number of GPUs' total memory in MiB (Example: 4096)")
124124
cli.StringFlag(placementGroupStrategy, nil, nil, "Placement group strategy: [cluster, partition, spread]", nil)

pkg/selector/selector.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ const (
6262
networkPerformance = "networkPerformance"
6363
allowList = "allowList"
6464
denyList = "denyList"
65+
66+
cpuArchitectureAMD64 = "amd64"
67+
cpuArchitectureX8664 = "x86_64"
6568
)
6669

6770
// New creates an instance of Selector provided an aws session
@@ -149,6 +152,10 @@ func (itf Selector) rawFilter(filters Filters) ([]*ec2.InstanceTypeInfo, error)
149152
}
150153
}
151154

155+
if filters.CPUArchitecture != nil && *filters.CPUArchitecture == cpuArchitectureAMD64 {
156+
*filters.CPUArchitecture = cpuArchitectureX8664
157+
}
158+
152159
if filters.AvailabilityZones != nil {
153160
locations = *filters.AvailabilityZones
154161
} else if filters.Region != nil {

pkg/selector/selector_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,3 +554,18 @@ func TestFilter_AllowAndDenyList(t *testing.T) {
554554
h.Ok(t, err)
555555
h.Assert(t, len(results) == 4, "Allow/Deny List Regex: 'c4.large' should return 4 instance types matching the regex but returned %d", len(results))
556556
}
557+
558+
func TestFilter_X8664_AMD64(t *testing.T) {
559+
ec2Mock := setupMock(t, describeInstanceTypesPages, "t3_micro.json")
560+
itf := selector.Selector{
561+
EC2: ec2Mock,
562+
}
563+
filters := selector.Filters{
564+
CPUArchitecture: aws.String("amd64"),
565+
}
566+
results, err := itf.Filter(filters)
567+
h.Ok(t, err)
568+
log.Println(results)
569+
h.Assert(t, len(results) == 1, "Should only return 1 instance type with x86_64/amd64 cpu architecture")
570+
h.Assert(t, results[0] == "t3.micro", "Should return t3.micro, got %s instead", results[0])
571+
}

pkg/selector/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ type Filters struct {
9696
Burstable *bool
9797

9898
// CPUArchitecture of the EC2 instance type
99-
// Possible values are: x86_64 or arm64
99+
// Possible values are: x86_64/amd64 or arm64
100100
CPUArchitecture *string
101101

102102
// CurrentGeneration returns the latest generation of instance types

0 commit comments

Comments
 (0)