awsconfigfile

package module
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2024 License: MIT Imports: 13 Imported by: 6

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 Generator added in v0.3.0

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
}

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

func (*Generator) AddSource added in v0.4.0

func (g *Generator) AddSource(source Source)

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

func (*Generator) Generate added in v0.3.0

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
}

type SSOProfile

type SSOProfile struct {
	SSOStartURL string
	SSORegion   string

	// Account and role details
	Region        string
	AccountID     string
	AccountName   string
	RoleName      string
	CommonFateURL string
	// GeneratedFrom is the source that the profile
	// was created from, such as 'commonfate' or 'aws-sso'
	GeneratedFrom string
}

func (SSOProfile) ToIni

func (p SSOProfile) ToIni(profileName string, noCredentialProcess bool) any

ToIni converts a profile to a struct with `ini` tags ready to be written to an ini config file.

if noCredentialProcess is true, the struct will contain sso_ parameters like sso_role_name, sso_start_url, etc.

if noCredentialProcess is false, the struct will contain granted_sso parameters for use with the Granted credential process, like granted_sso_role_name, granted_sso_start_url, and so forth.

type Source added in v0.3.0

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