繁体   English   中英

aws boto传递变量

[英]aws boto pass variable

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和instance,它们实际上是在打印实际的ID。

该如何解决?

我发现解决方案只是将sleep / wait设置为代码。 将time.sleep(10)放入代码中解决了该问题

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM