Documentation
¶
Index ¶
- Constants
- Variables
- func PluginSession(cfg aws.Config, input *ssm.StartSessionInput) error
- func PortForwardingSession(cfg aws.Config, opts *PortForwardingInput) error
- func PortPluginSession(cfg aws.Config, opts *PortForwardingInput) error
- func ResolveTarget(target string, cfg aws.Config) (string, error)
- func ResolveTargetChain(target string, resolvers ...TargetResolver) (inst string, err error)
- func SSHPluginSession(cfg aws.Config, opts *PortForwardingInput) error
- func SSHSession(cfg aws.Config, opts *PortForwardingInput) error
- func ShellPluginSession(cfg aws.Config, target string) error
- func ShellSession(cfg aws.Config, target string, initCmd ...io.Reader) error
- type DNSResolver
- type EC2Resolver
- type IPResolver
- type PortForwardingInput
- type TagResolver
- type TargetResolver
Constants ¶
const (
ResizeSleepInterval = time.Millisecond * 500
)
Variables ¶
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 PluginSession ¶
func PluginSession(cfg aws.Config, input *ssm.StartSessionInput) error
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 aws.Config parameter will be used to call the AWS SSM StartSession API, which is used as part of establishing the websocket communication channel.
func PortPluginSession ¶
func PortPluginSession(cfg aws.Config, opts *PortForwardingInput) error
PortPluginSession delegates the execution of the SSM port forwarding to the AWS-managed session manager plugin code, bypassing this libraries internal websocket code and connection management.
func ResolveTarget ¶
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 SSHPluginSession ¶
func SSHPluginSession(cfg aws.Config, opts *PortForwardingInput) error
SSHPluginSession delegates the execution of the SSM SSH integration to the AWS-managed session manager plugin code, bypassing this libraries internal websocket code and connection management.
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 aws.Config parameter is used to call the AWS SSM StartSession API, which is used as part of establishing the websocket communication channel.
func ShellPluginSession ¶
ShellPluginSession delegates the execution of the SSM shell session to the AWS-managed session manager plugin code, bypassing this libraries internal websocket code and session management.
func ShellSession ¶
ShellSession starts a shell session with the instance specified in the target parameter. The aws.Config parameter will be used to call the AWS SSM StartSession API, which is used as part of establishing the websocket communication channel. A vararg slice of io.Readers can be provided to send data to the instance before handing control of the terminal to the user.
Types ¶
type DNSResolver ¶
type DNSResolver bool
* DNS Resolver attempts to find an instance using a DNS TXT record lookup. The DNS record is expected * to resolve to the EC2 instance ID associated with the DNS name. If the DNS record is not found, or if * there is nothing which looks like an EC2 instance ID in the record data, and error is returned.
func NewDNSResolver ¶
func NewDNSResolver() *DNSResolver
NewDNSResolver is a TargetResolver which knows how to find an EC2 instance using DNS TXT record lookups.
type EC2Resolver ¶
type EC2Resolver struct {
// contains filtered or unexported fields
}
* EC2 Resolver calls the EC2 DescribeInstances API with a provided filter, which will return at most 1 * instance ID. If more than 1 instance matches the filter, the 1st instance ID in the list is returned.
type IPResolver ¶
type IPResolver struct {
*EC2Resolver
}
* IP Resolver attempts to find an instance by its private or public IPv4 address using the EC2 API. * If the target doesn't look like an IPv4 address, a DNS lookup is tried. If neither of those produce * an IPv4 address, or the EC2 instance lookup fails to find an instance, an error is returned. At most, * 1 instance ID is returned; if more than 1 match is found, only the 1st element of the instances list * is returned. The nature of the AWS EC2 API will not guarantee ordering of the instances list.
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.
type PortForwardingInput ¶
type PortForwardingInput struct { Target string RemotePort int LocalPort int Host string // optional }
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 TagResolver ¶
type TagResolver struct {
*EC2Resolver
}
* Tag Resolver attempts to find an instance using instance tags. The expected format is tag_key:tag_value * (ex. hostname:web0). If the target to resolve doesn't look like a a colon-separated tag key:value pair, * or no instance is found, an error is returned. At most, 1 instance ID is returned; if more than 1 match * is found, only the 1st element of the instances list is returned. The nature of the AWS EC2 API will not * guarantee ordering of the instances list.
func NewTagResolver ¶
func NewTagResolver(cfg aws.Config) *TagResolver
NewTagResolver is a TargetResolver which knows how to find an EC2 instance using tags.
type TargetResolver ¶
TargetResolver is the interface specification for something which knows how to resolve and EC2 instance identifier.