1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
"""
AWS SSM Bridge - Python bindings for AWS Systems Manager Session Manager protocol.
This package provides a high-level Python interface to the aws-ssm-bridge Rust library,
enabling secure, high-performance connections to EC2 instances via AWS Systems Manager.
Example (context manager - recommended):
>>> import asyncio
>>> from aws_ssm_bridge import SessionManager
>>>
>>> async def main():
... manager = await SessionManager.new()
... async with await manager.start_session("i-1234567890abcdef0") as session:
... await session.send(b"hostname\\n")
... async for chunk in await session.output():
... print(chunk.decode(), end='')
... # Session automatically terminated
>>>
>>> asyncio.run(main())
Example (manual):
>>> async def main():
... manager = await SessionManager.new()
... session = await manager.start_session("i-1234567890abcdef0")
... try:
... await session.send(b"hostname\\n")
... finally:
... await session.terminate()
Features:
- Full AWS SSM binary protocol implementation
- Async/await API with streaming output
- Async context manager for automatic cleanup
- Automatic retry with exponential backoff
- Secure: zeroized keys, constant-time comparisons
- High performance: Rust core with zero-copy where possible
"""
"""
Convenience function to quickly connect to an instance.
Creates a SessionManager and starts a session in one call.
For multiple sessions, prefer creating a SessionManager directly.
Args:
target: Instance ID to connect to (e.g., 'i-1234567890abcdef0')
region: AWS region (uses default if not specified)
session_type: Type of session ('standard_stream', 'port', etc.)
document_name: SSM document for custom sessions
parameters: Document parameters
reason: Audit reason for session
Returns:
Session: Connected session ready for use
Example:
>>> session = await connect("i-1234567890abcdef0")
>>> await session.send(b"whoami\\n")
>>> await session.terminate()
"""
= await
return await
=