Ruby : 调用不存在
Ruby : Invocation does not exist
我正在使用 aws sdk 并想使用 get_command_invocation method。这是我根据文档得到的:
resp = client.send_command(
instance_ids: [instance_id],
document_name: 'AWS-RunShellScript',
max_concurrency: '1',
max_errors: '1',
timeout_seconds: 60,
parameters:
{ commands:
[command]
}
)
command_id = client.get_command_invocation(
command_id: resp.command.command_id,
instance_id: instance_id
)
使用 puts
我确定该方法正在接收 command_id 和 instance_id,当我尝试在 aws 控制台上查看它们时,它们都存在。但是我将 运行 保留为 :
(Aws::SSM::Errors::InvocationDoesNotExist)
/Users/me/.rvm/gems/ruby-2.5.3/gems/aws-sdk-core-3.103.0/lib/seahorse/client/plugins/raise_response_errors.rb:17:in `call'
/Users/me/.rvm/gems/ruby-2.5.3/gems/aws-sdk-core-3.103.0/lib/aws-sdk-core/plugins/jsonvalue_converter.rb:22:in `call'
/Users/me/.rvm/gems/ruby-2.5.3/gems/aws-sdk-core-3.103.0/lib/aws-sdk-core/plugins/idempotency_token.rb:19:in `call'
/Users/me/.rvm/gems/ruby-2.5.3/gems/aws-sdk-core-3.103.0/lib/aws-sdk-core/plugins/param_converter.rb:26:in `call'
/Users/me/.rvm/gems/ruby-2.5.3/gems/aws-sdk-core-3.103.0/lib/aws-sdk-core/plugins/response_paging.rb:12:in `call'
/Users/me/.rvm/gems/ruby-2.5.3/gems/aws-sdk-core-3.103.0/lib/seahorse/client/plugins/response_target.rb:24:in `call'
/Users/me/.rvm/gems/ruby-2.5.3/gems/aws-sdk-core-3.103.0/lib/seahorse/client/request.rb:72:in `send_request'
/Users/me/.rvm/gems/ruby-2.5.3/gems/aws-sdk-ssm-1.84.0/lib/aws-sdk-ssm/client.rb:4534:in `get_command_invocation'
我做错了什么?
根据评论。
问题是由于 invocation
在执行 send_command
.
后 无法立即使用
解决方案 是在调用 get_command_invocation
之前稍等片刻。这可以通过一个基本的 while-type
循环来实现,该循环将在继续正常的程序流之前以周期性的方式持续拉取调用的可用性。
我正在使用 aws sdk 并想使用 get_command_invocation method。这是我根据文档得到的:
resp = client.send_command(
instance_ids: [instance_id],
document_name: 'AWS-RunShellScript',
max_concurrency: '1',
max_errors: '1',
timeout_seconds: 60,
parameters:
{ commands:
[command]
}
)
command_id = client.get_command_invocation(
command_id: resp.command.command_id,
instance_id: instance_id
)
使用 puts
我确定该方法正在接收 command_id 和 instance_id,当我尝试在 aws 控制台上查看它们时,它们都存在。但是我将 运行 保留为 :
(Aws::SSM::Errors::InvocationDoesNotExist)
/Users/me/.rvm/gems/ruby-2.5.3/gems/aws-sdk-core-3.103.0/lib/seahorse/client/plugins/raise_response_errors.rb:17:in `call'
/Users/me/.rvm/gems/ruby-2.5.3/gems/aws-sdk-core-3.103.0/lib/aws-sdk-core/plugins/jsonvalue_converter.rb:22:in `call'
/Users/me/.rvm/gems/ruby-2.5.3/gems/aws-sdk-core-3.103.0/lib/aws-sdk-core/plugins/idempotency_token.rb:19:in `call'
/Users/me/.rvm/gems/ruby-2.5.3/gems/aws-sdk-core-3.103.0/lib/aws-sdk-core/plugins/param_converter.rb:26:in `call'
/Users/me/.rvm/gems/ruby-2.5.3/gems/aws-sdk-core-3.103.0/lib/aws-sdk-core/plugins/response_paging.rb:12:in `call'
/Users/me/.rvm/gems/ruby-2.5.3/gems/aws-sdk-core-3.103.0/lib/seahorse/client/plugins/response_target.rb:24:in `call'
/Users/me/.rvm/gems/ruby-2.5.3/gems/aws-sdk-core-3.103.0/lib/seahorse/client/request.rb:72:in `send_request'
/Users/me/.rvm/gems/ruby-2.5.3/gems/aws-sdk-ssm-1.84.0/lib/aws-sdk-ssm/client.rb:4534:in `get_command_invocation'
我做错了什么?
根据评论。
问题是由于 invocation
在执行 send_command
.
解决方案 是在调用 get_command_invocation
之前稍等片刻。这可以通过一个基本的 while-type
循环来实现,该循环将在继续正常的程序流之前以周期性的方式持续拉取调用的可用性。