1

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 ?

3
  • 1
    I think invocation does not appear immediately. Have you tried to wait a bit before executing get_command_invocation? Commented Jul 15, 2020 at 2:18
  • 1
    @Marcin wow. yeah. never thought about that at all....do you mind making this as answer that I can accept ? Commented Jul 15, 2020 at 17:20
  • Thanks. Answer added :-) Commented Jul 15, 2020 at 21:46

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.