Documentation
¶
Overview ¶
Package awsprofile checks whether a named AWS profile is defined in either a context-scoped .aws/ directory or the operator's ambient AWS config. Callers use the result to decide whether emitting AWS_PROFILE is safe — pinning a profile that doesn't exist in the file the SDK will read causes a hard "profile not found" error that masks ambient env-var or IMDS credentials.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WarnOnProfileMismatch ¶ added in v0.9.1
WarnOnProfileMismatch writes a non-fatal warning to w when expected is not defined in r's files but at least one other profile is — the "configured under the wrong name" case HasProfile alone can't distinguish from "nothing configured yet." Silent when expected is present (nothing to warn about) or when no profile is defined at all (unconfigured, not mismatched).
Types ¶
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver carries the AWS config and credentials file paths a single profile lookup should read against. Construct via ForContext or Ambient.
func Ambient ¶
func Ambient() Resolver
Ambient resolves to the file paths the AWS SDK reads when windsor does not redirect them — AWS_CONFIG_FILE / AWS_SHARED_CREDENTIALS_FILE if the operator set them, else ~/.aws/config and ~/.aws/credentials. Any path that cannot be resolved (no env override and no home dir) stays empty — HasProfile treats empty paths as "no match".
func ForContext ¶
ForContext scopes lookups to <configRoot>/.aws/config and .aws/credentials. Used in project mode where windsor owns the context's .aws/ directory.
func (Resolver) HasProfile ¶
HasProfile reports whether the named profile is defined in either of the resolver's files. The AWS SDK treats a profile found in either file as satisfying the lookup, so a single match is enough. Section headers are expected as "[profile <name>]" in the config file (or "[default]" for the default profile) and "[<name>]" in the credentials file.
func (Resolver) ListProfileNames ¶ added in v0.9.1
ListProfileNames returns every profile name defined across the resolver's config and credentials files, deduplicated, in the order first encountered (config file scanned before credentials). Used for diagnostics when an expected profile isn't found, so the caller can name what's actually configured instead of just "not found" — e.g. a bare `aws configure sso` (without --profile) names the profile after the SSO role/account rather than the windsor context, which HasProfile alone can't distinguish from "nothing configured at all."