config

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package config handles reading and writing SSO profiles to ~/.aws/config.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CredentialsPath

func CredentialsPath() (string, error)

CredentialsPath returns the path to the AWS credentials file.

func DeleteProfile

func DeleteProfile(name string) error

DeleteProfile removes an SSO profile from the AWS config file.

func LoadProfiles

func LoadProfiles() ([]profile.SSOProfile, error)

LoadProfiles reads all SSO profiles from the AWS config file.

func Path

func Path() (string, error)

Path returns the path to the AWS config file.

func SaveProfile

func SaveProfile(p profile.SSOProfile) error

SaveProfile writes an SSO profile to the AWS config file.

func SaveProfiles

func SaveProfiles(profiles []profile.SSOProfile) error

SaveProfiles writes multiple SSO profiles to the AWS config file in a single read/write cycle. This is much faster than calling SaveProfile in a loop.

func WriteCredentials

func WriteCredentials(profileName, accessKeyID, secretAccessKey, sessionToken string) error

WriteCredentials writes temporary credentials to the AWS credentials file.

func WriteSSOCache

func WriteSSOCache(startURL, region, accessToken string, expiresAt time.Time) error

WriteSSOCache writes an SSO access token to the standard AWS SSO cache. This allows other AWS tools (CLI, SDKs) to use the cached token via AWS_PROFILE.

Types

type SSOToken

type SSOToken struct {
	StartURL    string    `json:"startUrl"`
	Region      string    `json:"region"`
	AccessToken string    `json:"accessToken"`
	ExpiresAt   time.Time `json:"-"` // custom marshal to RFC3339
}

SSOToken represents a cached SSO access token in the standard AWS CLI format. Stored at ~/.aws/sso/cache/{SHA1(startUrl)}.json.

func ReadSSOCache

func ReadSSOCache(startURL string) *SSOToken

ReadSSOCache reads a cached SSO access token for the given start URL. Returns nil if the cache file doesn't exist or the token is expired.

func (SSOToken) MarshalJSON

func (t SSOToken) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler with RFC3339 expiresAt.

func (*SSOToken) UnmarshalJSON

func (t *SSOToken) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler with RFC3339 expiresAt.

Jump to

Keyboard shortcuts

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