Skip to content

Commit

Permalink
update readme and fix some usage text
Browse files Browse the repository at this point in the history
  • Loading branch information
bwagner5 committed May 15, 2020
1 parent 565d148 commit 48de950
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 31 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -16,6 +16,7 @@ matrix:
script: make go-report-card-test
env: GO_REPORT_CARD=true
- stage: Test
if: type = push AND env(DOCKER_USERNAME) IS present
script: make output-validation-test
env: CFN_AND_TERRAFORM_OUTPUT_VALIDATION_TESTS=true
- stage: Test
Expand Down
49 changes: 27 additions & 22 deletions README.md
Expand Up @@ -40,7 +40,7 @@ Instance Selector can also be consumed as a go library for direct integration in
## Installation and Configuration

```
curl -Lo ec2-instance-selector https://github.com/aws/amazon-ec2-instance-selector/releases/download/latest/instance-selector-$(uname | tr '[:upper:]' '[:lower:]')-amd64
curl -Lo ec2-instance-selector https://github.com/aws/amazon-ec2-instance-selector/releases/download/v0.8.0/ec2-instance-selector-`uname | tr '[:upper:]' '[:lower:]'`-amd64 && chmod +x ec2-instance-selector
```

To execute the CLI, you will need AWS credentials configured. Take a look at the [AWS CLI configuration documentation](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html#config-settings-and-precedence) for details on the various ways to configure credentials. An easy way to try out the ec2-instance-selector CLI is to populate the following environment variables with your AWS API credentials.
Expand All @@ -53,9 +53,14 @@ export AWS_SECRET_ACCESS_KEY="..."
If you already have an AWS CLI profile setup, you can pass that directly into ec2-instance-selector:

```
$ ec2-instance-selector --profile=my-aws-cli-profile --vcpus=2
$ ec2-instance-selector --profile my-aws-cli-profile --vcpus 2 --region us-east-1
```

You can set a REGION environment variable if you don't want to pass in `--region` on each run.

```
$ export REGION="us-east-1"
```

## Examples

Expand Down Expand Up @@ -125,8 +130,8 @@ Usage:
ec2-instance-selector [flags]
Examples:
ec2-instance-selector --vcpus=4 --region=us-east-2 --availability-zone=us-east-2b
ec2-instance-selector --memory-min=4096 --memory-max=8192 --vcpus-min=4 --vcpus-max=8 --region=us-east-2
ec2-instance-selector --vcpus 4 --region us-east-2 --availability-zone us-east-2b
ec2-instance-selector --memory-min 4096 --memory-max 8192 --vcpus-min 4 --vcpus-max 8 --region us-east-2
Filter Flags:
-z, --availability-zone string Availability zone or zone id to check only EC2 capacity offered in a specific AZ
Expand All @@ -136,29 +141,29 @@ Filter Flags:
--current-generation Current generation instance types (explicitly set this to false to not return current generation instance types)
-e, --ena-support Instance types where ENA is supported or required
-f, --fpga-support FPGA instance types
--gpu-memory-total Number Number of GPUs' total memory in `MiB` (Example: 4096) (sets --gpu-memory-total-min and -max to the same value)
--gpu-memory-total-max Number Maximum Number of GPUs' total memory in `MiB` (Example: 4096) If --gpu-memory-total-min is not specified, the lower bound will be 0
--gpu-memory-total-min Number Minimum Number of GPUs' total memory in `MiB` (Example: 4096) If --gpu-memory-total-max is not specified, the upper bound will be infinity
-g, --gpus Number Total Number of GPUs (Example: 4) (sets --gpus-min and -max to the same value)
--gpus-max Number Maximum Total Number of GPUs (Example: 4) If --gpus-min is not specified, the lower bound will be 0
--gpus-min Number Minimum Total Number of GPUs (Example: 4) If --gpus-max is not specified, the upper bound will be infinity
--gpu-memory-total int Number of GPUs' total memory in MiB (Example: 4096) (sets --gpu-memory-total-min and -max to the same value)
--gpu-memory-total-max int Maximum Number of GPUs' total memory in MiB (Example: 4096) If --gpu-memory-total-min is not specified, the lower bound will be 0
--gpu-memory-total-min int Minimum Number of GPUs' total memory in MiB (Example: 4096) If --gpu-memory-total-max is not specified, the upper bound will be infinity
-g, --gpus int Total Number of GPUs (Example: 4) (sets --gpus-min and -max to the same value)
--gpus-max int Maximum Total Number of GPUs (Example: 4) If --gpus-min is not specified, the lower bound will be 0
--gpus-min int Minimum Total Number of GPUs (Example: 4) If --gpus-max is not specified, the upper bound will be infinity
--hibernation-support Hibernation supported
--hypervisor string Hypervisor: [xen or nitro]
-m, --memory Amount Amount of Memory available in MiB (Example: 4096) (sets --memory-min and -max to the same value)
--memory-max Amount Maximum Amount of Memory available in MiB (Example: 4096) If --memory-min is not specified, the lower bound will be 0
--memory-min Amount Minimum Amount of Memory available in MiB (Example: 4096) If --memory-max is not specified, the upper bound will be infinity
--network-interfaces Number Number of network interfaces (ENIs) that can be attached to the instance (sets --network-interfaces-min and -max to the same value)
--network-interfaces-max Number Maximum Number of network interfaces (ENIs) that can be attached to the instance If --network-interfaces-min is not specified, the lower bound will be 0
--network-interfaces-min Number Minimum Number of network interfaces (ENIs) that can be attached to the instance If --network-interfaces-max is not specified, the upper bound will be infinity
--network-performance Gib/s Bandwidth in Gib/s of network performance (Example: 100) (sets --network-performance-min and -max to the same value)
--network-performance-max Gib/s Maximum Bandwidth in Gib/s of network performance (Example: 100) If --network-performance-min is not specified, the lower bound will be 0
--network-performance-min Gib/s Minimum Bandwidth in Gib/s of network performance (Example: 100) If --network-performance-max is not specified, the upper bound will be infinity
-m, --memory int Amount of Memory available in MiB (Example: 4096) (sets --memory-min and -max to the same value)
--memory-max int Maximum Amount of Memory available in MiB (Example: 4096) If --memory-min is not specified, the lower bound will be 0
--memory-min int Minimum Amount of Memory available in MiB (Example: 4096) If --memory-max is not specified, the upper bound will be infinity
--network-interfaces int Number of network interfaces (ENIs) that can be attached to the instance (sets --network-interfaces-min and -max to the same value)
--network-interfaces-max int Maximum Number of network interfaces (ENIs) that can be attached to the instance If --network-interfaces-min is not specified, the lower bound will be 0
--network-interfaces-min int Minimum Number of network interfaces (ENIs) that can be attached to the instance If --network-interfaces-max is not specified, the upper bound will be infinity
--network-performance int Bandwidth in Gib/s of network performance (Example: 100) (sets --network-performance-min and -max to the same value)
--network-performance-max int Maximum Bandwidth in Gib/s of network performance (Example: 100) If --network-performance-min is not specified, the lower bound will be 0
--network-performance-min int Minimum Bandwidth in Gib/s of network performance (Example: 100) If --network-performance-max is not specified, the upper bound will be infinity
--placement-group-strategy string Placement group strategy: [cluster, partition, spread]
--root-device-type string Supported root device types: [ebs or instance-store]
-u, --usage-class string Usage class: [spot or on-demand]
-c, --vcpus Number Number of vcpus available to the instance type. (sets --vcpus-min and -max to the same value)
--vcpus-max Number Maximum Number of vcpus available to the instance type. If --vcpus-min is not specified, the lower bound will be 0
--vcpus-min Number Minimum Number of vcpus available to the instance type. If --vcpus-max is not specified, the upper bound will be infinity
-c, --vcpus int Number of vcpus available to the instance type. (sets --vcpus-min and -max to the same value)
--vcpus-max int Maximum Number of vcpus available to the instance type. If --vcpus-min is not specified, the lower bound will be 0
--vcpus-min int Minimum Number of vcpus available to the instance type. If --vcpus-max is not specified, the upper bound will be infinity
--vcpus-to-memory-ratio string The ratio of vcpus to memory in MiB. (Example: 1:2)
Global Flags:
Expand Down
16 changes: 8 additions & 8 deletions cmd/main.go
Expand Up @@ -84,8 +84,8 @@ func main() {
longUsage := binName + ` is a CLI tool to filter EC2 instance types based on resource criteria.
Filtering allows you to select all the instance types that match your application requirements.
Full docs can be found at github.com/aws/` + binName
examples := fmt.Sprintf(`%s --vcpus=4 --region=us-east-2 --availability-zone=us-east-2b
%s --memory-min=4096 --memory-max=8192 --vcpus-min=4 --vcpus-max=8 --region=us-east-2`, binName, binName)
examples := fmt.Sprintf(`%s --vcpus 4 --region us-east-2 --availability-zone us-east-2b
%s --memory-min 4096 --memory-max 8192 --vcpus-min 4 --vcpus-max 8 --region us-east-2`, binName, binName)

cli := commandline.New(binName, shortUsage, longUsage, examples)

Expand All @@ -98,12 +98,12 @@ Full docs can be found at github.com/aws/` + binName
// Registers flags with specific input types from the cli pkg
// Filter Flags - These will be grouped at the top of the help flags

cli.IntMinMaxRangeFlags(vcpus, cli.StringMe("c"), nil, "`Number` of vcpus available to the instance type.")
cli.IntMinMaxRangeFlags(memory, cli.StringMe("m"), nil, "`Amount` of Memory available in MiB (Example: 4096)")
cli.IntMinMaxRangeFlags(vcpus, cli.StringMe("c"), nil, "Number of vcpus available to the instance type.")
cli.IntMinMaxRangeFlags(memory, cli.StringMe("m"), nil, "Amount of Memory available in MiB (Example: 4096)")
cli.RatioFlag(vcpusToMemoryRatio, nil, nil, "The ratio of vcpus to memory in MiB. (Example: 1:2)")
cli.StringFlag(cpuArchitecture, cli.StringMe("a"), nil, "CPU architecture [x86_64, i386, or arm64]", nil)
cli.IntMinMaxRangeFlags(gpus, cli.StringMe("g"), nil, "Total `Number` of GPUs (Example: 4)")
cli.IntMinMaxRangeFlags(gpuMemoryTotal, nil, nil, "`Number` of GPUs' total memory in `MiB` (Example: 4096)")
cli.IntMinMaxRangeFlags(gpus, cli.StringMe("g"), nil, "Total Number of GPUs (Example: 4)")
cli.IntMinMaxRangeFlags(gpuMemoryTotal, nil, nil, "Number of GPUs' total memory in MiB (Example: 4096)")
cli.StringFlag(placementGroupStrategy, nil, nil, "Placement group strategy: [cluster, partition, spread]", nil)
cli.StringFlag(usageClass, cli.StringMe("u"), nil, "Usage class: [spot or on-demand]", nil)
cli.StringFlag(rootDeviceType, nil, nil, "Supported root device types: [ebs or instance-store]", nil)
Expand All @@ -115,8 +115,8 @@ Full docs can be found at github.com/aws/` + binName
cli.StringFlag(hypervisor, nil, nil, "Hypervisor: [xen or nitro]", nil)
cli.StringFlag(availabilityZone, cli.StringMe("z"), nil, "Availability zone or zone id to check only EC2 capacity offered in a specific AZ", nil)
cli.BoolFlag(currentGeneration, nil, nil, "Current generation instance types (explicitly set this to false to not return current generation instance types)")
cli.IntMinMaxRangeFlags(networkInterfaces, nil, nil, "`Number` of network interfaces (ENIs) that can be attached to the instance")
cli.IntMinMaxRangeFlags(networkPerformance, nil, nil, "Bandwidth in `Gib/s` of network performance (Example: 100)")
cli.IntMinMaxRangeFlags(networkInterfaces, nil, nil, "Number of network interfaces (ENIs) that can be attached to the instance")
cli.IntMinMaxRangeFlags(networkPerformance, nil, nil, "Bandwidth in Gib/s of network performance (Example: 100)")

// Configuration Flags - These will be grouped at the bottom of the help flags

Expand Down
2 changes: 1 addition & 1 deletion test/output-validation-test/test-output-validation
@@ -1,5 +1,5 @@
#!/bin/bash
set -euo errexit
set -euo pipefail

SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
BUILD_DIR="$SCRIPTPATH/../../build"
Expand Down

0 comments on commit 48de950

Please sign in to comment.