Skip to content

Commit

Permalink
feat: major update (#308)
Browse files Browse the repository at this point in the history
- add minimum vCPU, memory, reduceAZ and wide options
- cli option names changed
- cli output format changed
- add region build script
- add ec2-info build script
- module response format changed

BREAKING CHANGE: options & outputs changed
  • Loading branch information
hoonoh committed Nov 20, 2020
1 parent fe0acba commit 9bd46a5
Show file tree
Hide file tree
Showing 39 changed files with 37,332 additions and 869 deletions.
27 changes: 16 additions & 11 deletions .azure-pipelines-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ steps:
- task: NodeTool@0
inputs:
versionSpec: $(node_version)
displayName: "Install Node.js $(node_version)"
displayName: 'Install Node.js $(node_version)'

- task: CacheBeta@0
inputs:
Expand All @@ -11,41 +11,46 @@ steps:
displayName: Cache Yarn packages

- script: yarn --immutable
displayName: "Install dependencies"
displayName: 'Install dependencies'
condition: ne(variables['node_version'], '8.x')

- script: yarn build
displayName: "Build"
displayName: 'Build'
condition: succeededOrFailed()

# Check linting
- script: yarn lint
displayName: "Check linting"
displayName: 'Check linting'
condition: succeededOrFailed()

# Check types
- script: yarn types
displayName: "Check types"
displayName: 'Check types'
condition: succeededOrFailed()

# Build types
- script: yarn build:types
displayName: 'Build types'
condition: succeededOrFailed()

# Run test:ci
- script: yarn test:ci
displayName: "Run tests"
displayName: 'Run tests'
condition: succeededOrFailed()

# Publish CI test results
- task: PublishTestResults@2
displayName: "Publish test results"
displayName: 'Publish test results'
condition: succeededOrFailed()
inputs:
testRunner: JUnit
testResultsFiles: "junit.xml"
testRunTitle: "CI Tests $(Agent.OS)"
testResultsFiles: 'junit.xml'
testRunTitle: 'CI Tests $(Agent.OS)'

# Publish CI test coverage results
- task: PublishCodeCoverageResults@1
displayName: "Publish test coverage results"
displayName: 'Publish test coverage results'
condition: succeededOrFailed()
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: "$(Build.SourcesDirectory)/coverage/cobertura-coverage.xml"
summaryFileLocation: '$(Build.SourcesDirectory)/coverage/cobertura-coverage.xml'
10 changes: 9 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,21 @@ module.exports = {
'prettier',
'prettier/@typescript-eslint',
],
plugins: ['@typescript-eslint', 'prettier'],
plugins: ['@typescript-eslint', 'prettier', 'unused-imports'],
rules: {
'import/no-extraneous-dependencies': 0,
'import/prefer-default-export': 0,
'no-console': 0,
'no-param-reassign': 0,
'prettier/prettier': 'error',

// eslint-plugin-unused-imports
'@typescript-eslint/no-unused-vars': 'off',
'unused-imports/no-unused-imports-ts': 'error',
'unused-imports/no-unused-vars-ts': [
'warn',
{ vars: 'all', varsIgnorePattern: '^_', args: 'after-used', argsIgnorePattern: '^_' },
],
},
overrides: [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: keep ec2 types up to date
name: update constants

on:
schedule:
Expand All @@ -14,12 +14,24 @@ jobs:
- name: Install dependencies
run: yarn --immutable

- name: Generate regions
run: yarn build:regions
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

- name: Generate ec2-types
run: yarn build:ec2-types
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

- name: Generate ec2-info
run: yarn build:ec2-info
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

- name: Build
run: yarn build

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ dist
junit.xml
node_modules
types
webpack-status.json
coverage
150 changes: 105 additions & 45 deletions .pnp.js

Large diffs are not rendered by default.

123 changes: 88 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Supports CLI and module usage.

`aws-spot-run [options]`

If no options are applied, it will fetch all recent pricing data from default regions and show top 20 cheapest instances.
If no options are applied, it will fetch all recent pricing data from default regions and show top 30 cheapest instances.

#### Credentials

Expand All @@ -52,38 +52,80 @@ Start with UI mode.
AWS region to fetch data from. Accepts multiple string values.
Defaults to all available AWS region which does not require opt-in.

###### _example `-r us-east-1 us-east-2`_

##### --family

EC2 instance families to filter. Will be translated to `--familyType` and `--size` values.
Accepts multiple string values.
Choose from: `general`, `compute`, `memory`, `storage`, `acceleratedComputing`

###### _example `-f general compute`_

##### --instanceType | -i

Type of EC2 instance to filter. Accepts multiple string values.
Enter valid EC2 instance type name. e.g. `-i t3.nano t3a.nano`
Enter valid EC2 instance type name.

###### _example `-i t3.nano t3a.nano`_

##### --familyType | -f

EC2 Family type (`c4`, `c5`, etc..). Accepts multiple string values.

###### _example `-f c4 c5`_

##### --size | -s

EC2 size (`large`, `xlarge`, etc..). Accepts multiple string values.

##### --priceMax | -p
###### _example `-s large xlarge`_

##### --minVCPU | --mc

Minimum vCPU count

###### _Default: 1_

##### --minMemoryGiB | --mm

Minimum memory size in GiB

###### _Default: 0.5_

##### --priceLimit | --pl

Maximum price.
Maximum price limit.

##### --productDescription | -d
###### _Default: 100_

Instance product description to filter. Accepts multiple string values.
##### --platforms | -p

Instance platforms types to filter. Accepts multiple string values.
You can use `linux` or `windows` (all in lowercase) as wildcard.

###### _Default: "Linux/UNIX" "Linux/UNIX (Amazon VPC)"_

###### _example `-p windows "Red Hat Enterprise Linux"`_

##### --limit | -l

Limits list of price information items to be returned.

###### _Default: 30_

##### --reduceAZ | --raz

Reduce results with cheapest Availability Zone within Region

###### _Default: true_

##### --wide | -w

Output results with detail (vCPU, memory, etc)

###### _Default: false_

##### --json | -j

Outputs in JSON format. This option will silence any progress output.
Expand Down Expand Up @@ -118,52 +160,63 @@ import { getGlobalSpotPrices } from 'aws-spot-price';
(async () => {
const results = await getGlobalSpotPrices({
regions: ['us-east-1', 'us-east-2', 'us-west-1', 'us-west-2'],
familyTypes: ['c3', 'c4', 'c5'],
sizes: ['large', 'medium', 'xlarge'],
familyTypes: ['c5', 'c5a', 'c5ad', 'c5d', 'c5n', 'c6g', 'c6gd'],
minMemoryGiB: 4,
minVCPU: 2,
limit: 5,
reduceAZ: true,
});
console.log(JSON.stringify(results, null, 2));
})();
```

#### Results

```json
[
```json[
{
"AvailabilityZone": "us-east-2a",
"InstanceType": "c4.large",
"ProductDescription": "Linux/UNIX",
"SpotPrice": "0.018100",
"Timestamp": "2019-11-05T03:07:19.000Z"
"availabilityZone": "us-east-2c",
"instanceType": "c5.large",
"platform": "Linux/UNIX",
"spotPrice": 0.019,
"timestamp": "2020-11-19T15:18:07.000Z",
"vCpu": 2,
"memoryGiB": 4
},
{
"AvailabilityZone": "us-east-2c",
"InstanceType": "c4.large",
"ProductDescription": "Linux/UNIX",
"SpotPrice": "0.018100",
"Timestamp": "2019-11-05T03:07:19.000Z"
"availabilityZone": "us-east-2c",
"instanceType": "c5a.large",
"platform": "Linux/UNIX",
"spotPrice": 0.019,
"timestamp": "2020-11-19T22:04:26.000Z",
"vCpu": 2,
"memoryGiB": 4
},
{
"AvailabilityZone": "us-east-2a",
"InstanceType": "c5.large",
"ProductDescription": "Linux/UNIX",
"SpotPrice": "0.019000",
"Timestamp": "2019-11-04T14:51:42.000Z"
"availabilityZone": "us-east-2a",
"instanceType": "c5d.large",
"platform": "Linux/UNIX",
"spotPrice": 0.019,
"timestamp": "2020-11-19T05:58:45.000Z",
"vCpu": 2,
"memoryGiB": 4
},
{
"AvailabilityZone": "us-east-2c",
"InstanceType": "c5.large",
"ProductDescription": "Linux/UNIX",
"SpotPrice": "0.019000",
"Timestamp": "2019-11-04T14:51:42.000Z"
"availabilityZone": "us-east-2a",
"instanceType": "c5n.large",
"platform": "Linux/UNIX",
"spotPrice": 0.019,
"timestamp": "2020-11-20T02:27:24.000Z",
"vCpu": 2,
"memoryGiB": 5.25
},
{
"AvailabilityZone": "us-east-2b",
"InstanceType": "c5.large",
"ProductDescription": "Linux/UNIX",
"SpotPrice": "0.019300",
"Timestamp": "2019-11-04T14:51:42.000Z"
"availabilityZone": "us-east-2b",
"instanceType": "c6g.large",
"platform": "Linux/UNIX",
"spotPrice": 0.02,
"timestamp": "2020-11-19T13:41:03.000Z",
"vCpu": 2,
"memoryGiB": 4
}
]
```
18 changes: 18 additions & 0 deletions aws-spot-price.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"prettier.prettierPath": ".yarn/sdks/prettier/index.js",

// editor
"editor.codeActionsOnSave": { "source.fixAll.eslint": true },
"editor.rulers": [100],
"editor.tabSize": 2,
"editor.formatOnSave": true,
Expand All @@ -24,6 +25,23 @@
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},

"files.watcherExclude": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/node_modules/**": true,
"**/.hg/store/**": true,
".pnp.js": true
},

"search.exclude": {
"**/node_modules": true,
"**/bower_components": true,
"**/*.code-search": true,
".yarn": true,
".pnp.js": true,
"yarn.lock": true
}
},

Expand Down
Loading

0 comments on commit 9bd46a5

Please sign in to comment.