amazon-ec2-instance-selector

amazon-ec2-instance-selector

基于资源需求筛选EC2实例类型的工具

amazon-ec2-instance-selector是一个CLI工具和Go库,用于根据指定资源条件筛选EC2实例类型。支持vCPU、内存、网络性能等多种过滤条件,并提供聚合过滤功能。此工具有助于选择Spot实例和优化成本,可集成到自动化流程中。

Amazon EC2实例选择器AWS云计算自动伸缩组Github开源项目
<h1>Amazon EC2 实例选择器</h1> <h4>一个基于资源标准(如 vCPU 和内存)推荐实例类型的命令行工具和 Go 库。</h4> <p> <a href="https://golang.org/doc/go1.17"> <img src="https://img.shields.io/github/go-mod/go-version/aws/amazon-ec2-instance-selector?color=blueviolet" alt="go-version"> </a> <a href="https://opensource.org/licenses/Apache-2.0"> <img src="https://yellow-cdn.veclightyear.com/835a84d5/4b10ab12-d2ad-492f-9b3b-9c735ffac49e.svg" alt="license"> </a> <a href="https://goreportcard.com/report/github.com/aws/amazon-ec2-instance-selector"> <img src="https://goreportcard.com/badge/github.com/aws/amazon-ec2-instance-selector" alt="go-report-card"> </a> <a href="https://hub.docker.com/r/amazon/amazon-ec2-instance-selector"> <img src="https://img.shields.io/docker/pulls/amazon/amazon-ec2-instance-selector" alt="docker-pulls"> </a> </p>

EC2 实例选择器 CI 和发布

<div> <hr> </div>

概述

EC2 上有超过 270 种不同的实例类型,这可能使选择合适的实例类型变得困难。实例选择器可以帮助您为应用程序选择兼容的实例类型。命令行界面可以接收 vCPU、内存、网络性能等资源标准,然后返回可用的匹配实例类型。

如果您使用竞价型实例来节省成本,最佳实践是在自动扩展组(ASG)中使用多种实例类型,以确保您的应用程序不会因为一种实例类型被中断而停机。实例选择器将帮助您找到一组可以运行应用程序的实例类型。

实例选择器也可以作为 Go 库直接集成到您的 Go 代码中。

主要特性

  • 使用声明式资源标准(如 vCPU、内存、网络性能等)筛选 AWS 实例类型!
  • 聚合筛选器允许更有针对性的实例选择,如 --base-instance-type--flexible
  • 可作为 Go 库使用

安装和配置

使用 Homebrew 安装

brew tap aws/tap
brew install ec2-instance-selector

使用 Curl 在 Linux/Mac 上安装

$ curl -Lo ec2-instance-selector https://github.com/aws/amazon-ec2-instance-selector/releases/download/v2.4.1/ec2-instance-selector-`uname | tr '[:upper:]' '[:lower:]'`-amd64 && chmod +x ec2-instance-selector
$ sudo mv ec2-instance-selector /usr/local/bin/
$ ec2-instance-selector --version

要执行 CLI,您需要配置 AWS 凭证。查看 AWS CLI 配置文档 了解配置凭证的各种方法详情。尝试 ec2-instance-selector CLI 的一个简单方法是使用您的 AWS API 凭证填充以下环境变量。

export AWS_ACCESS_KEY_ID="..."
export AWS_SECRET_ACCESS_KEY="..."

如果您已经设置了 AWS CLI 配置文件,可以直接将其传递给 ec2-instance-selector:

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

如果您不想每次运行时都传入 --region,可以设置 AWS_REGION 环境变量。

$ export AWS_REGION="us-east-1"

示例

CLI

查找具有 4 GiB 内存、2 个 vCPU,并在 x86_64 CPU 架构上运行的实例类型

$ ec2-instance-selector --memory 4 --vcpus 2 --cpu-architecture x86_64 -r us-east-1
c5.large
c5a.large
c5ad.large
c5d.large
c6a.large
c6i.large
t2.medium
t3.medium
t3a.medium

查找支持 100GB/s 网络性能且可作为竞价型实例购买的实例类型

$ ec2-instance-selector --network-performance 100 --usage-class spot -r us-east-1
c5n.18xlarge
c5n.metal
c6gn.16xlarge
dl1.24xlarge
g4dn.metal
g5.48xlarge
i3en.24xlarge
i3en.metal
im4gn.16xlarge
inf1.24xlarge
m5dn.24xlarge
m5dn.metal
m5n.24xlarge
m5n.metal
m5zn.12xlarge
m5zn.metal
p3dn.24xlarge
p4d.24xlarge
r5dn.24xlarge
r5dn.metal

简短表格输出

$ ec2-instance-selector --memory 4 --vcpus 2 --cpu-architecture x86_64 -r us-east-1 -o table
实例类型            vCPU        内存 (GiB)
-------------        -----        ---------
c5.large             2            4
c5a.large            2            4
c5ad.large           2            4
c5d.large            2            4
c6a.large            2            4
c6i.large            2            4
t2.medium            2            4
t3.medium            2            4
t3a.medium           2            4

宽表格输出

$ ec2-instance-selector --memory 4 --vcpus 2 --cpu-architecture x86_64 -r us-east-1 -o table-wide
实例类型    vCPU    内存 (GiB)  虚拟化    当前代    支持休眠    CPU 架构    网络性能          ENI     GPU     GPU 内存 (GiB)  GPU 信息  按需价格/小时  竞价价格/小时 (30天平均)  
-------------  -----   ---------  ----------  -----------  -------------------  --------      -------------------  ----    ----    -------------  --------  ------------------  -----------------------  
c5.large       2       4          nitro       true         true                 x86_64        最高 10 Gigabit     3       0       0              无        -未获取-           $0.03932                 
c5a.large      2       4          nitro       true         false                x86_64        最高 10 Gigabit     3       0       0              无        -未获取-           $0.03822                 
c5ad.large     2       4          nitro       true         false                x86_64        最高 10 Gigabit     3       0       0              无        -未获取-           $0.03449                 
c5d.large      2       4          nitro       true         true                 x86_64        最高 10 Gigabit     3       0       0              无        $0.096             $0.03983                 
c6a.large      2       4          nitro       true         false                x86_64        最高 12.5 Gigabit   3       0       0              无        $0.0765            $0.034                   
c6i.large      2       4          nitro       true         false                x86_64        最高 12.5 Gigabit   3       0       0              无        $0.085             $0.03605                 
c6id.large     2       4          nitro       true         false                x86_64        最高 12.5 Gigabit   3       0       0              无        -未获取-           $0.034                   
t2.medium      2       4          xen         true         true                 i386, x86_64  低到中等            3       0       0              无        $0.0464            $0.0139                  
t3.medium      2       4          nitro       true         true                 x86_64        最高 5 Gigabit      3       0       0              无        $0.0416            $0.0125                  
t3a.medium     2       4          nitro       true         true                 x86_64        最高 5 Gigabit      3       0       0              无        -未获取-           $0.01246

交互式输出

$ ec2-instance-selector -o interactive

https://user-images.githubusercontent.com/68402662/184218343-6b236d4a-3fe6-42ae-9fe3-3fd3ee92a4b5.mov 按内存升序排序使用简写

$ ec2-instance-selector -r us-east-1 -o table-wide --max-results 10 --sort-by memory --sort-direction asc
实例类型    vCPU数   内存(GiB)  虚拟化    当前代    休眠支持    CPU架构      网络性能         网卡数  GPU数   GPU内存(GiB)  GPU信息  按需价格/小时   竞价价格/小时(30天平均)  
---------   -----   ---------  ------   -------   --------   --------     -----------     -----  -----   ------------  -------  ------------   ---------------------  
t2.nano     1       0.5        xen      是        是          i386, x86_64  低到中等         2      0       0            无       $0.0058        -未获取-               
t4g.nano    2       0.5        nitro    是        否          arm64         最高5 Gigabit    2      0       0            无       $0.0042        $0.0013                
t3a.nano    2       0.5        nitro    是        是          x86_64        最高5 Gigabit    2      0       0            无       -未获取-        $0.00328               
t3.nano     2       0.5        nitro    是        是          x86_64        最高5 Gigabit    2      0       0            无       $0.0052        $0.0016                
t1.micro    1       0.6123     xen      否        否          i386, x86_64  很低             2      0       0            无       -未获取-        $0.00205               
t3a.micro   2       1          nitro    是        是          x86_64        最高5 Gigabit    2      0       0            无       -未获取-        $0.00284               
t3.micro    2       1          nitro    是        是          x86_64        最高5 Gigabit    2      0       0            无       $0.0104        $0.0031                
t2.micro    1       1          xen      是        是          i386, x86_64  低到中等         2      0       0            无       -未获取-        $0.0035                
t4g.micro   2       1          nitro    是        否          arm64         最高5 Gigabit    2      0       0            无       -未获取-        $0.0025                
m1.small    1       1.69922    xen      否        否          i386, x86_64  低               2      0       0            无       -未获取-        $0.01876
注意:547个条目被截断,增加 --max-results 参数可查看更多

可用的简写标志:vcpus, memory, gpu-memory-total, network-interfaces, spot-price, on-demand-price, instance-storage, ebs-optimized-baseline-bandwidth, ebs-optimized-baseline-throughput, ebs-optimized-baseline-iops, gpus, inference-accelerators

使用JSON路径按内存降序排序

$ ec2-instance-selector -r us-east-1 -o table-wide --max-results 10 --sort-by .MemoryInfo.SizeInMiB --sort-direction desc
实例类型          vCPU数   内存(GiB)  虚拟化   当前代    休眠支持    CPU架构  网络性能       网卡数  GPU数   GPU内存(GiB)  GPU信息  按需价格/小时   竞价价格/小时(30天平均)  
-------------     -----   ---------  ------  -------   --------   -------  -----------   -----  -----   ------------  -------  ------------   ---------------------  
u-12tb1.112xlarge 448     12,288     nitro   是        否         x86_64   100 Gigabit   15     0       0            无       $109.2         -未获取-               
u-9tb1.112xlarge  448     9,216      nitro   是        否         x86_64   100 Gigabit   15     0       0            无       -未获取-        -未获取-               
u-6tb1.112xlarge  448     6,144      nitro   是        否         x86_64   100 Gigabit   15     0       0            无       $54.6          -未获取-               
u-6tb1.56xlarge   224     6,144      nitro   是        否         x86_64   100 Gigabit   15     0       0            无       $46.40391      -未获取-               
x2iedn.metal      128     4,096      无      是        否         x86_64   100 Gigabit   15     0       0            无       $26.676        $20.92296              
x2iedn.32xlarge   128     4,096      nitro   是        否         x86_64   100 Gigabit   15     0       0            无       $26.676        $8.70294               
x1e.32xlarge      128     3,904      xen     是        否         x86_64   25 Gigabit    8      0       0            无       $26.688        $8.0064                
x2iedn.24xlarge   96      3,072      nitro   是        否         x86_64   75 Gigabit    15     0       0            无       $20.007        $6.0021                
u-3tb1.56xlarge   224     3,072      nitro   是        否         x86_64   50 Gigabit    8      0       0            无       $27.3          -未获取-               
x2idn.metal       128     2,048      无      是        否         x86_64   100 Gigabit   15     0       0            无       $13.338        $7.46603
注意:547个条目被截断,增加 --max-results 参数可查看更多

JSON路径必须指向instancetype.Details结构体中的字段。

使用详细输出的实例类型对象示例

$ ec2-instance-selector --max-results 1 -v
[
    {
        "AutoRecoverySupported": true,
        "BareMetal": false,
        "BurstablePerformanceSupported": false,
        "CurrentGeneration": false,
        "DedicatedHostsSupported": true,
        "EbsInfo": {
            "EbsOptimizedInfo": {
                "BaselineBandwidthInMbps": 1750,
                "BaselineIops": 10000,
                "BaselineThroughputInMBps": 218.75,
                "MaximumBandwidthInMbps": 3500,
                "MaximumIops": 20000,
                "MaximumThroughputInMBps": 437.5
            },
            "EbsOptimizedSupport": "default",
            "EncryptionSupport": "supported",
            "NvmeSupport": "required"
        },
        "FpgaInfo": null,
        "FreeTierEligible": false,
        "GpuInfo": null,
        "HibernationSupported": false,
        "Hypervisor": "nitro",
        "InferenceAcceleratorInfo": null,
        "InstanceStorageInfo": null,
        "InstanceStorageSupported": false,
        "InstanceType": "a1.2xlarge",
        "MemoryInfo": {
            "SizeInMiB": 16384
        },
        "NetworkInfo": {
            "DefaultNetworkCardIndex": 0,
            "EfaInfo": null,
            "EfaSupported": false,
            "EnaSupport": "required",
            "EncryptionInTransitSupported": false,
            "Ipv4AddressesPerInterface": 15,
            "Ipv6AddressesPerInterface": 15,
            "Ipv6Supported": true,
            "MaximumNetworkCards": 1,
            "MaximumNetworkInterfaces": 4,
            "NetworkCards": [
                {
                    "MaximumNetworkInterfaces": 4,
                    "NetworkCardIndex": 0,
                    "NetworkPerformance": "Up to 10 Gigabit"
                }
            ],
            "NetworkPerformance": "Up to 10 Gigabit"
        },
        "PlacementGroupInfo": {
            "SupportedStrategies": [
                "cluster",
                "partition",
                "spread"
            ]
        },
        "ProcessorInfo": {
            "SupportedArchitectures": [
                "arm64"
            ],
            "SustainedClockSpeedInGhz": 2.3
        },
        "SupportedBootModes": [
            "uefi"
        ],
        "SupportedRootDeviceTypes": [
            "ebs"
        ],
        "SupportedUsageClasses": [
            "on-demand",
            "spot"
        ],
        "SupportedVirtualizationTypes": [
            "hvm"
        ],
        "VCpuInfo": {
            "DefaultCores": 8,
            "DefaultThreadsPerCore": 1,
            "DefaultVCpus": 8,
            "ValidCores": null,
            "ValidThreadsPerCore": null
        },
        "OndemandPricePerHour": 0.204,
        "SpotPrice": 0.03939999999999999
    }
]
注意:497个条目被截断,增加 --max-results 参数可查看更多

注意:在查找用于排序的JSON路径时,请使用此JSON格式作为参考

所有CLI选项

$ ec2-instance-selector --help
ec2-instance-selector 是一个CLI工具,用于根据资源条件筛选EC2实例类型。 筛选允许您选择满足应用程序要求的所有实例类型。 完整文档可在github.com/aws/amazon-ec2-instance-selector上找到 用法: ec2-instance-selector [flags]

示例: ec2-instance-selector --vcpus 4 --region us-east-2 --availability-zones us-east-2b ec2-instance-selector --memory-min 4 --memory-max 8 --vcpus-min 4 --vcpus-max 8 --region us-east-2

筛选标志: --allow-list string 允许选择的实例类型列表,支持正则表达式语法(示例:m[3-5].) --auto-recovery 支持EC2自动恢复 -z, --availability-zones strings 检查特定可用区提供的EC2容量的可用区或可用区ID --baremetal 裸金属实例类型(.metal实例) -b, --burst-support 可突发性能的实例类型 -a, --cpu-architecture string CPU架构 [x86_64/amd64, x86_64_mac, i386, 或 arm64] --cpu-manufacturer string CPU制造商 [amd, intel, aws] --current-generation 当前一代实例类型(明确设置为false则不返回当前一代实例类型) --dedicated-hosts 支持专用主机 --deny-list string 应排除的实例类型列表,支持正则表达式语法(示例:m[1-2].) --disk-encryption 支持或要求加密的EBS或本地实例存储 --disk-type string 磁盘类型:[hdd 或 ssd] --ebs-optimized 支持或默认启用EBS优化 --ebs-optimized-baseline-bandwidth string EBS优化基准带宽(示例:4 GiB)(将--ebs-optimized-baseline-bandwidth-min和-max设置为相同值) --ebs-optimized-baseline-bandwidth-max string 最大EBS优化基准带宽(示例:4 GiB)如果未指定--ebs-optimized-baseline-bandwidth-min,下限将为0 --ebs-optimized-baseline-bandwidth-min string 最小EBS优化基准带宽(示例:4 GiB)如果未指定--ebs-optimized-baseline-bandwidth-max,上限将为无穷大 --ebs-optimized-baseline-iops int EBS优化基准IOPS每秒(示例:10000)(将--ebs-optimized-baseline-iops-min和-max设置为相同值) --ebs-optimized-baseline-iops-max int 最大EBS优化基准IOPS每秒(示例:10000)如果未指定--ebs-optimized-baseline-iops-min,下限将为0 --ebs-optimized-baseline-iops-min int 最小EBS优化基准IOPS每秒(示例:10000)如果未指定--ebs-optimized-baseline-iops-max,上限将为无穷大 --ebs-optimized-baseline-throughput string EBS优化基准吞吐量每秒(示例:4 GiB)(将--ebs-optimized-baseline-throughput-min和-max设置为相同值) --ebs-optimized-baseline-throughput-max string 最大EBS优化基准吞吐量每秒(示例:4 GiB)如果未指定--ebs-optimized-baseline-throughput-min,下限将为0 --ebs-optimized-baseline-throughput-min string 最小EBS优化基准吞吐量每秒(示例:4 GiB)如果未指定--ebs-optimized-baseline-throughput-max,上限将为无穷大 --efa-support 支持弹性光纤适配器(EFA)的实例类型 -e, --ena-support 支持或要求ENA的实例类型 -f, --fpga-support FPGA实例类型 --free-tier 支持免费套餐 --gpu-manufacturer string GPU制造商名称(示例:NVIDIA) --gpu-memory-total string GPU总内存(示例:4 GiB)(将--gpu-memory-total-min和-max设置为相同值) --gpu-memory-total-max string 最大GPU总内存(示例:4 GiB)如果未指定--gpu-memory-total-min,下限将为0 --gpu-memory-total-min string 最小GPU总内存(示例:4 GiB)如果未指定--gpu-memory-total-max,上限将为无穷大 --gpu-model string GPU型号名称(示例:K520) -g, --gpus int32 GPU总数(示例:4)(将--gpus-min和-max设置为相同值) --gpus-max int32 最大GPU总数(示例:4)如果未指定--gpus-min,下限将为0 --gpus-min int32 最小GPU总数(示例:4)如果未指定--gpus-max,上限将为无穷大 --hibernation-support 支持休眠 --hypervisor string 虚拟化管理程序:[xen 或 nitro] --inference-accelerator-manufacturer string 推理加速器制造商名称(示例:AWS) --inference-accelerator-model string 推理加速器型号名称(示例:Inferentia) --inference-accelerators int 推理加速器总数(示例:4)(将--inference-accelerators-min和-max设置为相同值) --inference-accelerators-max int 最大推理加速器总数(示例:4)如果未指定--inference-accelerators-min,下限将为0 --inference-accelerators-min int 最小推理加速器总数(示例:4)如果未指定--inference-accelerators-max,上限将为无穷大 --instance-storage string 本地实例存储容量(示例:4 GiB)(将--instance-storage-min和-max设置为相同值) --instance-storage-max string 最大本地实例存储容量(示例:4 GiB)如果未指定--instance-storage-min,下限将为0 --instance-storage-min string 最小本地实例存储容量(示例:4 GiB)如果未指定--instance-storage-max,上限将为无穷大 --ipv6 支持IPv6的实例类型 -m, --memory string 可用内存容量(示例:4 GiB)(将--memory-min和-max设置为相同值) --memory-max string 最大可用内存容量(示例:4 GiB)如果未指定--memory-min,下限将为0 --memory-min string 最小可用内存容量(示例:4 GiB)如果未指定--memory-max,上限将为无穷大 --network-encryption 支持自动网络传输加密的实例类型 --network-interfaces int32 可以附加到实例的网络接口(ENI)数量(将--network-interfaces-min和-max设置为相同值) --network-interfaces-max int32 最大可以附加到实例的网络接口(ENI)数量 如果未指定--network-interfaces-min,下限将为0 --network-interfaces-min int32 最小可以附加到实例的网络接口(ENI)数量 如果未指定--network-interfaces-max,上限将为无穷大 --network-performance int 网络性能带宽,单位为Gib/s(示例:100)(将--network-performance-min和-max设置为相同值) --network-performance-max int 最大网络性能带宽,单位为Gib/s(示例:100)如果未指定--network-performance-min,下限将为0 --network-performance-min int 最小网络性能带宽,单位为Gib/s(示例:100)如果未指定--network-performance-max,上限将为无穷大 --nvme 支持或要求NVME的EBS或本地实例存储 --placement-group-strategy string 置放群组策略:[cluster, partition, spread] --price-per-hour float 每小时价格(美元)(示例:0.09)(将--price-per-hour-min和-max设置为相同值) --price-per-hour-max float 最高每小时价格(美元)(示例:0.09)如果未指定--price-per-hour-min,下限将为0 --price-per-hour-min float 最低每小时价格(美元)(示例:0.09)如果未指定--price-per-hour-max,上限将为无穷大 --root-device-type string 支持的根设备类型:[ebs 或 instance-store] -u, --usage-class string 使用类别:[spot 或 on-demand] -c, --vcpus int32 实例类型可用的vCPU数量(将--vcpus-min和-max设置为相同值) --vcpus-max int32 实例类型可用的最大vCPU数量 如果未指定--vcpus-min,下限将为0 --vcpus-min int32 实例类型可用的最小vCPU数量 如果未指定--vcpus-max,上限将为无穷大 --vcpus-to-memory-ratio string vCPU与内存(GiB)的比率(示例:1:2) --virtualization-type string 支持的虚拟化类型:[hvm 或 pv]

套件标志: --base-instance-type string 用于检索类似规格实例类型的基准实例类型 --flexible 基于固有默认值和用户覆盖的资源筛选器,检索跨多代的实例类型组 --service string 根据服务支持筛选实例类型(示例:emr-5.20.0) 全局标志: --cache-dir string 用于保存定价和实例类型缓存的目录 (默认为 "~/.ec2-instance-selector/") --cache-ttl int 定价和实例类型缓存的缓存 TTL,单位为小时。将缓存设置为 0 将关闭缓存并清理所有磁盘上的缓存。(默认为 168) -h, --help 帮助 --max-results int 返回符合您条件的实例类型的最大数量 (默认为 20) -o, --output string 指定输出格式 (table, table-wide, one-line, interactive) --profile string 用于凭证和配置的 AWS CLI 配置文件 -r, --region string 用于 API 请求的 AWS 区域 (注意: 如果未传入,将使用 AWS SDK 默认优先级) --sort-by string 指定排序字段。此 CLI 中存在的数量标志 (内存、GPU 等) 或适当实例类型字段的 JSON 路径 (例如: ".MemoryInfo.SizeInMiB") 均可接受。(默认为 ".InstanceType") --sort-direction string 指定排序方向 (ascending, asc, descending, desc) (默认为 "ascending") -v, --verbose 详细模式 - 将打印完整的实例规格 --version 打印 CLI 版本

Go 库

这是直接使用实例选择器 Go 包的最小示例:

cmd/examples/example1.go

package main import ( "context" "fmt" "github.com/aws/amazon-ec2-instance-selector/v2/pkg/bytequantity" "github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector" "github.com/aws/aws-sdk-go-v2/config" ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types" ) func main() { // 为应用程序初始化上下文 ctx := context.Background() // 通过查看共享凭证或环境变量加载 AWS 会话 // https://aws.github.io/aws-sdk-go-v2/docs/configuring-sdk cfg, err := config.LoadDefaultConfig(ctx, config.WithRegion("us-east-2")) if err != nil { fmt.Printf("糟糕,无法找到 AWS 会话凭证: %v", err) return } // 使用 AWS 会话实例化一个新的选择器实例 instanceSelector, err := selector.New(ctx, cfg) if err != nil { fmt.Printf("糟糕,出错了 :( %v", err) return } // 实例化一个整数范围过滤器来指定最小和最大 vCPU vcpusRange := selector.Int32RangeFilter{ LowerBound: 2, UpperBound: 4, } // 实例化一个字节数量范围过滤器来指定最小和最大内存 (以 GiB 为单位) memoryRange := selector.ByteQuantityRangeFilter{ LowerBound: bytequantity.FromGiB(2), UpperBound: bytequantity.FromGiB(4), } // 创建一个 CPU 架构变量,以便在创建 Filter 结构时可以作为指针传递 cpuArch := ec2types.ArchitectureTypeX8664 // 创建一个包含您想要过滤的条件的 Filter 结构 // 所有支持的过滤器的完整结构定义可以在这里找到: // https://github.com/aws/amazon-ec2-instance-selector/blob/main/pkg/selector/types.go filters := selector.Filters{ VCpusRange: &vcpusRange, MemoryRange: &memoryRange, CPUArchitecture: &cpuArch, } // 将 Filter 结构传递给选择器实例的 Filter 函数 instanceTypesSlice, err := instanceSelector.Filter(ctx, filters) if err != nil { fmt.Printf("糟糕,出错了 :( %v", err) return } // 打印返回的实例类型切片 fmt.Println(instanceTypesSlice) }

执行示例:

注意: 请确保您已设置 AWS 凭证

$ git clone https://github.com/aws/amazon-ec2-instance-selector.git $ cd amazon-ec2-instance-selector/ $ go run cmd/examples/example1.go [c4.large c5.large c5a.large c5ad.large c5d.large c6i.large t2.medium t3.medium t3.small t3a.medium t3a.small]

构建

有关构建说明,请参阅 BUILD.md

交流

如果您遇到了 bug 或有新功能请求,请开启一个问题

查看开源的 Amazon EC2 Spot 实例集成路线图,了解我们正在进行的工作并给我们反馈!

贡献

欢迎贡献!请阅读我们的指南行为准则

许可证

本项目采用 Apache-2.0 许可证。

编辑推荐精选

TRAE编程

TRAE编程

AI辅助编程,代码自动修复

Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。

AI工具TraeAI IDE协作生产力转型热门
蛙蛙写作

蛙蛙写作

AI小说写作助手,一站式润色、改写、扩写

蛙蛙写作—国内先进的AI写作平台,涵盖小说、学术、社交媒体等多场景。提供续写、改写、润色等功能,助力创作者高效优化写作流程。界面简洁,功能全面,适合各类写作者提升内容品质和工作效率。

AI辅助写作AI工具蛙蛙写作AI写作工具学术助手办公助手营销助手AI助手
问小白

问小白

全能AI智能助手,随时解答生活与工作的多样问题

问小白,由元石科技研发的AI智能助手,快速准确地解答各种生活和工作问题,包括但不限于搜索、规划和社交互动,帮助用户在日常生活中提高效率,轻松管理个人事务。

热门AI助手AI对话AI工具聊天机器人
Transly

Transly

实时语音翻译/同声传译工具

Transly是一个多场景的AI大语言模型驱动的同声传译、专业翻译助手,它拥有超精准的音频识别翻译能力,几乎零延迟的使用体验和支持多国语言可以让你带它走遍全球,无论你是留学生、商务人士、韩剧美剧爱好者,还是出国游玩、多国会议、跨国追星等等,都可以满足你所有需要同传的场景需求,线上线下通用,扫除语言障碍,让全世界的语言交流不再有国界。

讯飞智文

讯飞智文

一键生成PPT和Word,让学习生活更轻松

讯飞智文是一个利用 AI 技术的项目,能够帮助用户生成 PPT 以及各类文档。无论是商业领域的市场分析报告、年度目标制定,还是学生群体的职业生涯规划、实习避坑指南,亦或是活动策划、旅游攻略等内容,它都能提供支持,帮助用户精准表达,轻松呈现各种信息。

AI办公办公工具AI工具讯飞智文AI在线生成PPTAI撰写助手多语种文档生成AI自动配图热门
讯飞星火

讯飞星火

深度推理能力全新升级,全面对标OpenAI o1

科大讯飞的星火大模型,支持语言理解、知识问答和文本创作等多功能,适用于多种文件和业务场景,提升办公和日常生活的效率。讯飞星火是一个提供丰富智能服务的平台,涵盖科技资讯、图像创作、写作辅助、编程解答、科研文献解读等功能,能为不同需求的用户提供便捷高效的帮助,助力用户轻松获取信息、解决问题,满足多样化使用场景。

热门AI开发模型训练AI工具讯飞星火大模型智能问答内容创作多语种支持智慧生活
Spark-TTS

Spark-TTS

一种基于大语言模型的高效单流解耦语音令牌文本到语音合成模型

Spark-TTS 是一个基于 PyTorch 的开源文本到语音合成项目,由多个知名机构联合参与。该项目提供了高效的 LLM(大语言模型)驱动的语音合成方案,支持语音克隆和语音创建功能,可通过命令行界面(CLI)和 Web UI 两种方式使用。用户可以根据需求调整语音的性别、音高、速度等参数,生成高质量的语音。该项目适用于多种场景,如有声读物制作、智能语音助手开发等。

咔片PPT

咔片PPT

AI助力,做PPT更简单!

咔片是一款轻量化在线演示设计工具,借助 AI 技术,实现从内容生成到智能设计的一站式 PPT 制作服务。支持多种文档格式导入生成 PPT,提供海量模板、智能美化、素材替换等功能,适用于销售、教师、学生等各类人群,能高效制作出高品质 PPT,满足不同场景演示需求。

讯飞绘文

讯飞绘文

选题、配图、成文,一站式创作,让内容运营更高效

讯飞绘文,一个AI集成平台,支持写作、选题、配图、排版和发布。高效生成适用于各类媒体的定制内容,加速品牌传播,提升内容营销效果。

热门AI辅助写作AI工具讯飞绘文内容运营AI创作个性化文章多平台分发AI助手
材料星

材料星

专业的AI公文写作平台,公文写作神器

AI 材料星,专业的 AI 公文写作辅助平台,为体制内工作人员提供高效的公文写作解决方案。拥有海量公文文库、9 大核心 AI 功能,支持 30 + 文稿类型生成,助力快速完成领导讲话、工作总结、述职报告等材料,提升办公效率,是体制打工人的得力写作神器。

下拉加载更多