简体   繁体   中英

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
                )

Above is the code . the issue is in get_command_invocation its is not passing as varibale but passing as string and throing below error

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:  

but if i separately print command_id and instance they are actually printing the actual id.

What will the solution for this?

I found the solution just set sleep/wait into the code . time.sleep(10) into the code resolved the issue

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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