amazon web services - Error "TargetNotConnected" when attempting to start an SSM session with IoT device using

I'm working with AWS Systems Manager (SSM) to remotely connect to an IoT device via SSH using a Py

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条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信