переменная aws boto pass - PullRequest
0 голосов
/ 12 июня 2018
ssm = boto3.client('ssm' )
            instance = 'i-123123'
            response = ssm.send_command( InstanceIds=[ instance ], DocumentName='AWS-RunShellScript', Comment='slack testing', Parameters={ "commands":[ "hostname" ]  } )
            command_id = response['Command']['CommandId']
            command_id.encode("utf-8")
            output = ssm.get_command_invocation(
                CommandId=command_id,
                InstanceId=instance
                )

Над кодом.проблема в get_command_invocation, она не передается как переменная, а передается как строка и обрабатывается ниже ошибки

An error occurred (InvocationDoesNotExist) when calling the GetCommandInvocation operation: : InvocationDoesNotExist
Traceback (most recent call last):
File "/var/task/lambda_function.py", line 137, in lambda_handler
InstanceId=instance
File "/var/runtime/botocore/client.py", line 314, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/var/runtime/botocore/client.py", line 612, in _make_api_call
raise error_class(parsed_response, operation_name)
InvocationDoesNotExist: An error occurred (InvocationDoesNotExist) when calling the GetCommandInvocation operation:  

, но если я отдельно печатаю command_id и экземпляр, они фактически печатают фактический идентификатор.

Каким будет решение для этого?

1 Ответ

0 голосов
/ 15 июня 2018

Я нашел решение, просто установив режим сна / ожидания в код.time.sleep (10) в коде решил проблему

...