Help us shape the future of Go! Take the 2026 Go Developer Survey

asg

package module
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 21 Imported by: 0

README

asg

github.com/truvity/asg is a Pulumi Go library for running a service as an EC2 Auto Scaling group: a machine, or a few, built from user-data and replaced rather than repaired.

  • asg.New registers the group and its launch template, an optional warm pool of stopped instances, a launch lifecycle hook whose default result is ABANDON (an instance that never finished booting is replaced, not put in service half configured), an IAM role and instance profile with the least privilege the user-data needs, and a security group.

  • module and modules/ are the extension mechanism: a module returns data (user-data fragments, IAM statements, SSM parameter names, ingress rules, the steps and checks of the on-box lifecycle) and never a resource, so turning one on changes the launch template and the policy, not the set of resources. Shipped: watchdog (replace an instance whose local checks keep failing), ssh (opkssh and a fixed host key), selfregister (a DNS record for the in-service instance), tunnel (a Cloudflare tunnel connector that starts only in service) and ssmcert (a TLS certificate, key and CA from SSM into /run, with a nightly rotation that takes the box out of service through Standby while its daemon restarts).

  • bootstrap composes the user-data from fragments: systemd units, files, the secrets an instance reads at boot (SSM parameters and S3 objects, by exact name) and the readiness step that completes the lifecycle hook. The IAM policy is derived from it, so the instance can read exactly what its user-data names and nothing else.

  • front puts boxes behind an internal network load balancer: a shared NLB per environment (front.NewSharedNLB), a box's target group, TCP listener and port-scoped security group rules on it (front.Attach), or an NLB of its own (front.NewNLB). The port is the service's identity, and only the NLB's security group reaches the targets.

The rules the component enforces, whatever the caller passes:

  • IMDSv2 is always required;
  • a bare * action is refused;
  • no managed policy is attached by default;
  • a warm pool without a lifecycle hook is refused;
  • the image is pinned at deploy time, so a newer image is a visible diff.

Who it is for

Anyone running a service on EC2 the replace-don't-repair way with Pulumi in Go: a stateless box, or a small fleet, whose whole configuration is its user-data, behind a load balancer, a tunnel or nothing at all.

The model

One call, asg.New, registers an Auto Scaling group and everything it needs as children of one component. The user-data is a bootstrap.Plan: files, units and the secrets the instance reads at boot, by exact name. The IAM policy is derived from the plan, so an instance can read what its user-data names and nothing else. A launch lifecycle hook with a default of ABANDON means an instance that never finished booting is replaced, never put in service half configured.

Install and a worked example

go get github.com/truvity/asg
import (
    "github.com/truvity/asg"
    "github.com/truvity/asg/bootstrap"
)

Build a bootstrap.Plan, render it, and pass the result to asg.New with the group, instance, IAM and network arguments. The package documentation and composed_test.go show a complete box made of a plan and modules. Compat lets an existing group move onto this library without Pulumi replacing anything: it keeps the component type, the logical names and the layout the group was created with.

Consumers

The status page box in truvity/observability (pkg/statusbox/ec2).

Neighbours

truvity/aws-structure shapes the AWS organization this runs in; the code here used to live there as pkg/appliance and pkg/bootstrap.

Documentation

The package documentation, and the decisions under docs/decisions/.

The rule that makes this repository public

Mechanism only. Account ids, regions, names, images and policy statements are the caller's; nothing here defaults to one estate's value, and the tests use Pulumi mocks and never reach an AWS account. hack/leak-canary.sh enforces the mechanical half over tracked files and runs in the gate, with no exception.

Status

v0.x: the API may change in a minor release, and every change is in the CHANGELOG. v0.1.0 is the code that was pkg/appliance and pkg/bootstrap in truvity/aws-structure, moved without a behaviour change; v0.2.0 adds the module package and the first four modules, and changes two defaults (see the CHANGELOG); v0.3.0 adds front; v0.4.0 adds data volumes, several instance types, warm-pool reuse on scale-in, termination policies, module group actions and ssmcert.

Development

devbox shell
just check      # build, test, lint, leak-canary

Releasing

Releases are a v* tag, which the shared release workflow turns into the Go module version and a GitHub Release. Automatic patch releases are not armed; releases are hand-cut tags.

Licence

MIT, see LICENSE.

Documentation

Overview

Package asg provisions an EC2 appliance: a machine, or a few, that is built from user-data, joins an Auto Scaling group and is replaced rather than repaired. It sits next to bootstrap, which composes the user-data; this package gives that user-data a home and the least privilege it needs.

One call, New, registers these children under one component (or, with Compat.Flat, directly under the caller's parent):

  • an Auto Scaling group of Min..Max and a launch template;
  • a warm pool of stopped instances (optional);
  • an EC2_INSTANCE_LAUNCHING lifecycle hook, on the group or as a separate resource, whose DefaultResult is ABANDON: bootstrap-ready.service sends CONTINUE on every boot, so an instance that never finished is replaced instead of put in service half configured;
  • an IAM role and instance profile whose policy is built from the user-data: ssm:GetParameter on exactly the plan's parameter names, s3:GetObject on exactly the plan's object keys and the two Auto Scaling actions the lifecycle scripts call, scoped to the group, plus the statements the caller adds;
  • a security group, its rules inline or separate;
  • the plan's S3 objects, uploaded (this is the only thing bootstrap leaves to the caller), and the CloudWatch alarms the caller asks for.

The image is found by name filter or by SSM parameter at deploy time and pinned in the launch template, so a newer image is a visible diff and a rolling refresh. IMDSv2 is always required; the hop limit is configurable (a container on the instance needs 2).

Migrating without a replace

An appliance that exists today is adopted in two steps, and both are possible with this package.

Step A. The caller passes the old user-data unchanged (bootstrap.Verbatim) and the options of Compat reproduce every logical name, parent, type and physical name; Args.IAM.Policy returns the old policy document. The preview is empty: no launch template version, no refresh.

Step B. The caller switches to a composed plan and drops the overrides. The launch template gets one new version, which an instance refresh rolls out, and the role's policy is tightened in place.

Extension points

A Module contributes bootstrap fragments, IAM statements, SSM parameters, security group rules, and the steps and checks of the on-box lifecycle in one piece. Collect merges modules into a Contribution that Args.Contribution takes and that [Contribution.AddTo] feeds to the plan. The Pulumi-free package module defines the types and modules/ ships four: watchdog, ssh, selfregister and tunnel.

The on-box lifecycle

A step that must run only when the instance goes in service (start a daemon, read a secret) is a Step; a check that must pass before the launch hook is completed is a ReadyCheck. The library writes them as files and runs them from one oneshot unit that does nothing in the warm pool, and bootstrap-ready.service completes the hook only if that unit succeeded.

Index

Constants

View Source
const (
	// TypeToken is the Pulumi type of the component unless Compat.ComponentType
	// overrides it.
	TypeToken = "truvity:asg:Box"

	DefaultPartition        = "aws"
	DefaultHeartbeatSeconds = 900
	DefaultGracePeriod      = 300
	DefaultHopLimit         = 1
	DefaultRootDevice       = "/dev/xvda"
	DefaultRootVolumeGiB    = 8
	DefaultVolumeType       = "gp3"
	// MaxDataVolumes bounds InstanceArgs.Volumes: device names /dev/sdf to
	// /dev/sdp.
	MaxDataVolumes     = 11
	DefaultPolicyName  = "appliance"
	DefaultContentType = "text/plain"
)

Defaults.

View Source
const (
	SidReadParameters = "ReadParameters"
	SidReadObjects    = "ReadObjects"
	SidOwnGroup       = "OwnGroup"
)

Statement ids of BootstrapStatements.

View Source
const PolicyVersion = "2012-10-17"

PolicyVersion is the IAM policy language version of every document.

Variables

This section is empty.

Functions

func AssumeRolePolicy

func AssumeRolePolicy(partition string) string

AssumeRolePolicy lets EC2 assume the instance role.

func Document

func Document(statements []Statement) (string, error)

Document renders statements as a policy document, indented by two spaces. A statement without an Effect is an Allow.

func GroupARN

func GroupARN(partition, region, account, group string) string

GroupARN is the ARN of an Auto Scaling group.

func ObjectARN

func ObjectARN(partition, bucket, key string) string

ObjectARN is the ARN of an S3 object.

func ParameterARN

func ParameterARN(partition, region, account, name string) string

ParameterARN is the ARN of an SSM parameter named like /estate/token.

Types

type Alarm deprecated

type Alarm struct {
	// Suffix names the alarm: "<Base>-<Suffix>", and its logical name.
	Suffix string
	// Name, when set, is the alarm's physical name instead.
	Name        string
	Description string
	Namespace   string
	MetricName  string
	Statistic   string
	// Comparison is GreaterThanThreshold, GreaterThanOrEqualToThreshold,
	// LessThanThreshold or LessThanOrEqualToThreshold.
	Comparison        string
	Threshold         float64
	PeriodSeconds     int
	EvaluationPeriods int
	DatapointsToAlarm int
	// TreatMissingData defaults to missing.
	TreatMissingData string
	Dimensions       map[string]string
}

Alarm is one metric alarm. Dimensions default to the group.

Deprecated: see Args.Alarms.

type AlarmsArgs deprecated

type AlarmsArgs struct {
	// ActionARNs are notified when an alarm fires (e.g. an SNS topic).
	// Empty: the alarms notify nobody.
	ActionARNs   []string
	OKActionARNs []string
	Alarms       []Alarm
}

AlarmsArgs are CloudWatch alarms on the appliance.

Deprecated: see Args.Alarms.

type Appliance

type Appliance struct {
	pulumi.ResourceState

	// Names are the physical names after defaults.
	Names Resolved
	// Group is the Auto Scaling group.
	Group *autoscaling.Group
	// LaunchTemplate carries the image, the user-data and IMDSv2.
	LaunchTemplate *ec2.LaunchTemplate
	// Role and InstanceProfile are the instance's identity.
	Role            *iam.Role
	InstanceProfile *iam.InstanceProfile
	// Policy is the role's main inline policy document as exact JSON: the
	// bytes the role carries, so a golden of it is a review artifact.
	Policy pulumi.StringOutput
	// ManagedPolicies are the attachments of Args.IAM.ManagedPolicyARNs.
	ManagedPolicies []*iam.RolePolicyAttachment
	// SecurityGroup is the group the appliance created; nil with
	// Security.ExistingGroups.
	SecurityGroup *ec2.SecurityGroup
	// Rules are the separate rule resources (RulesSeparate, RulesLegacy).
	Rules []pulumi.Resource
	// Hook is the separate lifecycle hook; nil for an inline hook or none.
	Hook *autoscaling.LifecycleHook
	// Objects are the uploaded S3 objects, in the order of UserData.Objects
	// then Objects.Extra.
	Objects []*s3.BucketObjectv2
	// Alarms are the CloudWatch alarms, in the order of Alarms.Alarms.
	Alarms []*cloudwatch.MetricAlarm
}

Appliance is what New creates. With Compat.Flat it is a plain holder and not a registered component.

func New

func New(ctx *pulumi.Context, name string, args *Args, opts ...pulumi.ResourceOption) (*Appliance, error)

New creates the appliance. It refuses an invalid Args, all problems at once, before it registers anything.

The user-data is applied at launch: a change to it is a new launch template version, which Refresh rolls out.

type Args

type Args struct {
	// Names sets the physical names. Default: all derived from the
	// logical name.
	Names Names
	// Partition is the ARN partition. Default "aws".
	Partition string
	// Tags are added to every resource that takes tags.
	Tags map[string]string
	// Provider is the AWS provider the region, account and image lookups
	// go through. The resources take the options New is called with.
	Provider *aws.Provider

	// UserData is the instance's user-data. Required: a composed plan
	// (bootstrap.Plan.Render) or bootstrap.Verbatim. Its objects are
	// uploaded and its SSM parameters and object keys are granted to the
	// role.
	UserData *bootstrap.Rendered
	// Objects says where UserData.Objects are uploaded.
	Objects ObjectsArgs

	Image    ImageArgs
	Instance InstanceArgs
	Group    GroupArgs
	// Hook is the launch lifecycle hook; nil declares none.
	Hook *HookArgs
	// WarmPool is the warm pool; nil declares none. It needs Hook.
	WarmPool *WarmPoolArgs
	// Refresh is the group's instance refresh; nil declares none.
	Refresh *RefreshArgs

	IAM      IAMArgs
	Security SecurityArgs
	// Alarms are CloudWatch alarms on the group.
	//
	// Deprecated: monitoring is self-hosted. An alarm with no action is
	// read by nobody; export metrics from the box instead. Alarms keep
	// working and are removed no sooner than the next minor release.
	Alarms AlarmsArgs

	// Contribution is what the modules add (see Collect).
	Contribution Contribution

	// Compat keeps the names of an existing program.
	Compat Compat
}

Args is New's whole input.

type Compat

type Compat struct {
	// ComponentType overrides the component's Pulumi type, so a program
	// that already has a component of its own type keeps its URNs.
	ComponentType string
	// Flat registers no component: the children keep the caller's
	// parent, as in a program that never had one.
	Flat bool
	// Names are the logical names of the children.
	Names Logical
	// Aliases are added to the children, by kind.
	Aliases map[Kind][]pulumi.Alias
	// ComponentAliases are added to the component.
	ComponentAliases []pulumi.Alias
	// GroupTagsExcludeCommon leaves Args.Tags off the group's propagated
	// tags (only Name and ManagedBy remain), as programs did before.
	GroupTagsExcludeCommon bool
}

Compat keeps an existing program's resources where they are.

type Contribution

type Contribution = module.Contribution

Contribution is what modules add; see module.Contribution.

func Collect

func Collect(mods ...Module) (Contribution, error)

Collect merges the modules' contributions in the order given.

type GroupArgs

type GroupArgs struct {
	// Min, Max and Desired default to 1 (Max and Desired to Min).
	Min, Max, Desired int
	// SubnetIDs are required.
	SubnetIDs []pulumi.StringInput
	// HealthCheckType defaults to EC2.
	HealthCheckType string
	// GracePeriodSeconds defaults to 300.
	GracePeriodSeconds int
	// TargetGroupARNs registers the group's instances in these target
	// groups (front.Front.TargetGroupARNs). With HealthCheckType ELB a
	// failing target health check replaces the instance.
	TargetGroupARNs []pulumi.StringInput
	// EnabledMetrics are group metrics sent to CloudWatch (an alarm on
	// GroupInServiceInstances needs it).
	EnabledMetrics []string
	// TerminationPolicies say which instance a scale-in removes, in
	// order (OldestInstance, NewestInstance, OldestLaunchTemplate,
	// ClosestToNextInstanceHour, AllocationStrategy, Default). Empty:
	// the AWS default.
	TerminationPolicies []string
}

GroupArgs configures the Auto Scaling group.

type HookArgs

type HookArgs struct {
	Mode HookMode
	// HeartbeatTimeoutSeconds defaults to 900, bounded 30..7200.
	HeartbeatTimeoutSeconds int
	// DefaultResult is ABANDON (the default) or CONTINUE. CONTINUE needs
	// UnsafeDefaultContinue: an instance whose scripts never answered is
	// then put in service.
	DefaultResult         string
	UnsafeDefaultContinue bool
}

HookArgs is the EC2_INSTANCE_LAUNCHING hook.

type HookMode

type HookMode int

HookMode says where the lifecycle hook is declared.

const (
	// HookInline (the zero value) declares the hook on the group
	// (initial_lifecycle_hook), so it exists before the first instance
	// launches. A separate hook is created after the group and an instance
	// launched in between is not held by it.
	HookInline HookMode = iota
	// HookSeparate creates an aws.autoscaling.LifecycleHook resource.
	HookSeparate
)

type IAMArgs

type IAMArgs struct {
	// PermissionsBoundary is the full ARN of the boundary policy.
	PermissionsBoundary string
	// ManagedPolicyARNs are attached to the role. AmazonSSMManagedInstanceCore
	// lets the role read every parameter of the account; attach it only
	// for Session Manager.
	ManagedPolicyARNs []string
	// PolicyName is the inline policy's name. Default "appliance".
	PolicyName string
	// SSMParameters and ObjectKeys are granted in addition to the
	// user-data's.
	SSMParameters []string
	ObjectKeys    []string
	// Statements are added to the generated policy.
	Statements []Statement
	// StatementsFunc is like Statements for statements that need the
	// region, account or names.
	StatementsFunc func(PolicyContext) []Statement
	// Policy replaces the generated policy (the migration path of step
	// A). It excludes Statements, StatementsFunc, SSMParameters,
	// ObjectKeys, the user-data's grants and the modules'.
	Policy func(PolicyContext) (string, error)
	// ExtraInlinePolicies are further inline policies of the role.
	ExtraInlinePolicies []InlinePolicy
}

IAMArgs is the instance role.

type ImageArgs

type ImageArgs struct {
	// ID is a literal image id (or an output).
	ID pulumi.StringInput
	// NameFilter is an AMI name pattern, such as "al2023-ami-2023.*-kernel-6.1-arm64";
	// the newest available image wins.
	NameFilter string
	// Owners of the NameFilter lookup. Default "amazon".
	Owners []string
	// Architecture narrows the NameFilter lookup (x86_64, arm64).
	Architecture string
	// SSMParameter is a public or own parameter holding the image id.
	SSMParameter string
}

ImageArgs finds the AMI. Exactly one of ID, NameFilter and SSMParameter.

type InlinePolicy

type InlinePolicy struct {
	Name   string
	Policy func(PolicyContext) (string, error)
}

InlinePolicy is a named inline policy document.

type InstanceArgs

type InstanceArgs struct {
	// Type is the instance type. Exactly one of Type and Types.
	Type string
	// Types are several instance types, in priority order: the group
	// gets a mixed instances policy (on-demand, prioritized) whose
	// overrides are these types, and the launch template names none.
	// The types must share the image's architecture. A warm pool cannot
	// be combined with a mixed instances policy (an Auto Scaling
	// limit), so Types with WarmPool is refused.
	Types []string
	// HopLimit is the IMDS response hop limit, 1..64. Default 1. IMDSv2 is
	// always required.
	HopLimit int
	// RootVolume nil leaves the image's root volume alone.
	RootVolume *RootVolumeArgs
	// Volumes are extra EBS volumes in the launch template, encrypted
	// and deleted with the instance. A warm-pool stop and start keeps
	// them; a replacement starts with empty ones. The instance formats
	// and mounts them itself (a fragment of the consumer's).
	Volumes []VolumeArgs
	// PublicIP, when set, declares a network interface that associates
	// (true) or does not associate (false) a public address; nil
	// declares no interface and the group's subnets decide.
	PublicIP *bool
	// ExtraSecurityGroupIDs are attached next to the appliance's own
	// group.
	ExtraSecurityGroupIDs []pulumi.StringInput
}

InstanceArgs configures the launch template.

type Kind

type Kind string

Kind is a kind of child, for Compat.Aliases.

const (
	KindRole            Kind = "role"
	KindInstanceProfile Kind = "instance-profile"
	KindManagedPolicy   Kind = "managed-policy"
	KindSecurityGroup   Kind = "security-group"
	KindSecurityRule    Kind = "security-rule"
	KindLaunchTemplate  Kind = "launch-template"
	KindGroup           Kind = "group"
	KindHook            Kind = "hook"
	KindAlarm           Kind = "alarm"
	KindObject          Kind = "object"
)

Kinds.

type Logical

type Logical struct {
	// Role, InstanceProfile, SecurityGroup, LaunchTemplate and Group
	// default to the component's name.
	Role, InstanceProfile, SecurityGroup, LaunchTemplate, Group string
	// Hook defaults to "<name>-hook".
	Hook string
	// ManagedPolicy defaults to "<name>-managed-<index>".
	ManagedPolicy func(index int, arn string) string
	// Ingress and Egress default to "<name>-ingress-<i>[-<j>]" and
	// "<name>-egress-<i>[-<j>]" for separate rules.
	Ingress, Egress func(index, address int) string
	// Alarm defaults to "<name>-alarm-<suffix>".
	Alarm func(suffix string) string
	// Object defaults to "<name>-object-<first 12 of the digest>".
	Object func(bootstrap.Object) string
}

Logical overrides logical names. An empty field or nil func keeps the default, which is documented on each field.

type Module

type Module = module.Module

Module is an optional piece of an appliance; see module.Module.

type Names

type Names struct {
	// Base defaults to the logical name.
	Base string
	// Group defaults to Base.
	Group string
	// LaunchTemplate defaults to Base.
	LaunchTemplate string
	// Role defaults to Base; the instance profile has the same name.
	Role string
	// InstanceProfile defaults to Role.
	InstanceProfile string
	// Hook defaults to Group + "-launch".
	Hook string
	// SecurityGroup, when set, is the group's fixed name. Empty: a
	// generated name with the prefix Group + "-", so a replacement is
	// created before the old group is deleted.
	SecurityGroup string
}

Names are the physical names. An empty field takes its default from Base.

func (Names) Resolve

func (n Names) Resolve(name string) Resolved

Resolve applies the defaults for the logical name. A caller that renders the plan before calling New needs the group and hook names for bootstrap.Options.Lifecycle: use Resolved.Lifecycle.

type ObjectsArgs

type ObjectsArgs struct {
	// Bucket is required when the user-data has objects or Extra is set.
	Bucket string
	// KMSKeyARN encrypts the objects with that key (aws:kms); empty:
	// AES256.
	KMSKeyARN string
	// ContentType defaults to "text/plain".
	ContentType string
	// Extra are objects uploaded in addition to UserData.Objects, and
	// readable by the role. A migration whose old user-data fetches
	// objects the program owns lists them here.
	Extra []bootstrap.Object
	// Tags, when set, replaces the object's tags (default: Name = the
	// resource name, ManagedBy = pulumi, Tags).
	Tags func(bootstrap.Object) map[string]string
}

ObjectsArgs says where the user-data's S3 objects go.

type PolicyContext

type PolicyContext struct {
	Partition string
	Region    string
	Account   string
	Names     Resolved
	// Bucket is Args.Objects.Bucket.
	Bucket string
	// SSMParameters and ObjectKeys are every parameter and object key the
	// appliance reads: the user-data's, Args.IAM's and the modules'.
	SSMParameters []string
	ObjectKeys    []string
}

PolicyContext is what a policy callback may use.

type PolicyInput

type PolicyInput struct {
	Partition string
	Region    string
	Account   string
	// Group is the Auto Scaling group name. Empty: no group statement.
	Group string
	// Bucket holds ObjectKeys.
	Bucket        string
	SSMParameters []string
	ObjectKeys    []string
}

PolicyInput is the input of BootstrapStatements.

type ReadyCheck added in v0.2.0

type ReadyCheck = module.ReadyCheck

ReadyCheck gates the launch hook; see module.ReadyCheck.

type RefreshArgs

type RefreshArgs struct {
	MinHealthyPercentage int
	// MaxHealthyPercentage lets a refresh launch before it terminates
	// (100 to 200; 0 leaves it unset).
	MaxHealthyPercentage int
	// WarmupSeconds defaults to 300.
	WarmupSeconds int
	// SkipMatching skips instances that already match the launch template.
	SkipMatching bool
	// AutoRollback rolls the refresh back when it fails.
	AutoRollback bool
	// Triggers are extra triggers beyond the launch template. Default
	// none. Naming launch_template is redundant and makes Pulumi warn.
	Triggers []string
}

RefreshArgs is the rolling instance refresh the launch template change starts. The Auto Scaling API starts a refresh on every launch template version change whenever the group has a refresh block, so Triggers stays empty unless the caller wants another trigger.

type Resolved

type Resolved struct {
	Base            string
	Group           string
	LaunchTemplate  string
	Role            string
	InstanceProfile string
	Hook            string
	// SecurityGroup is the fixed name, or empty.
	SecurityGroup string
	// SecurityGroupPrefix is the generated-name prefix when SecurityGroup is
	// empty.
	SecurityGroupPrefix string
}

Resolved are the physical names after defaults.

func (Resolved) Lifecycle

func (r Resolved) Lifecycle() *bootstrap.Lifecycle

Lifecycle is what bootstrap.Options.Lifecycle needs to abandon the right hook of the right group.

type RootVolumeArgs

type RootVolumeArgs struct {
	// DeviceName defaults to /dev/xvda.
	DeviceName string
	// SizeGiB defaults to 8.
	SizeGiB int
	// Type defaults to gp3.
	Type string
	// KMSKeyID, when set, encrypts with that key instead of the default.
	KMSKeyID string
}

RootVolumeArgs is the root EBS volume. It is encrypted.

type Rule

type Rule struct {
	Description string
	// Protocol is tcp (default), udp, icmp, icmpv6 or -1.
	Protocol string
	// FromPort and ToPort; both 0 with -1.
	FromPort, ToPort int
	CIDRs            []string
	IPv6CIDRs        []string
	SourceGroups     []pulumi.StringInput
	// World acknowledges that an ingress rule opens a port to 0.0.0.0/0
	// or ::/0. Without it such a rule is refused.
	World bool
}

Rule is one security group rule.

type RuleStyle

type RuleStyle int

RuleStyle says how security group rules are declared.

const (
	// RulesInline (the zero value) puts the rules in the group's ingress and
	// egress blocks.
	RulesInline RuleStyle = iota
	// RulesSeparate creates one aws.vpc.SecurityGroupIngressRule or
	// SecurityGroupEgressRule per rule and address.
	RulesSeparate
	// RulesLegacy creates one aws.ec2.SecurityGroupRule per rule, the resource
	// older programs use.
	RulesLegacy
)

type SecurityArgs

type SecurityArgs struct {
	// VPCID is required unless ExistingGroups is set.
	VPCID pulumi.StringInput
	// ExistingGroups use these groups instead of creating one; Ingress
	// and Egress are then refused.
	ExistingGroups []pulumi.StringInput
	// Description cannot change in place. Default "<Base> appliance".
	Description string
	Style       RuleStyle
	Ingress     []Rule
	// Egress nil allows all outbound traffic; an empty non-nil slice
	// allows none.
	Egress []Rule
	// DeleteTimeout bounds the provider's retry of DependencyViolation
	// when a replaced group is deleted, e.g. "30m".
	DeleteTimeout string
}

SecurityArgs is the security group.

type Statement

type Statement = module.Statement

Statement is one IAM policy statement. The JSON field order is fixed, and Action and Resource are always arrays, so a document is byte-stable. It is defined in module, so a module can contribute statements without Pulumi.

func BootstrapStatements

func BootstrapStatements(in PolicyInput) []Statement

BootstrapStatements are the statements the bootstrap scripts need and no more: ssm:GetParameter on exactly the parameters, s3:GetObject on exactly the object keys and, when Group is set, the two Auto Scaling actions bootstrap-ready.service and the failure path call, on that group. A list that is empty yields no statement; the lists are sorted and de-duplicated.

type Step added in v0.2.0

type Step = module.Step

Step is an in-service step; see module.Step.

type VolumeArgs added in v0.4.0

type VolumeArgs struct {
	// DeviceName is /dev/sdf to /dev/sdp (on Nitro instances the volume
	// appears as an NVMe device; AL2023's udev rules link this name to
	// it). Required.
	DeviceName string
	// SizeGiB is required, 1..16384.
	SizeGiB int
	// Type defaults to gp3.
	Type string
	// IOPS and ThroughputMiBps, 0 keeps the type's baseline (gp3: 3000
	// IOPS and 125 MiB/s). Throughput is gp3 only.
	IOPS            int
	ThroughputMiBps int
	// KMSKeyID, when set, encrypts with that key instead of the default.
	KMSKeyID string
}

VolumeArgs is one extra EBS volume. It is encrypted and deleted with the instance.

type WarmPoolArgs

type WarmPoolArgs struct {
	// State is Stopped (default), Running or Hibernated.
	State string
	// MinSize defaults to 0.
	MinSize int
	// MaxGroupPreparedCapacity nil: no cap beyond the group's maximum.
	MaxGroupPreparedCapacity *int
	// ReuseOnScaleIn returns an instance that scales in to the pool
	// (stopped, its volumes kept) instead of terminating it, so a box
	// with a local cache keeps it.
	ReuseOnScaleIn bool
}

WarmPoolArgs is a pool of prepared instances.

type WatchCheck added in v0.2.0

type WatchCheck = module.WatchCheck

WatchCheck is a watchdog check; see module.WatchCheck.

Directories

Path Synopsis
Package bootstrap composes the cloud-init user-data (#cloud-config) of an instance from fragments.
Package bootstrap composes the cloud-init user-data (#cloud-config) of an instance from fragments.
Package front puts boxes behind a network load balancer.
Package front puts boxes behind a network load balancer.
internal
testutil
Package testutil renders contributions the way a box would receive them and runs the generated scripts against fake commands.
Package testutil renders contributions the way a box would receive them and runs the generated scripts against fake commands.
Package module is the extension mechanism of github.com/truvity/asg: a Module returns plain data, a Contribution, that the appliance and the bootstrap plan fold into the user-data, the instance role and the security group.
Package module is the extension mechanism of github.com/truvity/asg: a Module returns plain data, a Contribution, that the appliance and the bootstrap plan fold into the user-data, the instance role and the security group.
modules
selfregister
Package selfregister is a module that makes the box write its own private IP into a Route 53 hosted zone when it goes in service, so a stable name points at the current in-service instance (the address changes on every replacement or warm-pool takeover).
Package selfregister is a module that makes the box write its own private IP into a Route 53 hosted zone when it goes in service, so a stable name points at the current in-service instance (the address changes on every replacement or warm-pool takeover).
ssh
Package ssh is a module that gives the box SSH access through opkssh (OIDC sign-in), optional host certificates and an optional fixed host key from SSM, and opens TCP 22 to the listed networks.
Package ssh is a module that gives the box SSH access through opkssh (OIDC sign-in), optional host certificates and an optional fixed host key from SSM, and opens TCP 22 to the listed networks.
ssmcert
Package ssmcert is a module that delivers a TLS certificate, its key and an optional CA bundle from SSM Parameter Store into files under /run, for a daemon that loads them once at start and never reloads them.
Package ssmcert is a module that delivers a TLS certificate, its key and an optional CA bundle from SSM Parameter Store into files under /run, for a daemon that loads them once at start and never reloads them.
tunnel
Package tunnel is a module that runs a Cloudflare tunnel connector (cloudflared) on the box, in the right phases: the binary and the unit are installed on the first boot, warm-pool instances included, but the token is read from SSM and the unit started only on a boot into service, never in the warm pool.
Package tunnel is a module that runs a Cloudflare tunnel connector (cloudflared) on the box, in the right phases: the binary and the unit are installed on the first boot, warm-pool instances included, but the token is read from SSM and the unit started only on a boot into service, never in the warm pool.
watchdog
Package watchdog is a module that marks the instance Unhealthy when its local checks keep failing, so the Auto Scaling group replaces it.
Package watchdog is a module that marks the instance Unhealthy when its local checks keep failing, so the Auto Scaling group replaces it.

Jump to

Keyboard shortcuts

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