I'm working with AWS Systems Manager (SSM) to remotely connect to an IoT device via SSH using a Python script. The script uses the boto3 library to start an SSM session, but I'm encountering an error every time I try to execute it.
The error message is:
An error occurred (TargetNotConnected) when calling the StartSession operation: mi-xxxxxxxxxxxxx is not connected.
Here is a breakdown of the situation:
IoT device: I'm trying to connect to an IoT device identified as mi-043b90cebb70a46d5. Script: The script uses the aws ssm start-session command to establish a session with the device via SSM. Error: When the script attempts to start the session, it fails with the error message mentioned above. Here’s the section of my script that runs the aws ssm start-session command:
args = ["aws", "ssm", "start-session", "--target", node_id]
if program:
[args.append(arg) for arg in ['--document-name', 'AWS-StartSSHSession', '--parameters', f"portNumber={port}"]]
try:
p = subprocess.run(args, stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr)
except Exception as e:
print(f"Error: {e}")
Things I've checked so far: IAM Role Permissions: The IoT device has the correct IAM role attached, with the AmazonSSMManagedInstanceCore policy. SSM Agent: The IoT device is registered with SSM, but I cannot verify the connection status of the device.
It used to work and then suddenly I get the error described above. I’ve seen some references online to this error indicating that the device might not be connected to the SSM service, but I’m not sure how to resolve this issue.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744939456a4602233.html
评论列表(0条)