Skip to main content

Crate aws_ssm_bridge

Crate aws_ssm_bridge 

Source
Expand description

A Rust implementation of the AWS Systems Manager Session Manager protocol.

The official session-manager-plugin is a CLI binary. This is a library: open sessions, stream bytes, and forward ports from inside your own async application, with no subprocess and no plugin to install.

use aws_ssm_bridge::SessionBuilder;
use futures_util::StreamExt;

let session = SessionBuilder::new("i-0123456789abcdef0").start().await?;
session.wait_ready().await?;

let mut output = session.output();
session.send(&b"uname -a\r"[..]).await?;

while let Some(chunk) = output.next().await {
    print!("{}", String::from_utf8_lossy(&chunk));
}
session.terminate().await?;

§What you get

CapabilityWhere
Shell and command sessionsSession, documents
TCP port forwarding (smux-multiplexed)PortForwarder
End-to-end KMS session encryptioncrypto (feature kms)
Interactive terminalInteractiveShell (feature interactive)
Automatic reconnectionReconnectingSession
Many concurrent sessionsSessionPool
Metrics hooksmetrics

§Session lifetime

A Session is either running or closed, and every way it can end — terminate, the agent hanging up, a dead network, a protocol violation — resolves Session::closed and records a CloseReason. Build on that signal rather than polling:

tokio::select! {
    () = session.closed() => {
        eprintln!("session ended: {}", session.close_reason().unwrap());
    }
    _ = do_work(&session) => {}
}

§Ordering and delivery

The protocol layer handles sequencing, acknowledgement, retransmission and reordering, so Session::send and Session::output behave like an ordered, lossless byte stream. Message boundaries are an artefact of chunking and carry no meaning.

§Feature flags

FeatureDefaultEffect
interactiveyesterminal and InteractiveShell; pulls in crossterm
kmsyesKMS session encryption; pulls in aws-sdk-kms and aes-gcm
pythonnoPyO3 bindings
extension-modulenoLink the bindings as a Python extension module; set by maturin

Without kms, a session whose account requires encrypted sessions fails the handshake with an explicit error rather than downgrading to plaintext.

extension-module is separate from python because it leaves the CPython symbols for the interpreter to resolve at load time: correct for a wheel, fatal for a test binary. --all-features therefore does not link; name the features you want.

§Not affiliated with AWS

This is an independent implementation, not endorsed by or sponsored by Amazon Web Services, Inc.

Re-exports§

pub use builder::SessionBuilder;
pub use documents::SessionType;
pub use documents::SsmDocument;
pub use errors::Error;
pub use errors::Result;
pub use metrics::MetricsRecorder;
pub use mux::SmuxConfig;
pub use mux::SmuxSession;
pub use mux::SmuxStream;
pub use pool::PoolConfig;
pub use pool::PoolStats;
pub use pool::SessionPool;
pub use port_forward::PortForwardConfig;
pub use port_forward::PortForwarder;
pub use reconnect::ReconnectConfig;
pub use reconnect::ReconnectEvent;
pub use reconnect::ReconnectingSession;
pub use session::CloseReason;
pub use session::DocumentSpec;
pub use session::Session;
pub use session::SessionConfig;
pub use session::SessionManager;
pub use shutdown::install_signal_handlers;
pub use shutdown::ShutdownSignal;
pub use interactive::InteractiveConfig;
pub use interactive::InteractiveShell;
pub use terminal::TerminalSize;

Modules§

ack
Reliable delivery: acknowledgements, retransmission and RTT estimation.
binary_protocol
The AWS SSM Session Manager binary wire format.
builder
Fluent construction of sessions.
crypto
KMS session encryption (AES-256-GCM).
documents
Typed wrappers for the AWS-managed Session Manager documents.
errors
Error types for aws-ssm-bridge.
handshake
The SSM agent handshake.
interactive
A complete interactive shell, terminal and all.
metrics
Optional metrics hooks.
mux
smux v1 stream multiplexing over one SSM data channel.
pool
Managing many concurrent sessions.
port_forward
Local TCP port forwarding over an SSM session.
reconnect
A session that rebuilds itself when the connection drops.
session
Session lifecycle: starting, using and ending an SSM session.
shutdown
Cooperative cancellation for long-running session work.
terminal
Terminal plumbing for interactive sessions.

Structs§

OutputStream
A borrowed view of the session’s output stream.

Enums§

EndpointPolicy
Which WebSocket endpoints the client is willing to connect to.

Constants§

VERSION
The version of this crate.