Documentation
¶
Overview ¶
Package aws provides AWS EC2 instance discovery and display functions.
Index ¶
- func BuildFilters(flagFilters []string, positionalArgs []string) []types.Filter
- func GetInstances(c context.Context, api EC2DescribeInstancesAPI, ...) (*ec2.DescribeInstancesOutput, error)
- func GetValue(key string, tags []types.Tag) string
- func LaunchSession(opts LaunchOpts) error
- func ListInstances(result *ec2.DescribeInstancesOutput, opts DisplayOptions) map[int]InstancePosition
- func ParseAWSProfiles() ([]string, error)
- func PromptProfile(scanner *bufio.Scanner) (string, error)
- func PromptUser(scanner *bufio.Scanner, max int) (int, error)
- func SafeString(s *string, fallback string) string
- type DisplayOptions
- type EC2DescribeInstancesAPI
- type InstanceInfo
- type InstancePosition
- type LaunchOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildFilters ¶
BuildFilters creates the EC2 filter list from flag filters and positional arguments. It always includes a filter for running instances.
func GetInstances ¶
func GetInstances(c context.Context, api EC2DescribeInstancesAPI, input *ec2.DescribeInstancesInput) (*ec2.DescribeInstancesOutput, error)
GetInstances retrieves information about Amazon EC2 instances.
func GetValue ¶
GetValue returns the value of a tag by key (case-insensitive). Returns an empty string if the key is not found or the tags slice is empty.
func LaunchSession ¶
func LaunchSession(opts LaunchOpts) error
LaunchSession executes the aws ssm start-session command for the given instance. It supports both shell and port-forward session types.
func ListInstances ¶
func ListInstances(result *ec2.DescribeInstancesOutput, opts DisplayOptions) map[int]InstancePosition
ListInstances prints the instance list using tabwriter and returns the position map.
func ParseAWSProfiles ¶
ParseAWSProfiles reads ~/.aws/config and returns a list of profile names.
func PromptProfile ¶
PromptProfile displays available AWS profiles and lets the user pick one.
func PromptUser ¶
PromptUser asks the user to select an instance number. Returns the chosen number.
func SafeString ¶
SafeString dereferences a string pointer, returning a fallback if nil.
Types ¶
type DisplayOptions ¶
DisplayOptions controls which optional columns are shown in the instance listing.
type EC2DescribeInstancesAPI ¶
type EC2DescribeInstancesAPI interface {
DescribeInstances(ctx context.Context,
params *ec2.DescribeInstancesInput,
optFns ...func(*ec2.Options)) (*ec2.DescribeInstancesOutput, error)
}
EC2DescribeInstancesAPI defines the interface for the DescribeInstances function. We use this interface to test the function using a mocked service.
type InstanceInfo ¶
type InstanceInfo struct {
InstanceID string
InstanceName string
State string
InstanceType string
PrivateIP string
AZ string
}
InstanceInfo holds structured EC2 instance data for the web dashboard.
func ExtractInstances ¶
func ExtractInstances(output *ec2.DescribeInstancesOutput) []InstanceInfo
ExtractInstances parses DescribeInstancesOutput into a slice of InstanceInfo.