awsconfigfile

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2025 License: MIT Imports: 16 Imported by: 0

README

awsconfigfile

A Go package to handle automated updates to ~/.aws/config files.

Documentation

Overview

Package awsconfigfile contains logic to template ~/.aws/config files based on Common Fate access rules.

Index

Constants

This section is empty.

Variables

View Source
var DefaultProfileNameTemplate = "{{ .AccountName }}/{{ .RoleName }}"

Functions

func DefaultSharedConfigFilename

func DefaultSharedConfigFilename() string

DefaultSharedConfigFilename returns the AWS SDK's default file path for the shared config file. It is vendored from the AWS Go SDK v2 to prevent importing the entire module.

Builds the shared config file path based on the OS's platform.

  • Linux/Unix: $HOME/.aws/config
  • Windows: %USERPROFILE%\.aws\config

func Merge

func Merge(opts MergeOpts) error

Types

type AccountProfile

type AccountProfile struct {
	AccountName    string
	SSOSessionName string
	AccountID      string
	RoleName       string
	GeneratedFrom  string
	Region         string
	CommonFateURL  string
	// Legacy format used for credential process
	SSOStartURL string
	SSORegion   string
}

func (*AccountProfile) ToIni

func (a *AccountProfile) ToIni(profileName string, noCredentialProcess bool) any

type Generator

type Generator struct {
	Sources             []Source
	Config              *ini.File
	NoCredentialProcess bool
	ProfileNameTemplate string
	Prefix              string
	// PruneStartURLs is a slice of AWS SSO start URLs which profiles are being generated for.
	// Existing profiles with these start URLs will be removed if they aren't found in the Profiles field.
	PruneStartURLs []string
	SessionName    string
	SSOScopes      []string
	PreferRoles    []string
	Verbose        bool
	DefaultRegion  string
}

Generator generates AWS profiles for ~/.aws/config. It reads profiles from sources and merges them with an existing ini config file.

func (*Generator) AddSource

func (g *Generator) AddSource(source Source)

AddSource adds a new source to load profiles from to the generator.

func (*Generator) Generate

func (g *Generator) Generate(ctx context.Context) error

Generate AWS profiles and merge them with the existing config. Writes output to the generator's output.

type MergeOpts

type MergeOpts struct {
	Config              *ini.File
	Prefix              string
	Profiles            []SSOProfile
	SectionNameTemplate string
	NoCredentialProcess bool
	// PruneStartURLs is a slice of AWS SSO start URLs which profiles are being generated for.
	// Existing profiles with these start URLs will be removed if they aren't found in the Profiles field.
	PruneStartURLs []string
	SessionName    string
	SSOScopes      []string
	PreferRoles    []string
	Verbose        bool
	DefaultRegion  string
}

type SSOProfile

type SSOProfile interface {
	ToIni(profileName string, nocredentialProcessProfile bool) any
}

type SSOSession

type SSOSession struct {
	SSOSessionName        string
	SSOStartURL           string
	SSORegistrationScopes string
	SSORegion             string
	GeneratedFrom         string
}

func (*SSOSession) ToIni

func (s *SSOSession) ToIni(profileName string, nocredentialProcessProfile bool) any

type Source

type Source interface {
	GetProfiles(ctx context.Context) ([]SSOProfile, error)
}

Sources return AWS profiles to be combined into an AWS config file.

Jump to

Keyboard shortcuts

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