ami

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package ami provides internal AMI-to-OS mapping utilities for holodeck. This package enables simplified configuration by allowing users to specify an OS identifier instead of a specific AMI ID.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exists

func Exists(id string) bool

Exists checks if an OS ID is in the registry.

func List

func List() []string

List returns all supported OS IDs in sorted order.

func NormalizeArch

func NormalizeArch(arch string) string

NormalizeArch converts architecture aliases to canonical form.

Types

type EC2ImageDescriber

type EC2ImageDescriber interface {
	DescribeImages(ctx context.Context, params *ec2.DescribeImagesInput,
		optFns ...func(*ec2.Options)) (*ec2.DescribeImagesOutput, error)
}

EC2ImageDescriber defines the subset of EC2 operations needed for AMI resolution.

type OSFamily

type OSFamily string

OSFamily groups similar operating systems for template selection and package management.

const (
	// OSFamilyDebian includes Ubuntu, Debian, and similar distributions.
	OSFamilyDebian OSFamily = "debian"
	// OSFamilyRHEL includes Rocky Linux, Fedora, RHEL, CentOS, and similar.
	OSFamilyRHEL OSFamily = "rhel"
	// OSFamilyAmazon includes Amazon Linux distributions.
	OSFamilyAmazon OSFamily = "amazon"
)

type OSImage

type OSImage struct {
	// ID is the short identifier (e.g., "ubuntu-22.04").
	ID string

	// Name is the display name (e.g., "Ubuntu 22.04 LTS (Jammy Jellyfish)").
	Name string

	// Family groups related OSes for template selection.
	Family OSFamily

	// SSHUsername is the default SSH user for this OS.
	SSHUsername string

	// PackageManager indicates the package management system.
	PackageManager PackageManager

	// MinRootVolumeGB is the minimum root volume size in gigabytes.
	MinRootVolumeGB int32

	// OwnerID is the AWS account ID that owns the AMI, used as a filter in
	// DescribeImages. Use "amazon" for Amazon-owned images.
	OwnerID string

	// NamePattern is the pattern for DescribeImages filter. Use %s as a
	// placeholder for architecture (e.g., "x86_64" or "arm64").
	NamePattern string

	// SSMPath is the SSM Parameter Store path for looking up the latest AMI.
	// Use %s as a placeholder for architecture. Empty if SSM is not supported.
	SSMPath string

	// NameArchMap maps EC2 architecture names to the format used in AMI name
	// patterns. If nil, EC2 arch names are used directly (x86_64, arm64).
	// Ubuntu uses "amd64" instead of "x86_64", so it needs: {"x86_64": "amd64"}.
	NameArchMap map[string]string

	// Architectures lists the supported CPU architectures (x86_64, arm64).
	Architectures []string
}

OSImage defines metadata for an operating system image.

func All

func All() []OSImage

All returns all OSImage entries in sorted order by ID.

func Get

func Get(id string) (*OSImage, bool)

Get returns an OSImage by ID. Returns nil and false if not found.

type PackageManager

type PackageManager string

PackageManager indicates the package management system used by an OS.

const (
	// PackageManagerAPT is the Advanced Package Tool used by Debian-based
	// distributions.
	PackageManagerAPT PackageManager = "apt"
	// PackageManagerDNF is the Dandified YUM package manager used by modern
	// RHEL-based distributions.
	PackageManagerDNF PackageManager = "dnf"
	// PackageManagerYUM is the Yellowdog Updater Modified package manager
	// used by older RHEL-based distributions.
	PackageManagerYUM PackageManager = "yum"
)

type ResolvedAMI

type ResolvedAMI struct {
	// ImageID is the resolved AMI ID.
	ImageID string

	// SSHUsername is the default SSH user for this OS.
	SSHUsername string

	// OSFamily is the family of the resolved OS.
	OSFamily OSFamily

	// PackageManager is the package manager used by the resolved OS.
	PackageManager PackageManager
}

ResolvedAMI contains the resolved AMI information along with metadata needed for provisioning.

type Resolver

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

Resolver resolves OS IDs to AMI IDs using SSM Parameter Store or EC2 DescribeImages API.

func NewResolver

func NewResolver(
	ec2Client EC2ImageDescriber,
	ssmClient SSMParameterGetter,
	region string,
) *Resolver

NewResolver creates a new AMI resolver.

func (*Resolver) Resolve

func (r *Resolver) Resolve(
	ctx context.Context,
	osID, arch string,
) (*ResolvedAMI, error)

Resolve looks up the AMI for the given OS ID, region, and architecture. It first tries SSM Parameter Store (if available for the OS), then falls back to EC2 DescribeImages API.

type SSMParameterGetter

type SSMParameterGetter interface {
	GetParameter(ctx context.Context, params *ssm.GetParameterInput,
		optFns ...func(*ssm.Options)) (*ssm.GetParameterOutput, error)
}

SSMParameterGetter defines the subset of SSM operations needed for AMI resolution.

Jump to

Keyboard shortcuts

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