Ruby aws-sdk describe-instance-status 仅适用于具有事件的实例
Ruby aws-sdk describe-instance-status only for instances with events
我想用ruby aws-sdk client function Aws::EC2::Client.describe-instance-status
to only return a list of instances with Scheduled Events。这是我目前的尝试:
ec2 = Aws::EC2::Client.new(
region: ENV['REGION'],
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
)
ec2_events = ec2.describe_instance_status({
dry_run: false,
filters: [
{
name: "events",
values: ["event.description"],
},
],
})
这是我得到的错误消息:
/Users/myusername/.gems/gems/aws-sdk-core-2.5.11/lib/seahorse/client/plugins/raise_response_errors.rb:15:in `call': The filter 'events' is invalid (Aws::EC2::Errors::InvalidParameterValue)
from /Users/myusername/.gems/gems/aws-sdk-core-2.5.11/lib/aws-sdk-core/plugins/param_converter.rb:20:in `call'
from /Users/myusername/.gems/gems/aws-sdk-core-2.5.11/lib/aws-sdk-core/plugins/response_paging.rb:26:in `call'
from /Users/myusername/.gems/gems/aws-sdk-core-2.5.11/lib/seahorse/client/plugins/response_target.rb:21:in `call'
from /Users/myusername/.gems/gems/aws-sdk-core-2.5.11/lib/seahorse/client/request.rb:70:in `send_request'
from /Users/myusername/.gems/gems/aws-sdk-core-2.5.11/lib/seahorse/client/base.rb:207:in `block (2 levels) in define_operation_methods'
from test.rb:30:in `<main>'
是否有一种简单的方法可以让 aws-sdk 仅表扬具有计划事件的实例?我知道常规的 aws cli 工具有这个 ,但我真的想改用 aws-sdk gem。
您在代码中混淆了 Name
和 Values
- 它应该读作
ec2_events = ec2.describe_instance_status({
dry_run: false,
filters: [
{
name: "event.description",
values: ["events"],
},
],
})
您可以查看完整文档http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeInstanceStatus.html
过滤器(Name
)可能的值为
availability-zone
- 实例的可用区。
event.code
- 计划事件的代码(instance-reboot | system-reboot | system-maintenance | instance-retirement | instance-stop)。
event.description
- 事件描述。
event.not-after
- 预定事件的最晚结束时间(例如,2014-09-15T17:15:20.000Z)。
event.not-before
- 预定事件的最早开始时间(例如,2014-09-15T17:15:20.000Z)。
instance-state-code
- 实例状态的代码,作为 16 位无符号整数。高字节是一个不透明的内部值,应该被忽略。低字节根据表示的状态设置。有效值为 0(待定)、16(运行)、32(正在关闭)、48(已终止)、64(正在停止)和 80(已停止)。
instance-state-name
- 实例的状态(待定 | 运行 | 正在关闭 | 已终止 | 正在停止 | 已停止)。
instance-status.reachability
- 根据名称为 reachability 的实例状态进行过滤(通过 | 失败 | 正在初始化 | 数据不足)。
instance-status.status
- 实例的状态(正常 | 受损 | 初始化 | 数据不足 | 不适用)。
system-status.reachability
- 根据名称为 reachability 的系统状态进行过滤(通过 | 失败 | 正在初始化 | 数据不足)。
system-status.status
- 实例的系统状态(ok | impaired | initializing | insufficient-data | not-applicable)。
我想用ruby aws-sdk client function Aws::EC2::Client.describe-instance-status
to only return a list of instances with Scheduled Events。这是我目前的尝试:
ec2 = Aws::EC2::Client.new(
region: ENV['REGION'],
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
)
ec2_events = ec2.describe_instance_status({
dry_run: false,
filters: [
{
name: "events",
values: ["event.description"],
},
],
})
这是我得到的错误消息:
/Users/myusername/.gems/gems/aws-sdk-core-2.5.11/lib/seahorse/client/plugins/raise_response_errors.rb:15:in `call': The filter 'events' is invalid (Aws::EC2::Errors::InvalidParameterValue)
from /Users/myusername/.gems/gems/aws-sdk-core-2.5.11/lib/aws-sdk-core/plugins/param_converter.rb:20:in `call'
from /Users/myusername/.gems/gems/aws-sdk-core-2.5.11/lib/aws-sdk-core/plugins/response_paging.rb:26:in `call'
from /Users/myusername/.gems/gems/aws-sdk-core-2.5.11/lib/seahorse/client/plugins/response_target.rb:21:in `call'
from /Users/myusername/.gems/gems/aws-sdk-core-2.5.11/lib/seahorse/client/request.rb:70:in `send_request'
from /Users/myusername/.gems/gems/aws-sdk-core-2.5.11/lib/seahorse/client/base.rb:207:in `block (2 levels) in define_operation_methods'
from test.rb:30:in `<main>'
是否有一种简单的方法可以让 aws-sdk 仅表扬具有计划事件的实例?我知道常规的 aws cli 工具有这个
您在代码中混淆了 Name
和 Values
- 它应该读作
ec2_events = ec2.describe_instance_status({
dry_run: false,
filters: [
{
name: "event.description",
values: ["events"],
},
],
})
您可以查看完整文档http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeInstanceStatus.html
过滤器(Name
)可能的值为
availability-zone
- 实例的可用区。event.code
- 计划事件的代码(instance-reboot | system-reboot | system-maintenance | instance-retirement | instance-stop)。event.description
- 事件描述。event.not-after
- 预定事件的最晚结束时间(例如,2014-09-15T17:15:20.000Z)。event.not-before
- 预定事件的最早开始时间(例如,2014-09-15T17:15:20.000Z)。instance-state-code
- 实例状态的代码,作为 16 位无符号整数。高字节是一个不透明的内部值,应该被忽略。低字节根据表示的状态设置。有效值为 0(待定)、16(运行)、32(正在关闭)、48(已终止)、64(正在停止)和 80(已停止)。instance-state-name
- 实例的状态(待定 | 运行 | 正在关闭 | 已终止 | 正在停止 | 已停止)。instance-status.reachability
- 根据名称为 reachability 的实例状态进行过滤(通过 | 失败 | 正在初始化 | 数据不足)。instance-status.status
- 实例的状态(正常 | 受损 | 初始化 | 数据不足 | 不适用)。system-status.reachability
- 根据名称为 reachability 的系统状态进行过滤(通过 | 失败 | 正在初始化 | 数据不足)。system-status.status
- 实例的系统状态(ok | impaired | initializing | insufficient-data | not-applicable)。