Documentation
¶
Overview ¶
Package credentials handles fetching and formatting AWS temporary credentials.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatDisplay ¶
func FormatDisplay(creds *AWSCredentials, profileName string) string
FormatDisplay returns a styled string showing credentials in a readable format.
func FormatExportCommands ¶
func FormatExportCommands(creds *AWSCredentials, profileName string) string
FormatExportCommands returns shell export commands for the credentials.
Types ¶
type AWSCredentials ¶
type AWSCredentials struct {
AccessKeyID string
SecretAccessKey string
SessionToken string
Expiration time.Time
}
AWSCredentials holds temporary AWS credentials.
func GetCredentials ¶
func GetCredentials( ctx context.Context, client SSOClient, accessToken string, accountID string, roleName string, ) (*AWSCredentials, error)
GetCredentials fetches temporary AWS credentials for the given account and role.
type DiscoveredAccount ¶
DiscoveredAccount holds account info returned from SSO ListAccounts.
func ListAccounts ¶
func ListAccounts(ctx context.Context, client SSOClient, accessToken string) ([]DiscoveredAccount, error)
ListAccounts discovers all AWS accounts accessible with the given SSO token. It handles pagination automatically, returning all accounts in a single slice.
type DiscoveredRole ¶
DiscoveredRole holds role info returned from SSO ListAccountRoles.
func ListAccountRoles ¶
func ListAccountRoles(ctx context.Context, client SSOClient, accessToken string, accountID string) ([]DiscoveredRole, error)
ListAccountRoles discovers all roles available for the given account. It handles pagination automatically, returning all roles in a single slice.
type SSOClient ¶
type SSOClient interface {
GetRoleCredentials(ctx context.Context, params *sso.GetRoleCredentialsInput, optFns ...func(*sso.Options)) (*sso.GetRoleCredentialsOutput, error)
ListAccounts(ctx context.Context, params *sso.ListAccountsInput, optFns ...func(*sso.Options)) (*sso.ListAccountsOutput, error)
ListAccountRoles(ctx context.Context, params *sso.ListAccountRolesInput, optFns ...func(*sso.Options)) (*sso.ListAccountRolesOutput, error)
}
SSOClient defines the interface for SSO operations (for testability).
func NewSSOClient ¶
NewSSOClient creates a real SSO client for the given region. It loads the default AWS config internally. If you already have a loaded aws.Config, use NewSSOClientFromConfig instead to avoid duplicate loads.
func NewSSOClientFromConfig ¶
NewSSOClientFromConfig creates a real SSO client from a pre-loaded AWS config. It configures adaptive retry mode with up to 10 attempts to handle API rate limiting (HTTP 429) when discovering roles across many accounts.