awscli

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const InstallURL = "https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html"

Variables

View Source
var ErrCompleterNotFound = errors.New("aws_completer not found")
View Source
var ErrNotInstalled = errors.New("aws CLI not found in PATH")

Functions

func BuildEnv

func BuildEnv(base []string, account string) []string

BuildEnv seeds LocalStack-compatible credentials and region for a child aws CLI invocation that resolves no profile. A non-empty account overrides AWS_ACCESS_KEY_ID outright, since LocalStack derives the account from it; an empty account keeps the set-if-absent mock default. The secret and region are only defaults, so an explicit user value continues to win.

An ambient AWS_SESSION_TOKEN is dropped either way: lstk supplies the credentials itself, a token from an unrelated session cannot correspond to them, and the endpoint is always LocalStack. This matches the stripping the terraform and sam proxies already perform.

func CheckInstalled added in v0.13.0

func CheckInstalled() error

func Complete added in v0.21.0

func Complete(ctx context.Context, args []string, toComplete string) ([]string, error)

Complete returns the aws CLI's own completion candidates for `aws <args...> <toComplete>`, where toComplete is the partial word under the cursor (empty when the cursor sits after a space).

Bounding how long a Tab press may block is the caller's call: pass a ctx with a deadline.

func CompleterPath added in v0.21.0

func CompleterPath() (string, error)

CompleterPath resolves the aws_completer binary. It is usually on PATH alongside aws, but some installs expose only aws, so fall back to a sibling of the (symlink-resolved) aws binary: the v2 installer puts /usr/local/bin/aws there as a symlink into an install dir that also holds aws_completer.

func Exec

func Exec(ctx context.Context, opts ExecOptions, stdout, stderr io.Writer, args []string) error

Exec runs `aws <args...>` against opts.EndpointURL. When opts.UsePTY is true (lstk's stdout and stderr are both terminals), the child's output goes through a pseudo-terminal merged into stdout — see proc.RunInPTY for why; otherwise stdout/stderr are wired as given.

func IsHelp added in v0.18.0

func IsHelp(args []string) bool

IsHelp reports whether args requests the aws CLI's help output. The aws CLI answers this without needing a running emulator or resolved endpoint.

Types

type ExecOptions added in v0.22.0

type ExecOptions struct {
	// EndpointURL is injected as --endpoint-url. Empty skips it (the help path).
	EndpointURL string
	// Account is the resolved LocalStack account, written to AWS_ACCESS_KEY_ID
	// wherever lstk supplies credentials. LocalStack derives the account from
	// the access key id it receives.
	Account string
	// UseProfile selects the localstack AWS profile. See execEnv for why this
	// happens through AWS_PROFILE rather than a --profile argument.
	UseProfile bool
	// AccountSelected reports that the user explicitly asked for Account (via
	// --account, or a 12-digit AWS_ACCESS_KEY_ID) rather than it being the
	// default. It only matters alongside UseProfile, where it decides whether
	// the environment or the profile supplies credentials.
	AccountSelected bool
	// UsePTY runs the child under a pseudo-terminal.
	UsePTY bool
}

ExecOptions configures a single `aws` invocation.

Jump to

Keyboard shortcuts

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