amazon-web-servicesaws-sdk-rubyruby-2.5

Ruby : Invocation does not exist


Im working with the aws sdk and want to use the get_command_invocation method. This is what I have in accordance with the docs:

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
    )

Using puts I know for sure that the method is receiving the command_id and the instance_id, both of which exist when i try and view them on the aws console. Yet I keep running into :

(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'

What am i doing wrong ?


Solution

  • Based on the comments.

    The issue was caused by the fact that invocation is not immediately available after executing send_command.

    The solution was to wait a bit before calling get_command_invocation. This could be achieved with a basic while-type loop which will keep pulling for availability of the invocation in a periodic manner, before continuing the normal program flow.