accounts

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package accounts says which accounts an estimate reaches (vision docs/specs/2026-10-10-savings-estimate-design.md §4, decision 4): an organization's active accounts when the profile may list them, else its own account only, and why. The profile's own account uses its own credentials; the others a role given or supposed (OrganizationAccountAccessRole), assumed when an account's turn comes (the sessions last an hour) — a refusal lists the account apart with AWS's reason and the fix. Restricted to the accounts given with --accounts: one not reached is listed apart with why; none of them, refused. Several profiles (such as one SSO profile per account): each reaches its accounts, merged; an account a profile logs in to directly is reached with it, never through another's role; --accounts restricts the merged accounts.

Ports manager packages/estimate/src/accounts.ts (AccountsPorts, reachAccounts, reachProfiles).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	Role        string
	Only        []string
	Now         func() time.Time
	Unreachable *Unreachables
	// Profile names the profile in what is said; Say says each step (nil: nothing); Listing passes the organization's
	// walk on as it goes (nil: nothing). The user, 2026-10-14: a large organization took a while without a word.
	Profile string
	Say     func(line string)
	Listing func(discover.InventoryProgress)
}

Options of Reach and ReachProfiles. Only: the accounts given with --accounts (nil: every account reached). Now: the clock (time.Now when nil). Unreachable: where the accounts refusing their role are listed, shared by several profiles (a new list when nil).

type Ports

type Ports interface {
	Whoami(ctx context.Context) (string, error)
	Organization(ctx context.Context) (string, error)
	// Inventory walks the organization, saying how far it is (progress nil: silent).
	Inventory(ctx context.Context, progress func(discover.InventoryProgress)) (discover.OrgInventory, error)
	Assume(ctx context.Context, account, role string) (aws.Credentials, error)
}

Ports are a profile's calls that reach accounts (Node's AccountsPorts): its own account (GetCallerIdentity), its organization (DescribeOrganization), the organization's active accounts (the inventory) and a role assumed in an account (AssumeRole).

type Profile

type Profile struct {
	Profile string
	Ports   Ports
}

Profile is a profile and its ports.

type Reached

type Reached struct {
	Organization *string          `json:"organization"`
	Why          *string          `json:"why"`
	Accounts     []ReachedAccount `json:"accounts"`
	Unreachable  *Unreachables    `json:"unreachable"`
	Listed       int              `json:"listed"`
}

Reached is what an estimate reaches: the organization (nil when none, or several profiles in different ones), why only some accounts are (nil when all), the accounts, those not reached, and Listed, how many were reached before --accounts restricted them.

func Reach

func Reach(ctx context.Context, ports Ports, o Options) (Reached, error)

Reach gives the accounts a profile reaches (Node's reachAccounts).

func ReachProfiles

func ReachProfiles(ctx context.Context, profiles []Profile, o Options) (Reached, error)

ReachProfiles gives the accounts several profiles reach, merged in their order: an account reached by several, with the profile whose own account it is when one is (and the name another knows); the organization when they share one; each profile's why. One profile: as reached alone (Node's reachProfiles). A profile that fails names itself in the error's message.

type ReachedAccount

type ReachedAccount struct {
	Account string `json:"account"`
	Name    string `json:"name"`
	Own     bool   `json:"own,omitempty"`
	Profile string `json:"profile,omitempty"`
	// Credentials are the account's: nil for the profile's own account, else
	// its role's, assumed when first asked and again five minutes before they
	// expire; a refusal is kept and said once.
	Credentials func(ctx context.Context) (*aws.Credentials, error) `json:"-"`
}

ReachedAccount is an account reached. Own: the profile's own account, whose Credentials are nil (the profile's own); Profile: the profile reaching it.

type Unreachable

type Unreachable struct {
	Account string `json:"account"`
	Name    string `json:"name"`
	Reason  string `json:"reason"`
	Fix     string `json:"fix"`
}

Unreachable is an account not reached, why, and how to include it.

type Unreachables

type Unreachables struct {
	// contains filtered or unexported fields
}

Unreachables lists the accounts not reached: those --accounts names that are not, and those refusing their role, as their turn comes. Safe for concurrent use; written as a JSON array.

func (*Unreachables) List

func (u *Unreachables) List() []Unreachable

List is a copy of the accounts listed so far.

func (*Unreachables) MarshalJSON

func (u *Unreachables) MarshalJSON() ([]byte, error)

MarshalJSON writes the list.

Jump to

Keyboard shortcuts

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