Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python aws boto pass变量_Python_Amazon Web Services_Boto3_Ssm - Fatal编程技术网

Python aws boto pass变量

Python aws boto pass变量,python,amazon-web-services,boto3,ssm,Python,Amazon Web Services,Boto3,Ssm,上面是代码。问题出在get_命令_调用中,它不是以变量形式传递,而是以字符串形式传递,并在下面传递错误 ssm = boto3.client('ssm' ) instance = 'i-123123' response = ssm.send_command( InstanceIds=[ instance ], DocumentName='AWS-RunShellScript', Comment='slack testing', Parameters

上面是代码。问题出在get_命令_调用中,它不是以变量形式传递,而是以字符串形式传递,并在下面传递错误

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
                )
但是,如果我单独打印command_id和instance,它们实际上是在打印实际的id


这个问题的解决方案是什么?

我发现解决方案只是在代码中设置了sleep/wait。
在代码中使用time.sleep(10)解决了问题

我可能错了,但不应该响应=ssm.send_命令实际上是client.send_命令?ssm=boto3.client('ssm')我将其存储在ssm变量中
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: