Documentation ¶
Index ¶
- Variables
- func NewDNSResolver() *dnsResolver
- func NewIPResolver(cfg client.ConfigProvider) *ipResolver
- func NewTagResolver(cfg client.ConfigProvider) *tagResolver
- func PortForwardingSession(cfg client.ConfigProvider, opts *PortForwardingInput) error
- func ResolveTarget(target string, cfg client.ConfigProvider) (string, error)
- func ResolveTargetChain(target string, resolvers ...TargetResolver) (string, error)
- func ShellSession(cfg client.ConfigProvider, target string) error
- func SshSession(cfg client.ConfigProvider, opts *PortForwardingInput) error
- type PortForwardingInput
- type TargetResolver
Constants ¶
This section is empty.
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 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 client.ConfigProvider) *ipResolver
NewIPResolver is a TargetResolver which knows how to find an EC2 instance using the private IPv4 address
func NewTagResolver ¶
func NewTagResolver(cfg client.ConfigProvider) *tagResolver
NewTagResolver is a TargetResolver which knows how to find an EC2 instance using tags.
func PortForwardingSession ¶
func PortForwardingSession(cfg client.ConfigProvider, 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 client.ConfigProvider) (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) (string, 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 ShellSession ¶
func ShellSession(cfg client.ConfigProvider, 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.
func SshSession ¶
func SshSession(cfg client.ConfigProvider, 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.
Types ¶
type PortForwardingInput ¶
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 ¶
TargetResolver is the interface specification for something which knows how to resolve and EC2 instance identifier