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
- Variables
- func Apply(ctx context.Context, d Deps, r Request) int
- func AtLeast(version, floor string) bool
- func Bootstrap(ctx context.Context, c Clients, p Project, buildRole string) error
- func CheckPlan(ctx context.Context, c Clients, planBuild string, applied *Applied) error
- func CompareVersions(a, b string) int
- func Config(s Settings, w Where, p Project) ([]byte, error)
- func ConsoleURL(p Project, build string) string
- func Disabled(managementAccount string) string
- func Failed(cs []Check) bool
- func Install(ctx context.Context, d Deps, r Request) int
- func InstallCheck(ctx context.Context, d Deps, r Request) int
- func Latest(ctx context.Context, h HTTP) (string, error)
- func MergePolicy(current, template []byte, managerAccount, env string) (merged []byte, change string, err error)
- func OrgBootstrap(ctx context.Context, mgmt Clients, p Project, memberRole, organization string) error
- func OrgTeardown(ctx context.Context, mgmt Clients, p Project) error
- func OtherEnvs(ctx context.Context, c Clients, p Project) ([]string, error)
- func ParseTags(values []string) (map[string]string, error)
- func Prompted[T any](ctx context.Context, out io.Writer, ask func() (T, error)) (T, error)
- func PutConfig(ctx context.Context, c Clients, p Project, mainTF []byte) error
- func PutOrgPlan(ctx context.Context, mgmt Clients, p Project, a Access) error
- func ReadOrgAccounts(ctx context.Context, mgmt Clients, p Project) ([]string, error)
- func ReadPlan(ctx context.Context, c Clients, p Project, build string) ([]byte, error)
- func Running(ctx context.Context, c Clients, project string) (string, error)
- func Start(ctx context.Context, c Clients, p Project, a Action, env map[string]string) (string, error)
- func StateHasResources(ctx context.Context, c Clients, p Project) (bool, error)
- func Status(ctx context.Context, d Deps, r Request) int
- func Suggest(w Where) (mode, why string)
- func Survey(ctx context.Context, mgmt Clients, ...) (Access, []Check, error)
- func Teardown(ctx context.Context, c Clients, p Project, bucket bool) error
- func Uninstall(ctx context.Context, d Deps, r Request) int
- func UninstallApply(ctx context.Context, d Deps, r Request) int
- func UploadRelease(ctx context.Context, c Clients, p Project, r Release) (string, error)
- func ValidateTags(tags map[string]string) error
- func WriteCLI(ctx context.Context, c Clients, p Project, version string) error
- func WriteSettings(ctx context.Context, c Clients, p Project, s Settings) error
- type ACM
- type Access
- type Action
- type AdoptedFrom
- type Adoption
- type Applied
- type Check
- type Clients
- type CodeBuild
- type Cognito
- type CredentialsError
- type Deps
- type Domain
- type DynamoDB
- type EC2
- type EventBridge
- type FollowOptions
- type Found
- type HTTP
- type IAM
- type Lambda
- type Logs
- type Moved
- type NotPublishedError
- type Organization
- type Organizations
- type Outputs
- type PlanSummary
- type Project
- type Prompter
- type Release
- type Request
- type Result
- type RoleResult
- type Route53
- type RunningError
- type S3
- type SESv2
- type STS
- type Settings
- type StalePlanError
- type UnusablePlanError
- type Verdict
- type VerifyOptions
- type Where
Constants ¶
const MinVersion = "0.11.0"
MinVersion is the first manager release `dormeto install` can install.
const ReleasesURL = "https://releases.dormeto.com/manager"
ReleasesURL is where the manager's releases are published.
const SelfUpdateVersion = "0.12.0"
SelfUpdateVersion is the first manager release with the module's install input (the dashboard's updates).
Variables ¶
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 ¶
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 ¶
AtLeast reports whether version's major.minor.patch reaches floor's; a pre-release suffix is ignored.
func Bootstrap ¶
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 ¶
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 ¶
CompareVersions is semver precedence: major.minor.patch numerically, then a pre-release sorts before its release, pre-releases compared as strings.
func Config ¶
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 ¶
ConsoleURL is the build's page in the AWS console.
func Install ¶
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 ¶
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 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 ¶
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 ¶
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
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
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 PutOrgPlan ¶
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 ¶
ReadOrgAccounts reads the accounts of the plan the organization build applies (accounts.txt; none when absent).
func ReadPlan ¶
ReadPlan reads <env>/plans/<build>/plan.json (the build id as manager.sh writes it); nil when absent.
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 ¶
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 ¶
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 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 ¶
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 ¶
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 ¶
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 ¶
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
ValidateTags checks the install's tags (--tag), its message beginning with --tag and naming the faulty tag.
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.
type Action ¶
type Action string
Action is what a build does: the ACTION variable manager.sh and organization.sh read.
type AdoptedFrom ¶
AdoptedFrom is the state file an install adopted: its base name and its SHA-256.
type Adoption ¶
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 ¶
Applied is <env>/applied.json, written by the apply build: what the last apply installed.
type Check ¶
Check is one prerequisite and what was found.
func Checks ¶
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.
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 ¶
type CodeBuild interface {
ListCuratedEnvironmentImages(ctx context.Context, in *codebuild.ListCuratedEnvironmentImagesInput, optFns ...func(*codebuild.Options)) (*codebuild.ListCuratedEnvironmentImagesOutput, error)
BatchGetProjects(ctx context.Context, in *codebuild.BatchGetProjectsInput, optFns ...func(*codebuild.Options)) (*codebuild.BatchGetProjectsOutput, error)
CreateProject(ctx context.Context, in *codebuild.CreateProjectInput, optFns ...func(*codebuild.Options)) (*codebuild.CreateProjectOutput, error)
UpdateProject(ctx context.Context, in *codebuild.UpdateProjectInput, optFns ...func(*codebuild.Options)) (*codebuild.UpdateProjectOutput, error)
DeleteProject(ctx context.Context, in *codebuild.DeleteProjectInput, optFns ...func(*codebuild.Options)) (*codebuild.DeleteProjectOutput, error)
StartBuild(ctx context.Context, in *codebuild.StartBuildInput, optFns ...func(*codebuild.Options)) (*codebuild.StartBuildOutput, error)
BatchGetBuilds(ctx context.Context, in *codebuild.BatchGetBuildsInput, optFns ...func(*codebuild.Options)) (*codebuild.BatchGetBuildsOutput, error)
ListBuildsForProject(ctx context.Context, in *codebuild.ListBuildsForProjectInput, optFns ...func(*codebuild.Options)) (*codebuild.ListBuildsForProjectOutput, error)
}
CodeBuild is the codebuild client's calls the install makes.
type Cognito ¶
type Cognito interface {
ListUserPools(ctx context.Context, in *cognitoidentityprovider.ListUserPoolsInput, optFns ...func(*cognitoidentityprovider.Options)) (*cognitoidentityprovider.ListUserPoolsOutput, error)
ListUsers(ctx context.Context, in *cognitoidentityprovider.ListUsersInput, optFns ...func(*cognitoidentityprovider.Options)) (*cognitoidentityprovider.ListUsersOutput, error)
}
Cognito is the cognitoidentityprovider client's calls the install makes.
type CredentialsError ¶
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.
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 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 Logs ¶
type Logs interface {
CreateLogGroup(ctx context.Context, in *cloudwatchlogs.CreateLogGroupInput, optFns ...func(*cloudwatchlogs.Options)) (*cloudwatchlogs.CreateLogGroupOutput, error)
PutRetentionPolicy(ctx context.Context, in *cloudwatchlogs.PutRetentionPolicyInput, optFns ...func(*cloudwatchlogs.Options)) (*cloudwatchlogs.PutRetentionPolicyOutput, error)
DescribeLogGroups(ctx context.Context, in *cloudwatchlogs.DescribeLogGroupsInput, optFns ...func(*cloudwatchlogs.Options)) (*cloudwatchlogs.DescribeLogGroupsOutput, error)
TagResource(ctx context.Context, in *cloudwatchlogs.TagResourceInput, optFns ...func(*cloudwatchlogs.Options)) (*cloudwatchlogs.TagResourceOutput, error)
GetLogEvents(ctx context.Context, in *cloudwatchlogs.GetLogEventsInput, optFns ...func(*cloudwatchlogs.Options)) (*cloudwatchlogs.GetLogEventsOutput, error)
DeleteLogGroup(ctx context.Context, in *cloudwatchlogs.DeleteLogGroupInput, optFns ...func(*cloudwatchlogs.Options)) (*cloudwatchlogs.DeleteLogGroupOutput, error)
}
Logs is the cloudwatchlogs 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 ¶
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 ¶
type Organizations interface {
DescribeOrganization(ctx context.Context, in *organizations.DescribeOrganizationInput, optFns ...func(*organizations.Options)) (*organizations.DescribeOrganizationOutput, error)
ListAccounts(ctx context.Context, in *organizations.ListAccountsInput, optFns ...func(*organizations.Options)) (*organizations.ListAccountsOutput, error)
DescribeResourcePolicy(ctx context.Context, in *organizations.DescribeResourcePolicyInput, optFns ...func(*organizations.Options)) (*organizations.DescribeResourcePolicyOutput, error)
}
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).
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 OrgNames ¶
OrgNames is the management account's own project: its bucket, CodeBuild project, role and log group.
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.
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 ¶
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).
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.
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.
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 ¶
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 ¶
ParseSettings reads install.json.
func ReadSettings ¶
ReadSettings reads <env>/install.json; nil when it is absent or the bucket is.
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 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 ¶
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) IsManagement ¶
IsManagement tells whether the account is its organization's management account.
Source Files
¶
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). |