ssmclient

package
v0.200.1-0...-f744ad6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidTargetFormat is the error returned if the target format doesn't match the expected format
	// required by the resolver.
	ErrInvalidTargetFormat = errors.New("invalid target format")
	// ErrNoInstanceFound is the error returned if a resolver was unable to find an instance.
	ErrNoInstanceFound = errors.New("no instances returned from lookup")
)

Functions

func NewDNSResolver

func NewDNSResolver() *dnsResolver

NewDNSResolver is a TargetResolver which knows how to find an EC2 instance using DNS TXT record lookups.

func NewIPResolver

func NewIPResolver(cfg aws.Config) *ipResolver

NewIPResolver is a TargetResolver which knows how to find an EC2 instance using the private IPv4 address.

func NewTagResolver

func NewTagResolver(cfg aws.Config) *tagResolver

NewTagResolver is a TargetResolver which knows how to find an EC2 instance using tags.

func PortForwardingSession

func PortForwardingSession(cfg aws.Config, opts *PortForwardingInput) error

PortForwardingSession starts a port forwarding session using the PortForwardingInput parameters to configure the session. The client.ConfigProvider parameter will be used to call the AWS SSM StartSession API, which is used as part of establishing the websocket communication channel.

func ResolveTarget

func ResolveTarget(target string, cfg aws.Config) (string, error)

ResolveTarget attempts to find the instance ID of the target using a pre-defined resolution order. The first check will see if the target is already in the format of an EC2 instance ID. Next, if the cfg parameter is not nil, checking by EC2 instance tags or private IPv4 IP address is performed. Finally, resolving by DNS TXT record will be attempted.

func ResolveTargetChain

func ResolveTargetChain(target string, resolvers ...TargetResolver) (inst string, err error)

ResolveTargetChain attempts to find the instance ID of the target using the provided list of TargetResolvers. The first check will always be to see if the target is already in the format of an EC2 instance ID before moving on to the resolution logic of the provided TargetResolvers. If a resolver returns an error, the next resolver in the chain is checked. If all resolvers fail to find an instance ID an error is returned.

func SSHSession

func SSHSession(cfg aws.Config, opts *PortForwardingInput) error

SSHSession starts a specialized port forwarding session to allow SSH connectivity to the target instance over the SSM session. It listens for data from Stdin and sends output to Stdout. Like a port forwarding session, use a PortForwardingInput type to configure the session properties. Any LocalPort information is ignored, and if no RemotePort is specified, the default SSH port (22) will be used. The client.ConfigProvider parameter is used to call the AWS SSM StartSession API, which is used as part of establishing the websocket communication channel.

func ShellSession

func ShellSession(cfg aws.Config, target string) error

ShellSession starts a shell session with the instance specified in the target parameter. The client.ConfigProvider parameter will be used to call the AWS SSM StartSession API, which is used as part of establishing the websocket communication channel.

Types

type PortForwardingInput

type PortForwardingInput struct {
	Target     string
	RemotePort int
	LocalPort  int
}

PortForwardingInput configures the port forwarding session parameters. Target is the EC2 instance ID to establish the session with. RemotePort is the port on the EC2 instance to connect to. LocalPort is the port on the local host to listen to. If not provided, a random port will be used.

type TargetResolver

type TargetResolver interface {
	Resolve(string) (string, error)
}

TargetResolver is the interface specification for something which knows how to resolve and EC2 instance identifier.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL