awsconfig

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProfileName = "localstack"
)

Variables

View Source
var ErrNoCredentials = errors.New("AWS credentials not found in environment")

ErrNoCredentials is returned by CredentialsFromEnv when the required AWS credential environment variables are not set.

Functions

func CheckProfileStatus added in v0.5.6

func CheckProfileStatus(resolvedHost string) (profileStatus, error)

CheckProfileStatus determines which AWS profile files need to be written or updated.

func EnsureProfile added in v0.5.6

func EnsureProfile(ctx context.Context, sink output.Sink, interactive bool, resolvedHost string) error

EnsureProfile checks for the LocalStack AWS profile and either emits a note when it is incomplete or triggers the interactive setup flow. resolvedHost must be a host:port string (e.g. "localhost.localstack.cloud:4566").

func ProfileExists added in v0.5.8

func ProfileExists(ctx context.Context) (bool, error)

ProfileExists reports whether the localstack profile section is present in both ~/.aws/config and ~/.aws/credentials.

func ResolveProfileHost added in v0.15.0

func ResolveProfileHost(ctx context.Context, containers []config.ContainerConfig, localStackHost string) (resolvedHost string, dnsOK bool, err error)

ResolveProfileHost finds the configured AWS emulator container and resolves its host:port endpoint, reporting whether DNS resolution succeeded. It is shared by the interactive and non-interactive setup paths so both resolve identically.

func Setup

func Setup(ctx context.Context, sink output.Sink, resolvedHost string, status profileStatus, skipConfirm, explicit bool) error

Setup checks for the localstack AWS profile and prompts to create or update it if needed. resolvedHost must be a host:port string (e.g. "localhost.localstack.cloud:4566"). status is passed in from EnsureProfile to avoid re-checking the profile status.

When skipConfirm is true the confirmation prompt is bypassed and the profile is written directly.

explicit is true for the user-invoked `lstk setup aws` command, where writing the profile is the command's whole purpose, so a write failure must surface a non-zero exit. It is false for the best-effort post-start convenience flow (EnsureProfile during `lstk start`), where a write failure must only warn and must not abort an already-running emulator.

func SetupNonInteractive added in v0.15.0

func SetupNonInteractive(ctx context.Context, sink output.Sink, resolvedHost string, force bool) error

SetupNonInteractive writes the LocalStack AWS profile without prompting, for CI, piped, or --non-interactive use. A fresh profile (or completing a partial one) is written automatically; overwriting an existing profile whose values differ requires force. Unlike the interactive Setup, write and check failures are returned as errors so the caller exits non-zero.

Types

type Credentials added in v0.15.0

type Credentials struct {
	AccessKeyID     string
	SecretAccessKey string
	SessionToken    string
}

Credentials holds static AWS credentials read from the environment or a profile. SessionToken is optional.

func CredentialsFromEnv added in v0.15.0

func CredentialsFromEnv() (Credentials, error)

CredentialsFromEnv reads credentials from AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and the optional AWS_SESSION_TOKEN. It returns ErrNoCredentials when either of the two required variables is unset.

func ReadProfileCredentials added in v0.15.0

func ReadProfileCredentials(profile string) (Credentials, error)

ReadProfileCredentials resolves AWS credentials for the named profile from the shared credentials file (~/.aws/credentials, section "[<profile>]"), falling back to the config file (~/.aws/config, section "[profile <profile>]", or "[default]" for the default profile). It honors AWS_SHARED_CREDENTIALS_FILE and AWS_CONFIG_FILE.

Jump to

Keyboard shortcuts

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