aws

package
v0.0.0-...-c0a824d Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package aws provides AWS EC2 instance discovery and display functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildFilters

func BuildFilters(flagFilters []string, positionalArgs []string) []types.Filter

BuildFilters creates the EC2 filter list from flag filters and positional arguments. It always includes a filter for running instances.

func GetInstances

GetInstances retrieves information about Amazon EC2 instances.

func GetValue

func GetValue(key string, tags []types.Tag) string

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

func ParseAWSProfiles() ([]string, error)

ParseAWSProfiles reads ~/.aws/config and returns a list of profile names.

func PromptProfile

func PromptProfile(scanner *bufio.Scanner) (string, error)

PromptProfile displays available AWS profiles and lets the user pick one.

func PromptUser

func PromptUser(scanner *bufio.Scanner, max int) (int, error)

PromptUser asks the user to select an instance number. Returns the chosen number.

func SafeString

func SafeString(s *string, fallback string) string

SafeString dereferences a string pointer, returning a fallback if nil.

Types

type DisplayOptions

type DisplayOptions struct {
	ShowInstanceType     bool
	ShowAvailabilityZone bool
	ShowPrivateIP        bool
}

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.

type InstancePosition

type InstancePosition struct {
	Num              int
	ReservationCount int
	InstanceCount    int
	InstanceID       string
	InstanceName     string
}

InstancePosition holds the display position and identity of an EC2 instance.

type LaunchOpts

type LaunchOpts struct {
	Profile    string
	InstanceID string
	Type       string // "shell" or "port-forward"
	LocalPort  int
	RemotePort int
	RemoteHost string
}

LaunchOpts carries the parameters for launching an SSM session from the CLI.

Jump to

Keyboard shortcuts

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