install

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 49 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 install is `dormeto install`: the manager installed in an AWS account (or an organization) by CodeBuild, from the CLI. This part holds the install's settings, kept as install.json, and its terminal prompts, as the design spec describes them (vision docs/specs/2026-10-17-cli-install-design.md, sections 3 and 6).

Index

Constants

View Source
const MinVersion = "0.11.0"

MinVersion is the first manager release `dormeto install` can install.

View Source
const ReleasesURL = "https://releases.dormeto.com/manager"

ReleasesURL is where the manager's releases are published.

View Source
const SelfUpdateVersion = "0.12.0"

SelfUpdateVersion is the first manager release with the module's install input (the dashboard's updates).

Variables

View Source
var ErrNoTerminal = errors.New("no terminal to ask")

ErrNoTerminal is what Ask returns when there is no terminal to ask: the flags must give every answer.

Functions

func Apply

func Apply(ctx context.Context, d Deps, r Request) int

Apply is `dormeto install apply`: the explicit confirmation of the last plan (a plan made without a terminal, or left at the question), shown, then applied, followed and verified as Install does; with a management profile, organization access deployed after it, or alone when there is no plan to apply (ruling R16). Exit codes as Install's.

func AtLeast

func AtLeast(version, floor string) bool

AtLeast reports whether version's major.minor.patch reaches floor's; a pre-release suffix is ignored.

func Bootstrap

func Bootstrap(ctx context.Context, c Clients, p Project, buildRole string) error

Bootstrap creates, or updates to what this version expects, the install's own resources in the account: the state bucket, the build role (unless buildRole, an ARN, is given: it is used as is), the log group, the scripts and the CodeBuild project, then, unless buildRole is given (the dashboard's update is not set up then), the rule that starts the project on a request, its role and the bucket's EventBridge events. Running it again is safe.

func CheckPlan

func CheckPlan(ctx context.Context, c Clients, planBuild string, applied *Applied) error

CheckPlan refuses a plan that is unknown or did not succeed (an *UnusablePlanError), or was made before the last apply (applied, when not nil: a *StalePlanError); its other errors are AWS's.

func CompareVersions

func CompareVersions(a, b string) int

CompareVersions is semver precedence: major.minor.patch numerically, then a pre-release sorts before its release, pre-releases compared as strings.

func Config

func Config(s Settings, w Where, p Project) ([]byte, error)

Config is main.tf.json, the Terraform configuration CodeBuild runs: the manager module from the release unpacked beside it, with the settings as its inputs. Keys are sorted and the bytes are stable.

func ConsoleURL

func ConsoleURL(p Project, build string) string

ConsoleURL is the build's page in the AWS console.

func Disabled

func Disabled(managementAccount string) string

Disabled explains organization access without the management account's profile.

func Failed

func Failed(cs []Check) bool

Failed tells whether a check failed.

func Install

func Install(ctx context.Context, d Deps, r Request) int

Install is `dormeto install`: where it runs, the answers (asked on a first install), the checks, the bootstrap, the plan in CodeBuild, its summary, the person's confirmation in a terminal, the saved plan applied and followed, then the dashboard and the invitations checked; with a management profile, organization access after the manager (also when the plan changes nothing, and alone with --access). Exit codes: 0; 1 when AWS refuses, a check fails or a build fails; 2 for a bad or missing answer; 130 when ctx is cancelled (Ctrl-C).

func InstallCheck

func InstallCheck(ctx context.Context, d Deps, r Request) int

InstallCheck is `dormeto install check` (Check is a check's row): the prerequisites, read-only, without asking anything but the region: the version the latest unless given, the mode the suggested one unless given, the administrators a warning until given; with a management profile, organization access surveyed. Exit codes: 0; 1 when a check fails or AWS refuses; 2 for a bad flag; 130 when ctx is cancelled.

func Latest

func Latest(ctx context.Context, h HTTP) (string, error)

Latest is the version latest.json names.

func MergePolicy

func MergePolicy(current, template []byte, managerAccount, env string) (merged []byte, change string, err error)

MergePolicy puts this manager into the organization's delegation policy: the template (the release's dormeto-organization-policy.json, MANAGER_ACCOUNT and ENV replaced) when there is none; else the statement of the template's Sid gets the manager's principal and the template's actions, the other statements kept in place. change is "new", "updated" (the principal was added), "actions" (only the release's actions were added) or "unchanged" (current returned as it is).

func OrgBootstrap

func OrgBootstrap(ctx context.Context, mgmt Clients, p Project, memberRole, organization string) error

OrgBootstrap creates, or updates, the management account's project that runs organization.sh: the bucket, the role (no managed policy, one scoped inline policy: the member role of the organization's accounts), the log group, the scripts and the project.

func OrgTeardown

func OrgTeardown(ctx context.Context, mgmt Clients, p Project) error

OrgTeardown deletes the organization project, its role and its log group; the bucket stays (its reports stay). What is already gone is not an error.

func OtherEnvs

func OtherEnvs(ctx context.Context, c Clients, p Project) ([]string, error)

OtherEnvs is the envs of the bucket with an <env>/install.json, but p.Env, sorted: one listing of the bucket.

func ParseTags added in v0.3.0

func ParseTags(values []string) (map[string]string, error)

ParseTags reads the --tag values (key=value, the value up to the end after the first =). Nothing given is nil; "" alone is an empty map, which removes every tag.

func Prompted added in v0.4.0

func Prompted[T any](ctx context.Context, out io.Writer, ask func() (T, error)) (T, error)

Prompted is the prompter's answer, or the context's error as soon as the run is cancelled (a terminal's read does not end with Ctrl-C), a newline then written to out so that what follows does not land on the question's line.

func PutConfig

func PutConfig(ctx context.Context, c Clients, p Project, mainTF []byte) error

PutConfig writes the generated configuration, <env>/config/main.tf.json.

func PutOrgPlan

func PutOrgPlan(ctx context.Context, mgmt Clients, p Project, a Access) error

PutOrgPlan writes the plan the build applies: policy.json is the policy to put; policy-base.json is the policy it was merged from, an empty object (zero bytes) when there was none (ruling R23), which is what the build compares with an absent policy; accounts.txt and discovery-only.txt are the accounts that get the roles and those of them without the command role, one id per line (an organization's hundreds of ids do not fit the build's environment).

func ReadOrgAccounts

func ReadOrgAccounts(ctx context.Context, mgmt Clients, p Project) ([]string, error)

ReadOrgAccounts reads the accounts of the plan the organization build applies (accounts.txt; none when absent).

func ReadPlan

func ReadPlan(ctx context.Context, c Clients, p Project, build string) ([]byte, error)

ReadPlan reads <env>/plans/<build>/plan.json (the build id as manager.sh writes it); nil when absent.

func Running

func Running(ctx context.Context, c Clients, project string) (string, error)

Running is the id of the project's build in progress, or "" when none.

func Start

func Start(ctx context.Context, c Clients, p Project, a Action, env map[string]string) (string, error)

Start starts a build of the project with the action (and env as more variables) and returns its id; a build already running is a *RunningError.

func StateHasResources

func StateHasResources(ctx context.Context, c Clients, p Project) (bool, error)

StateHasResources tells whether the manager's Terraform state, <env>/manager.tfstate, holds a resource: false when it is absent (or the bucket is) or its resources are none. It, not applied.json, says whether anything is applied: an apply that failed halfway leaves resources and no applied.json.

func Status

func Status(ctx context.Context, d Deps, r Request) int

Status is `dormeto install status`. Exit codes: 0; 1 when a check fails, the last build failed or AWS refuses; 130 when ctx is cancelled (a followed build goes on).

func Suggest

func Suggest(w Where) (mode, why string)

Suggest is the mode to suggest ("organization" or "account") and why.

func Survey

func Survey(ctx context.Context, mgmt Clients, assume func(account string) (Clients, error), s Settings, manager Where, template []byte) (Access, []Check, error)

Survey reads the organization from the management account, changing nothing: which accounts the member role reaches, which of them hold Dormeto's roles (and whose), and the delegation policy that would be put. An error is returned only for a failure that makes the rest meaningless. assume is called from up to 20 goroutines at once.

func Teardown

func Teardown(ctx context.Context, c Clients, p Project, bucket bool) error

Teardown deletes the install's request rule, its project, its log group, its two roles (the build role and the rule's, each only when this install created it: under /dormeto/ and tagged) and, with bucket, the state bucket with every version in it. The rule and its role go whatever the build role now: a first run without --build-role made them. What is already gone is not an error.

func Uninstall

func Uninstall(ctx context.Context, d Deps, r Request) int

Uninstall is `dormeto uninstall`: where it runs; with the manager applied, the routers (refused while any), event-driven refresh off (asked in a terminal), the deletion protection lifted (a plan, confirmed in a terminal, applied), the destroy plan, its summary, the person's confirmation in a terminal, then the plan applied and followed; then the bootstrap removed when the person asks. Without a terminal it stops after a plan with the command that applies it. Exit codes: 0; 1 when routers are installed, event-driven refresh is not off, AWS refuses or a build fails; 2 for a bad flag; 130 when ctx is cancelled (Ctrl-C).

func UninstallApply

func UninstallApply(ctx context.Context, d Deps, r Request) int

UninstallApply is `dormeto uninstall apply`: the explicit confirmation of the last plan when it is a destroy plan (made without a terminal, or left at the question), shown, then applied and followed; the bootstrap kept. Exit codes as Uninstall's.

func UploadRelease

func UploadRelease(ctx context.Context, c Clients, p Project, r Release) (string, error)

UploadRelease puts a local release's files under <env>/release/ and returns that base, s3://<bucket>/<env>/release.

func ValidateTags added in v0.3.0

func ValidateTags(tags map[string]string) error

ValidateTags checks the install's tags (--tag), its message beginning with --tag and naming the faulty tag.

func WriteCLI

func WriteCLI(ctx context.Context, c Clients, p Project, version string) error

WriteCLI writes <env>/cli.json, the version of the CLI that installed: the dashboard reads it to know whether the install can be updated from there.

func WriteSettings

func WriteSettings(ctx context.Context, c Clients, p Project, s Settings) error

WriteSettings writes <env>/install.json.

Types

type ACM

type ACM interface {
	DescribeCertificate(ctx context.Context, in *acm.DescribeCertificateInput, optFns ...func(*acm.Options)) (*acm.DescribeCertificateOutput, error)
}

ACM is the acm client's calls the install makes.

type Access

type Access struct {
	Management    string            // the management account (the management profile's)
	Ready         []string          // reachable, roles present and trusting this manager (the script updates them)
	Missing       []string          // reachable, no Dormeto role (the script creates them)
	DiscoveryOnly []string          // of Ready+Missing, the --discovery-only ones (no command role)
	Unreachable   []string          // the member role could not be assumed
	Foreign       []string          // another manager's roles or boundary (decision 15): left out
	Notes         map[string]string // account → why it is unreachable or foreign
	Policy        []byte            // the merged delegation policy to put
	PolicyBase    []byte            // the policy as read (empty: none), which the build checks is unchanged
	PolicyChange  string            // "new", "updated" (principal added), "actions" (only actions added), "unchanged"
}

Access is what the survey of the organization found, and the plan the build applies.

func (Access) Accounts

func (a Access) Accounts() []string

Accounts are the accounts the build runs the script in: Ready and Missing, sorted.

type Action

type Action string

Action is what a build does: the ACTION variable manager.sh and organization.sh read.

const (
	ActionPlan         Action = "plan"
	ActionPlanDestroy  Action = "plan-destroy"
	ActionApply        Action = "apply"
	ActionApplyDestroy Action = "apply-destroy"
	ActionOrgApply     Action = "org-apply" // the management account's project: ACTION=apply for organization.sh
)

type AdoptedFrom

type AdoptedFrom struct {
	File   string `json:"file"`
	SHA256 string `json:"sha256"`
}

AdoptedFrom is the state file an install adopted: its base name and its SHA-256.

type Adoption

type Adoption struct {
	File, SHA256, Module string
	Source               []byte
	Moved
	Err error
}

Adoption is --adopt-state's: the source state's file (its base name and SHA-256), the module's name in it, the file as read, and the state moved from it; Err is why it cannot be adopted.

type Applied

type Applied struct {
	Version string `json:"version"`
	Build   string `json:"build"`
}

Applied is <env>/applied.json, written by the apply build: what the last apply installed.

func ReadApplied

func ReadApplied(ctx context.Context, c Clients, p Project) (*Applied, error)

ReadApplied reads <env>/applied.json; nil when absent.

type Check

type Check struct {
	Name    string
	Detail  string
	Verdict Verdict
}

Check is one prerequisite and what was found.

func Checks

func Checks(ctx context.Context, c Clients, s Settings, w Where, f Found) []Check

Checks runs every prerequisite of the manager's own account, read-only, and returns the rows in a fixed order. An unexpected error in a row fails that row with AWS's message.

func Verify

func Verify(ctx context.Context, c Clients, h HTTP, out Outputs, admins []string, o VerifyOptions) []Check

Verify checks after an apply that the dashboard answers and the administrators were invited.

func Warnings

func Warnings(cs []Check) []Check

Warnings are the checks that warn.

func (Check) Line

func (c Check) Line() string

Line is the check as one terminal line.

type Clients

type Clients struct {
	STS           STS
	IAM           IAM
	S3            S3
	CodeBuild     CodeBuild
	Logs          Logs
	Organizations Organizations
	EC2           EC2
	ACM           ACM
	Route53       Route53
	SESv2         SESv2
	Lambda        Lambda
	Cognito       Cognito
	DynamoDB      DynamoDB
	EventBridge   EventBridge
}

Clients is every service's client of one install run.

type CodeBuild

CodeBuild is the codebuild client's calls the install makes.

type Cognito

Cognito is the cognitoidentityprovider client's calls the install makes.

type CredentialsError

type CredentialsError struct {
	Build       string
	Err         error
	Login, Args string
}

CredentialsError is the AWS credentials expiring while a build is followed: the build goes on. The run that followed it gives the command that signs in again (Login) and the flags that name the install again (Args).

func (*CredentialsError) Error

func (e *CredentialsError) Error() string

func (*CredentialsError) Unwrap

func (e *CredentialsError) Unwrap() error

type Deps

type Deps struct {
	Clients func(ctx context.Context, profile, region string) (Clients, error) // internal/aws.Load + installaws.Clients
	Region  func(ctx context.Context, profile string) (string, error)          // the profile's configured region, "" when none
	// Assume is the clients of a role assumed with the profile's credentials (internal/aws.Load + installaws.Assumed +
	// installaws.Clients, session dmt-<env>-install): the member role in each account, for organization access.
	Assume   func(ctx context.Context, profile, region, roleARN string) (Clients, error)
	HTTP     HTTP
	Prompter Prompter
	Out      io.Writer
	Status   progress.Status // nil when stdout is not a terminal
	Terminal bool            // stdin is a terminal: the guide may ask
	Now      func() time.Time
	Every    func(time.Duration) <-chan time.Time
	Version  string // the CLI's own version, recorded in <env>/cli.json
}

Deps are what a command's run uses outside itself.

type Domain

type Domain struct {
	Dashboard string `json:"dashboard"`
	// The sign-in host; empty: AuthHost's default.
	Auth string `json:"auth"`
	// The ACM certificate, in us-east-1.
	CertificateARN string `json:"certificateArn"`
	ZoneID         string `json:"zoneId"`
}

Domain is the custom domain of the dashboard and its sign-in page.

func (Domain) AuthHost

func (d Domain) AuthHost() string

AuthHost is the sign-in host: Auth, or auth.<Dashboard> when empty.

type DynamoDB

type DynamoDB interface {
	Query(ctx context.Context, in *dynamodb.QueryInput, optFns ...func(*dynamodb.Options)) (*dynamodb.QueryOutput, error)
}

DynamoDB is the dynamodb client's calls the install makes.

type EC2

type EC2 interface {
	DescribeRegions(ctx context.Context, in *ec2.DescribeRegionsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeRegionsOutput, error)
}

EC2 is the ec2 client's calls the install makes.

type EventBridge

type EventBridge interface {
	PutRule(ctx context.Context, in *eventbridge.PutRuleInput, optFns ...func(*eventbridge.Options)) (*eventbridge.PutRuleOutput, error)
	PutTargets(ctx context.Context, in *eventbridge.PutTargetsInput, optFns ...func(*eventbridge.Options)) (*eventbridge.PutTargetsOutput, error)
	RemoveTargets(ctx context.Context, in *eventbridge.RemoveTargetsInput, optFns ...func(*eventbridge.Options)) (*eventbridge.RemoveTargetsOutput, error)
	DeleteRule(ctx context.Context, in *eventbridge.DeleteRuleInput, optFns ...func(*eventbridge.Options)) (*eventbridge.DeleteRuleOutput, error)
}

EventBridge is the eventbridge client's calls the install makes.

type FollowOptions

type FollowOptions struct {
	Label  string          // "Plan", "Apply", "Destroy", "Organization access"
	Total  int             // resources the plan changes (0: unknown, no "n/total")
	Status progress.Status // nil: not a terminal → lines to Out
	Out    io.Writer
	Lines  bool // --verbose: Terraform's lines to Out even in a terminal (no status line)
	Every  func(time.Duration) <-chan time.Time
	Now    func() time.Time
	// Count tells whether a log line is one more done out of Total (organization.sh's line per account); nil: Terraform's
	// lines, the resource in progress shown.
	Count func(line string) bool
}

FollowOptions are how Follow shows a build.

type Found

type Found struct {
	Saved      *Settings
	OtherEnvs  []string
	Release    Release
	ReleaseErr error
	Adoption   *Adoption // --adopt-state's; nil: not adopting
}

Found is what the command gathers before the checks: the bucket's install.json of this env (nil: none), the other environments' install.json found in the bucket (their env names), and the release resolution's result.

type HTTP

type HTTP interface {
	Do(*http.Request) (*http.Response, error)
}

HTTP is the HTTP client of the calls outside AWS.

type IAM

type IAM interface {
	ListAccountAliases(ctx context.Context, in *iam.ListAccountAliasesInput, optFns ...func(*iam.Options)) (*iam.ListAccountAliasesOutput, error)
	SimulatePrincipalPolicy(ctx context.Context, in *iam.SimulatePrincipalPolicyInput, optFns ...func(*iam.Options)) (*iam.SimulatePrincipalPolicyOutput, error)
	GetRole(ctx context.Context, in *iam.GetRoleInput, optFns ...func(*iam.Options)) (*iam.GetRoleOutput, error)
	GetPolicy(ctx context.Context, in *iam.GetPolicyInput, optFns ...func(*iam.Options)) (*iam.GetPolicyOutput, error)
	CreateRole(ctx context.Context, in *iam.CreateRoleInput, optFns ...func(*iam.Options)) (*iam.CreateRoleOutput, error)
	UpdateAssumeRolePolicy(ctx context.Context, in *iam.UpdateAssumeRolePolicyInput, optFns ...func(*iam.Options)) (*iam.UpdateAssumeRolePolicyOutput, error)
	AttachRolePolicy(ctx context.Context, in *iam.AttachRolePolicyInput, optFns ...func(*iam.Options)) (*iam.AttachRolePolicyOutput, error)
	DetachRolePolicy(ctx context.Context, in *iam.DetachRolePolicyInput, optFns ...func(*iam.Options)) (*iam.DetachRolePolicyOutput, error)
	PutRolePolicy(ctx context.Context, in *iam.PutRolePolicyInput, optFns ...func(*iam.Options)) (*iam.PutRolePolicyOutput, error)
	DeleteRolePolicy(ctx context.Context, in *iam.DeleteRolePolicyInput, optFns ...func(*iam.Options)) (*iam.DeleteRolePolicyOutput, error)
	ListAttachedRolePolicies(ctx context.Context, in *iam.ListAttachedRolePoliciesInput, optFns ...func(*iam.Options)) (*iam.ListAttachedRolePoliciesOutput, error)
	ListRolePolicies(ctx context.Context, in *iam.ListRolePoliciesInput, optFns ...func(*iam.Options)) (*iam.ListRolePoliciesOutput, error)
	TagRole(ctx context.Context, in *iam.TagRoleInput, optFns ...func(*iam.Options)) (*iam.TagRoleOutput, error)
	DeleteRole(ctx context.Context, in *iam.DeleteRoleInput, optFns ...func(*iam.Options)) (*iam.DeleteRoleOutput, error)
}

IAM is the iam client's calls the install makes.

type Lambda

type Lambda interface {
	GetFunction(ctx context.Context, in *lambda.GetFunctionInput, optFns ...func(*lambda.Options)) (*lambda.GetFunctionOutput, error)
	ListFunctions(ctx context.Context, in *lambda.ListFunctionsInput, optFns ...func(*lambda.Options)) (*lambda.ListFunctionsOutput, error)
}

Lambda is the lambda client's calls the install makes.

type Moved

type Moved struct {
	State     []byte   // the install's state, as <env>/manager.tfstate holds it
	Resources int      // the resources moved
	Left      []string // the addresses of the resources left in the source, in its order
	Terraform string   // the Terraform version that wrote the source
	IAMNames  []string // the names of the IAM roles and policies moved, in the source's order
}

Moved is the state an adopting install takes from a source state.

func MoveState

func MoveState(source []byte, module string, p Project, terraform string) (Moved, error)

MoveState is the state an install of the project p takes from source, a Terraform state of a manager installed as module.<module>. The source must be of format version 4, written by a Terraform no newer than terraform (the build's), and hold module.<module>'s aws_lambda_function.api named dmt-<env>-manager-api in p's account and region. Every resource of module.<module> and of the modules nested in it moves to module.dormeto, their dependencies (and a provider of the module) renamed with them, the rest of their JSON kept as written; the resources outside are left (and listed); the serial goes up, the lineage and the Terraform version stay; the outputs and the check results go.

type NotPublishedError

type NotPublishedError struct{ Version string }

NotPublishedError is a version releases.dormeto.com does not have; its message says how to install a release built locally instead.

func (*NotPublishedError) Error

func (e *NotPublishedError) Error() string

func (*NotPublishedError) Short

func (e *NotPublishedError) Short() string

Short is the fact alone, for a caller that gives its own advice.

type Organization

type Organization struct {
	ID          string // o-…
	Management  string // the management account's id
	AllFeatures bool   // FeatureSet == "ALL"
}

Organization is the AWS organization the account belongs to.

type Organizations

Organizations is the organizations client's calls the install makes.

type Outputs

type Outputs struct{ DashboardURL, UserPoolID, Version string }

Outputs are the manager's Terraform outputs the install shows, from <env>/outputs.json (terraform output -json).

func ReadOutputs

func ReadOutputs(ctx context.Context, c Clients, p Project) (*Outputs, error)

ReadOutputs reads <env>/outputs.json, Terraform's `output -json` ({"dashboard_url":{"value":…},…}); nil when absent.

type PlanSummary

type PlanSummary struct {
	Add, Change, Destroy int
	ByType               map[string]int // type → resources changed (created, updated, replaced or destroyed)
	Replaced, Destroyed  []string       // addresses, sorted
}

PlanSummary is what a Terraform plan does, counted.

func Summarize

func Summarize(planJSON []byte) (PlanSummary, error)

Summarize reads `terraform show -json` of a plan. A replacement counts as one to add and one to destroy.

func (PlanSummary) Empty

func (s PlanSummary) Empty() bool

Empty is a plan with nothing to add, change or destroy.

func (PlanSummary) Lines

func (s PlanSummary) Lines() []string

Lines is the summary to show: the counts, the replaced and destroyed addresses, then the resources by type.

type Project

type Project struct {
	Account, Region, Env string
	Bucket               string // dmt-install-<account>-<region>
	Name                 string // dmt-<env>-install (the CodeBuild project)
	Role                 string // dmt-<env>-install (its role)
	LogGroup             string // /aws/codebuild/dmt-<env>-install
	Rule                 string // dmt-<env>-install-requests (the EventBridge rule)
	EventsRole           string // dmt-<env>-install-events (the rule's role)
}

Project is the install's own AWS resources, named from the account, the region and the env.

func Names

func Names(account, region, env string) Project

Names is the project of an account, a region and an env.

func OrgNames

func OrgNames(managementAccount, region, env string) Project

OrgNames is the management account's own project: its bucket, CodeBuild project, role and log group.

func (Project) Key

func (p Project) Key(parts ...string) string

Key is an S3 key in the install's bucket: <env>/ then the parts joined by "/".

func (Project) StateKey

func (p Project) StateKey() string

StateKey is the key of the manager's Terraform state.

func (Project) Tags

func (p Project) Tags() map[string]string

Tags are the tags of every resource the install creates.

type Prompter

type Prompter interface {
	// Ask writes the question (with the suggestion in brackets when there is one) and reads a line: an empty line gives
	// the suggestion. The end of the input is io.EOF.
	Ask(question, suggestion string) (string, error)
	// Confirm is true only for y or yes, in any case.
	Confirm(question string) (bool, error)
}

Prompter asks the person running the install.

func NewPrompter

func NewPrompter(in io.Reader, out io.Writer, terminal bool) Prompter

NewPrompter reads answers from in and writes questions to out. terminal false (a run without a terminal, CI): Ask returns ErrNoTerminal and Confirm false, neither writing anything.

type Release

type Release struct {
	Version string            // 0.11.0, or 0.11.0-dev for a local build
	Base    string            // ReleasesURL/<version>; empty for a local release (the bucket's copy is used)
	Sums    map[string]string // file name → sha256 (hex), from SHA256SUMS
	Local   string            // the local directory, or empty
}

Release is the manager release to install, resolved and checked against its SHA256SUMS.

func Resolve

func Resolve(ctx context.Context, h HTTP, version, local string) (Release, error)

Resolve reads and checks the release to install: version on releases.dormeto.com, or the local directory when local is set (version, when given, must then be the directory's).

func (Release) Files

func (r Release) Files() []string

Files is the files SHA256SUMS lists, sorted, then SHA256SUMS itself (what a local release uploads).

func (Release) Required

func (r Release) Required() []string

Required is the files the install cannot go without.

type Request

type Request struct {
	Profile, Region, Release string          // --profile, --region, --release
	ManagementProfile        string          // --management-profile: the management account's, for organization access
	Flags                    Settings        // the flags' values
	Set                      map[string]bool // the flags given (Merge's keys)
	Yes, Verbose             bool
	Access                   bool // --access: organization access alone, the manager installed
	// --adopt-state and --adopt-module: a manager installed with Terraform taken over by a first install, from its state
	// file and its module's name in it ("": manager).
	AdoptState, AdoptModule string
}

Request is a command line: its profile, region and release, the flags' settings and which flags were given.

type Result

type Result struct {
	Status     string // SUCCEEDED, FAILED, FAULT, TIMED_OUT, STOPPED, or IN_PROGRESS when detached
	Failed     bool
	Tail       []string // the log's last 40 lines (on a failure)
	ConsoleURL string
}

Result is how a build ended.

func Follow

func Follow(ctx context.Context, c Clients, p Project, build string, o FollowOptions) (Result, error)

Follow shows the build until it ends. A cancelled ctx detaches: it returns IN_PROGRESS and ctx's error, and never stops the build.

type RoleResult

type RoleResult struct {
	Account string `json:"account"`
	OK      bool   `json:"ok"`
	Error   string `json:"error,omitempty"`
}

RoleResult is one account's line of roles.json.

func ReadRoles

func ReadRoles(ctx context.Context, mgmt Clients, p Project) ([]RoleResult, error)

ReadRoles reads <env>/organization/roles.json (one JSON object per line); nil when it is absent.

type Route53

type Route53 interface {
	GetHostedZone(ctx context.Context, in *route53.GetHostedZoneInput, optFns ...func(*route53.Options)) (*route53.GetHostedZoneOutput, error)
}

Route53 is the route53 client's calls the install makes.

type RunningError

type RunningError struct{ Build string }

RunningError is a build already running in the project: CodeBuild refuses a second one rather than queuing it.

func (*RunningError) Error

func (e *RunningError) Error() string

type S3

type S3 interface {
	HeadBucket(ctx context.Context, in *s3.HeadBucketInput, optFns ...func(*s3.Options)) (*s3.HeadBucketOutput, error)
	CreateBucket(ctx context.Context, in *s3.CreateBucketInput, optFns ...func(*s3.Options)) (*s3.CreateBucketOutput, error)
	PutBucketVersioning(ctx context.Context, in *s3.PutBucketVersioningInput, optFns ...func(*s3.Options)) (*s3.PutBucketVersioningOutput, error)
	PutBucketEncryption(ctx context.Context, in *s3.PutBucketEncryptionInput, optFns ...func(*s3.Options)) (*s3.PutBucketEncryptionOutput, error)
	PutPublicAccessBlock(ctx context.Context, in *s3.PutPublicAccessBlockInput, optFns ...func(*s3.Options)) (*s3.PutPublicAccessBlockOutput, error)
	PutBucketPolicy(ctx context.Context, in *s3.PutBucketPolicyInput, optFns ...func(*s3.Options)) (*s3.PutBucketPolicyOutput, error)
	PutBucketLifecycleConfiguration(ctx context.Context, in *s3.PutBucketLifecycleConfigurationInput, optFns ...func(*s3.Options)) (*s3.PutBucketLifecycleConfigurationOutput, error)
	PutBucketTagging(ctx context.Context, in *s3.PutBucketTaggingInput, optFns ...func(*s3.Options)) (*s3.PutBucketTaggingOutput, error)
	GetObject(ctx context.Context, in *s3.GetObjectInput, optFns ...func(*s3.Options)) (*s3.GetObjectOutput, error)
	PutObject(ctx context.Context, in *s3.PutObjectInput, optFns ...func(*s3.Options)) (*s3.PutObjectOutput, error)
	ListObjectsV2(ctx context.Context, in *s3.ListObjectsV2Input, optFns ...func(*s3.Options)) (*s3.ListObjectsV2Output, error)
	ListObjectVersions(ctx context.Context, in *s3.ListObjectVersionsInput, optFns ...func(*s3.Options)) (*s3.ListObjectVersionsOutput, error)
	DeleteObjects(ctx context.Context, in *s3.DeleteObjectsInput, optFns ...func(*s3.Options)) (*s3.DeleteObjectsOutput, error)
	PutBucketNotificationConfiguration(ctx context.Context, in *s3.PutBucketNotificationConfigurationInput, optFns ...func(*s3.Options)) (*s3.PutBucketNotificationConfigurationOutput, error)
	DeleteBucket(ctx context.Context, in *s3.DeleteBucketInput, optFns ...func(*s3.Options)) (*s3.DeleteBucketOutput, error)
}

S3 is the s3 client's calls the install makes.

type SESv2

type SESv2 interface {
	GetEmailIdentity(ctx context.Context, in *sesv2.GetEmailIdentityInput, optFns ...func(*sesv2.Options)) (*sesv2.GetEmailIdentityOutput, error)
	GetAccount(ctx context.Context, in *sesv2.GetAccountInput, optFns ...func(*sesv2.Options)) (*sesv2.GetAccountOutput, error)
}

SESv2 is the sesv2 client's calls the install makes.

type STS

type STS interface {
	GetCallerIdentity(ctx context.Context, in *sts.GetCallerIdentityInput, optFns ...func(*sts.Options)) (*sts.GetCallerIdentityOutput, error)
	AssumeRole(ctx context.Context, in *sts.AssumeRoleInput, optFns ...func(*sts.Options)) (*sts.AssumeRoleOutput, error)
}

STS is the sts client's calls the install makes.

type Settings

type Settings struct {
	Env             string                     `json:"env"`
	Region          string                     `json:"region"`
	Version         string                     `json:"version"`
	Mode            string                     `json:"mode"` // "organization" | "account"
	AdminEmails     []string                   `json:"adminEmails"`
	OrganizationID  string                     `json:"organizationId,omitempty"`
	Domain          *Domain                    `json:"domain,omitempty"`
	SESIdentity     string                     `json:"sesIdentity,omitempty"`
	EmailFrom       string                     `json:"emailFrom,omitempty"`
	Vars            map[string]json.RawMessage `json:"vars,omitempty"`
	Tags            map[string]string          `json:"tags,omitempty"` // the Terraform default tags, after the fixed ones
	MemberRole      string                     `json:"memberRole,omitempty"`
	Accounts        []string                   `json:"accounts,omitempty"`
	ExcludeAccounts []string                   `json:"excludeAccounts,omitempty"`
	DiscoveryOnly   []string                   `json:"discoveryOnly,omitempty"`
	BuildRole       string                     `json:"buildRole,omitempty"`
	ReleaseBase     string                     `json:"releaseBase,omitempty"`  // the base the plan used, for a later install apply
	Installed       string                     `json:"installed,omitempty"`    // the version applied
	LastPlan        string                     `json:"lastPlan,omitempty"`     // build ids
	LastPlanKind    string                     `json:"lastPlanKind,omitempty"` // planApply or planDestroy; "": planApply
	LastApply       string                     `json:"lastApply,omitempty"`
	AdoptedFrom     *AdoptedFrom               `json:"adoptedFrom,omitempty"`   // the state adopted (--adopt-state)
	AdoptedModule   string                     `json:"adoptedModule,omitempty"` // its module's name in that state
}

Settings is what the install asks and remembers (install.json): the flags' values, then the install's own state.

func Merge

func Merge(flags, saved Settings, set map[string]bool) Settings

Merge is the settings a run uses: saved (install.json, or zero on a first install), each field whose flag is in set (the flag names) replaced by the flag's value. Vars merge key by key, a flag's key winning; Tags are replaced whole. The install's own state (Installed, LastPlan, LastPlanKind, LastApply) is always saved's.

func ParseSettings

func ParseSettings(b []byte) (Settings, error)

ParseSettings reads install.json.

func ReadSettings

func ReadSettings(ctx context.Context, c Clients, p Project) (*Settings, error)

ReadSettings reads <env>/install.json; nil when it is absent or the bucket is.

func (Settings) JSON

func (s Settings) JSON() ([]byte, error)

JSON is install.json: indented by two spaces, ending with a newline.

func (Settings) Validate

func (s Settings) Validate() error

Validate checks the settings and returns the first failure, its message beginning with the flag it is about.

type StalePlanError

type StalePlanError struct{ Plan, Apply string }

StalePlanError is a plan made before the last apply: applied already, or replaced; there is no plan to apply.

func (*StalePlanError) Error

func (e *StalePlanError) Error() string

type UnusablePlanError

type UnusablePlanError struct{ Plan, Status string }

UnusablePlanError is a plan that cannot be applied: unknown (Status empty), or it did not succeed.

func (*UnusablePlanError) Error

func (e *UnusablePlanError) Error() string

type Verdict

type Verdict int

Verdict is how a check came out.

const (
	OK   Verdict = iota
	Warn         // asked about once, by the command
	Fail         // stops the install
	Skip         // not applicable
)

type VerifyOptions

type VerifyOptions struct {
	Wait, Poll time.Duration // 10 min, 15 s when zero; a negative Wait: one try, no wait
	Every      func(time.Duration) <-chan time.Time
	Now        func() time.Time
}

VerifyOptions are how long Verify waits for the dashboard.

type Where

type Where struct {
	Account, Alias, Region, Caller string        // Caller: the caller's ARN
	Organization                   *Organization // nil: not in an organization, or unknown
	OrganizationUnknown            bool          // DescribeOrganization refused (access denied)
}

Where is where the install runs: the account the profile reaches, and its organization.

func Locate

func Locate(ctx context.Context, c Clients, region string) (Where, error)

Locate reads the caller's account, its alias and its organization. Only the caller identity and unexpected organization errors are returned; a missing alias or organization is a value.

func (Where) Describe

func (w Where) Describe() string

Describe is the one line that says where the install runs.

func (Where) IsManagement

func (w Where) IsManagement() bool

IsManagement tells whether the account is its organization's management account.

Directories

Path Synopsis
Package build holds what CodeBuild runs for the install: a one-line buildspec and two POSIX shell scripts, kept in the binary and uploaded to the install's bucket (Terraform with the manager release; the organization's access).
Package build holds what CodeBuild runs for the install: a one-line buildspec and two POSIX shell scripts, kept in the binary and uploaded to the install's bucket (Terraform with the manager release; the organization's access).

Jump to

Keyboard shortcuts

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