Skip to content

Commit d938601

Browse files
authored
fetch spot current price to speed up loading data without caching (#351)
1 parent fe73119 commit d938601

25 files changed

+596
-316
lines changed

.github/workflows/ci.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: EC2 Instance Selector CI and Release
33
on: [push, pull_request, workflow_dispatch]
44

55
env:
6-
DEFAULT_GO_VERSION: ^1.18
6+
DEFAULT_GO_VERSION: ^1.23
77
GITHUB_USERNAME: ${{ secrets.EC2_BOT_GITHUB_USERNAME }}
88
GITHUB_TOKEN: ${{ secrets.EC2_BOT_GITHUB_TOKEN }}
99
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.20 as builder
1+
FROM golang:1.23 as builder
22

33
## GOLANG env
44
ARG GOPROXY="https://proxy.golang.org|direct"

README.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<h4>A CLI tool and go library which recommends instance types based on resource criteria like vcpus and memory.</h4>
44

55
<p>
6-
<a href="https://golang.org/doc/go1.17">
6+
<a href="https://golang.org/doc/go1.23">
77
<img src="https://img.shields.io/github/go-mod/go-version/aws/amazon-ec2-instance-selector?color=blueviolet" alt="go-version">
88
</a>
99
<a href="https://opensource.org/licenses/Apache-2.0">
@@ -25,7 +25,7 @@
2525

2626
## Summary
2727

28-
There are over 270 different instance types available on EC2 which can make the process of selecting appropriate instance types difficult. Instance Selector helps you select compatible instance types for your application to run on. The command line interface can be passed resource criteria like vcpus, memory, network performance, and much more and then return the available, matching instance types.
28+
There are over 800 different instance types available on EC2 which can make the process of selecting appropriate instance types difficult. Instance Selector helps you select compatible instance types for your application to run on. The command line interface can be passed resource criteria like vcpus, memory, network performance, and much more and then return the available, matching instance types.
2929

3030
If you are using spot instances to save on costs, it is a best practice to use multiple instances types within your auto-scaling group (ASG) to ensure your application doesn't experience downtime due to one instance type being interrupted. Instance Selector will help to find a set of instance types that your application can run on.
3131

@@ -313,7 +313,7 @@ Filter Flags:
313313
-z, --availability-zones strings Availability zones or zone ids to check EC2 capacity offered in specific AZs
314314
--baremetal Bare Metal instance types (.metal instances)
315315
-b, --burst-support Burstable instance types
316-
-a, --cpu-architecture string CPU architecture [x86_64/amd64, x86_64_mac, i386, or arm64]
316+
-a, --cpu-architecture string CPU architecture [x86_64, amd64, x86_64_mac, i386, or arm64]
317317
--cpu-manufacturer string CPU manufacturer [amd, intel, aws]
318318
--current-generation Current generation instance types (explicitly set this to false to not return current generation instance types)
319319
--dedicated-hosts Dedicated Hosts supported
@@ -334,6 +334,9 @@ Filter Flags:
334334
-e, --ena-support Instance types where ENA is supported or required
335335
-f, --fpga-support FPGA instance types
336336
--free-tier Free Tier supported
337+
--generation int Generation of the instance type (i.e. c7i.xlarge is 7) (sets --generation-min and -max to the same value)
338+
--generation-max int Maximum Generation of the instance type (i.e. c7i.xlarge is 7) If --generation-min is not specified, the lower bound will be 0
339+
--generation-min int Minimum Generation of the instance type (i.e. c7i.xlarge is 7) If --generation-max is not specified, the upper bound will be infinity
337340
--gpu-manufacturer string GPU Manufacturer name (Example: NVIDIA)
338341
--gpu-memory-total string Number of GPUs' total memory (Example: 4 GiB) (sets --gpu-memory-total-min and -max to the same value)
339342
--gpu-memory-total-max string Maximum Number of GPUs' total memory (Example: 4 GiB) If --gpu-memory-total-min is not specified, the lower bound will be 0
@@ -385,7 +388,8 @@ Suite Flags:
385388
386389
Global Flags:
387390
--cache-dir string Directory to save the pricing and instance type caches (default "~/.ec2-instance-selector/")
388-
--cache-ttl int Cache TTLs in hours for pricing and instance type caches. Setting the cache to 0 will turn off caching and cleanup any on-disk caches. (default 168)
391+
--cache-ttl int Cache TTLs in hours for pricing and instance type caches. Setting the cache to 0 will turn off caching and cleanup any on-disk caches.
392+
--debug Debug - prints debug log messages
389393
-h, --help Help
390394
--max-results int The maximum number of instance types that match your criteria to return (default 20)
391395
-o, --output string Specify the output format (table, table-wide, one-line, interactive)

THIRD_PARTY_LICENSES

+264-2
Original file line numberDiff line numberDiff line change
@@ -818,8 +818,8 @@ THE SOFTWARE.
818818

819819
------
820820

821-
** github.com/imdario/mergo; version v0.3.11 --
822-
https://github.com/imdario/mergo
821+
** dario.cat/mergo; version v1.0.1 --
822+
dario.cat/mergo
823823

824824
Copyright (c) 2013 Dario Castañé. All rights reserved.
825825
Copyright (c) 2012 The Go Authors. All rights reserved.
@@ -1502,3 +1502,265 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15021502
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
15031503
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
15041504
SOFTWARE.
1505+
1506+
------
1507+
1508+
** github.com/charmbracelet/x/term; v0.2.0 --
1509+
github.com/charmbracelet/x/term
1510+
1511+
MIT License
1512+
1513+
Copyright (c) 2023 Charmbracelet, Inc.
1514+
1515+
Permission is hereby granted, free of charge, to any person obtaining a copy
1516+
of this software and associated documentation files (the "Software"), to deal
1517+
in the Software without restriction, including without limitation the rights
1518+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1519+
copies of the Software, and to permit persons to whom the Software is
1520+
furnished to do so, subject to the following conditions:
1521+
1522+
The above copyright notice and this permission notice shall be included in all
1523+
copies or substantial portions of the Software.
1524+
1525+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1526+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1527+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1528+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1529+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1530+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1531+
SOFTWARE.
1532+
1533+
1534+
------
1535+
1536+
** github.com/charmbracelet/x/ansi; v0.2.3 --
1537+
github.com/charmbracelet/x/ansi
1538+
1539+
MIT License
1540+
1541+
Copyright (c) 2023 Charmbracelet, Inc.
1542+
1543+
Permission is hereby granted, free of charge, to any person obtaining a copy
1544+
of this software and associated documentation files (the "Software"), to deal
1545+
in the Software without restriction, including without limitation the rights
1546+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1547+
copies of the Software, and to permit persons to whom the Software is
1548+
furnished to do so, subject to the following conditions:
1549+
1550+
The above copyright notice and this permission notice shall be included in all
1551+
copies or substantial portions of the Software.
1552+
1553+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1554+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1555+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1556+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1557+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1558+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1559+
SOFTWARE.
1560+
1561+
------
1562+
1563+
** github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding; v1.12.0 --
1564+
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding
1565+
1566+
Apache License
1567+
Version 2.0, January 2004
1568+
http://www.apache.org/licenses/
1569+
1570+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1571+
1572+
1. Definitions.
1573+
1574+
"License" shall mean the terms and conditions for use, reproduction,
1575+
and distribution as defined by Sections 1 through 9 of this document.
1576+
1577+
"Licensor" shall mean the copyright owner or entity authorized by
1578+
the copyright owner that is granting the License.
1579+
1580+
"Legal Entity" shall mean the union of the acting entity and all
1581+
other entities that control, are controlled by, or are under common
1582+
control with that entity. For the purposes of this definition,
1583+
"control" means (i) the power, direct or indirect, to cause the
1584+
direction or management of such entity, whether by contract or
1585+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
1586+
outstanding shares, or (iii) beneficial ownership of such entity.
1587+
1588+
"You" (or "Your") shall mean an individual or Legal Entity
1589+
exercising permissions granted by this License.
1590+
1591+
"Source" form shall mean the preferred form for making modifications,
1592+
including but not limited to software source code, documentation
1593+
source, and configuration files.
1594+
1595+
"Object" form shall mean any form resulting from mechanical
1596+
transformation or translation of a Source form, including but
1597+
not limited to compiled object code, generated documentation,
1598+
and conversions to other media types.
1599+
1600+
"Work" shall mean the work of authorship, whether in Source or
1601+
Object form, made available under the License, as indicated by a
1602+
copyright notice that is included in or attached to the work
1603+
(an example is provided in the Appendix below).
1604+
1605+
"Derivative Works" shall mean any work, whether in Source or Object
1606+
form, that is based on (or derived from) the Work and for which the
1607+
editorial revisions, annotations, elaborations, or other modifications
1608+
represent, as a whole, an original work of authorship. For the purposes
1609+
of this License, Derivative Works shall not include works that remain
1610+
separable from, or merely link (or bind by name) to the interfaces of,
1611+
the Work and Derivative Works thereof.
1612+
1613+
"Contribution" shall mean any work of authorship, including
1614+
the original version of the Work and any modifications or additions
1615+
to that Work or Derivative Works thereof, that is intentionally
1616+
submitted to Licensor for inclusion in the Work by the copyright owner
1617+
or by an individual or Legal Entity authorized to submit on behalf of
1618+
the copyright owner. For the purposes of this definition, "submitted"
1619+
means any form of electronic, verbal, or written communication sent
1620+
to the Licensor or its representatives, including but not limited to
1621+
communication on electronic mailing lists, source code control systems,
1622+
and issue tracking systems that are managed by, or on behalf of, the
1623+
Licensor for the purpose of discussing and improving the Work, but
1624+
excluding communication that is conspicuously marked or otherwise
1625+
designated in writing by the copyright owner as "Not a Contribution."
1626+
1627+
"Contributor" shall mean Licensor and any individual or Legal Entity
1628+
on behalf of whom a Contribution has been received by Licensor and
1629+
subsequently incorporated within the Work.
1630+
1631+
2. Grant of Copyright License. Subject to the terms and conditions of
1632+
this License, each Contributor hereby grants to You a perpetual,
1633+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
1634+
copyright license to reproduce, prepare Derivative Works of,
1635+
publicly display, publicly perform, sublicense, and distribute the
1636+
Work and such Derivative Works in Source or Object form.
1637+
1638+
3. Grant of Patent License. Subject to the terms and conditions of
1639+
this License, each Contributor hereby grants to You a perpetual,
1640+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
1641+
(except as stated in this section) patent license to make, have made,
1642+
use, offer to sell, sell, import, and otherwise transfer the Work,
1643+
where such license applies only to those patent claims licensable
1644+
by such Contributor that are necessarily infringed by their
1645+
Contribution(s) alone or by combination of their Contribution(s)
1646+
with the Work to which such Contribution(s) was submitted. If You
1647+
institute patent litigation against any entity (including a
1648+
cross-claim or counterclaim in a lawsuit) alleging that the Work
1649+
or a Contribution incorporated within the Work constitutes direct
1650+
or contributory patent infringement, then any patent licenses
1651+
granted to You under this License for that Work shall terminate
1652+
as of the date such litigation is filed.
1653+
1654+
4. Redistribution. You may reproduce and distribute copies of the
1655+
Work or Derivative Works thereof in any medium, with or without
1656+
modifications, and in Source or Object form, provided that You
1657+
meet the following conditions:
1658+
1659+
(a) You must give any other recipients of the Work or
1660+
Derivative Works a copy of this License; and
1661+
1662+
(b) You must cause any modified files to carry prominent notices
1663+
stating that You changed the files; and
1664+
1665+
(c) You must retain, in the Source form of any Derivative Works
1666+
that You distribute, all copyright, patent, trademark, and
1667+
attribution notices from the Source form of the Work,
1668+
excluding those notices that do not pertain to any part of
1669+
the Derivative Works; and
1670+
1671+
(d) If the Work includes a "NOTICE" text file as part of its
1672+
distribution, then any Derivative Works that You distribute must
1673+
include a readable copy of the attribution notices contained
1674+
within such NOTICE file, excluding those notices that do not
1675+
pertain to any part of the Derivative Works, in at least one
1676+
of the following places: within a NOTICE text file distributed
1677+
as part of the Derivative Works; within the Source form or
1678+
documentation, if provided along with the Derivative Works; or,
1679+
within a display generated by the Derivative Works, if and
1680+
wherever such third-party notices normally appear. The contents
1681+
of the NOTICE file are for informational purposes only and
1682+
do not modify the License. You may add Your own attribution
1683+
notices within Derivative Works that You distribute, alongside
1684+
or as an addendum to the NOTICE text from the Work, provided
1685+
that such additional attribution notices cannot be construed
1686+
as modifying the License.
1687+
1688+
You may add Your own copyright statement to Your modifications and
1689+
may provide additional or different license terms and conditions
1690+
for use, reproduction, or distribution of Your modifications, or
1691+
for any such Derivative Works as a whole, provided Your use,
1692+
reproduction, and distribution of the Work otherwise complies with
1693+
the conditions stated in this License.
1694+
1695+
5. Submission of Contributions. Unless You explicitly state otherwise,
1696+
any Contribution intentionally submitted for inclusion in the Work
1697+
by You to the Licensor shall be under the terms and conditions of
1698+
this License, without any additional terms or conditions.
1699+
Notwithstanding the above, nothing herein shall supersede or modify
1700+
the terms of any separate license agreement you may have executed
1701+
with Licensor regarding such Contributions.
1702+
1703+
6. Trademarks. This License does not grant permission to use the trade
1704+
names, trademarks, service marks, or product names of the Licensor,
1705+
except as required for reasonable and customary use in describing the
1706+
origin of the Work and reproducing the content of the NOTICE file.
1707+
1708+
7. Disclaimer of Warranty. Unless required by applicable law or
1709+
agreed to in writing, Licensor provides the Work (and each
1710+
Contributor provides its Contributions) on an "AS IS" BASIS,
1711+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
1712+
implied, including, without limitation, any warranties or conditions
1713+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
1714+
PARTICULAR PURPOSE. You are solely responsible for determining the
1715+
appropriateness of using or redistributing the Work and assume any
1716+
risks associated with Your exercise of permissions under this License.
1717+
1718+
8. Limitation of Liability. In no event and under no legal theory,
1719+
whether in tort (including negligence), contract, or otherwise,
1720+
unless required by applicable law (such as deliberate and grossly
1721+
negligent acts) or agreed to in writing, shall any Contributor be
1722+
liable to You for damages, including any direct, indirect, special,
1723+
incidental, or consequential damages of any character arising as a
1724+
result of this License or out of the use or inability to use the
1725+
Work (including but not limited to damages for loss of goodwill,
1726+
work stoppage, computer failure or malfunction, or any and all
1727+
other commercial damages or losses), even if such Contributor
1728+
has been advised of the possibility of such damages.
1729+
1730+
9. Accepting Warranty or Additional Liability. While redistributing
1731+
the Work or Derivative Works thereof, You may choose to offer,
1732+
and charge a fee for, acceptance of support, warranty, indemnity,
1733+
or other liability obligations and/or rights consistent with this
1734+
License. However, in accepting such obligations, You may act only
1735+
on Your own behalf and on Your sole responsibility, not on behalf
1736+
of any other Contributor, and only if You agree to indemnify,
1737+
defend, and hold each Contributor harmless for any liability
1738+
incurred by, or claims asserted against, such Contributor by reason
1739+
of your accepting any such warranty or additional liability.
1740+
1741+
END OF TERMS AND CONDITIONS
1742+
1743+
APPENDIX: How to apply the Apache License to your work.
1744+
1745+
To apply the Apache License to your work, attach the following
1746+
boilerplate notice, with the fields enclosed by brackets "[]"
1747+
replaced with your own identifying information. (Don't include
1748+
the brackets!) The text should be enclosed in the appropriate
1749+
comment syntax for the file format. We also recommend that a
1750+
file or class name and description of purpose be included on the
1751+
same "printed page" as the copyright notice for easier
1752+
identification within third-party archives.
1753+
1754+
Copyright [yyyy] [name of copyright owner]
1755+
1756+
Licensed under the Apache License, Version 2.0 (the "License");
1757+
you may not use this file except in compliance with the License.
1758+
You may obtain a copy of the License at
1759+
1760+
http://www.apache.org/licenses/LICENSE-2.0
1761+
1762+
Unless required by applicable law or agreed to in writing, software
1763+
distributed under the License is distributed on an "AS IS" BASIS,
1764+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1765+
See the License for the specific language governing permissions and
1766+
limitations under the License.

0 commit comments

Comments
 (0)