Documentation
¶
Overview ¶
Package localstack manages LocalStack container lifecycle via testcontainers-go.
The package wraps the testcontainers-go LocalStack module with libtftest-specific defaults:
- Image is pinned to localstack/localstack:2026.04.0 (OSS) by default; LIBTFTEST_LOCALSTACK_IMAGE or Options.Image overrides for Pro or custom images
- Ports are bound via PortEndpoint with the explicit edge port rather than Endpoint(http) — the latter picks the lowest port, which is wrong for multi-port containers
- The AllServicesReady wait strategy uses the io.Reader signature introduced in testcontainers-go v0.30
- LIBTFTEST_CONTAINER_URL bypasses container startup entirely so a single external container can serve a whole test suite
See INV-0002 for the Pro vs. OSS image-version landscape and DESIGN-0001 for the container-lifecycle modes the package supports (per-test, per-package via harness, per-suite via LIBTFTEST_CONTAINER_URL).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllServicesReady ¶
AllServicesReady returns true if no service is in state "initializing" or "error". The signature matches testcontainers' wait.HTTPStrategy ResponseMatcher: func(body io.Reader) bool.
func WriteInitHooks ¶
WriteInitHooks writes all hooks to a temp directory and returns its path. The directory is suitable for bind-mounting at /etc/localstack/init/ready.d/.
Types ¶
type Config ¶
type Config struct {
Edition Edition
Image string
Services []string
AuthToken string
InitHooks []InitHook
}
Config configures a LocalStack container.
func (*Config) ResolveImage ¶
ResolveImage returns the container image to use, checking (in order): Config.Image, LIBTFTEST_LOCALSTACK_IMAGE env var, then edition-based default.
type Container ¶
type Container struct {
ID string
EdgeURL string
Edition Edition
Services map[string]string
// contains filtered or unexported fields
}
Container holds a running LocalStack container and its metadata.
func Start ¶
Start creates and starts a LocalStack container. It pre-checks that Docker is available, then uses testcontainers.Run with functional options. The container is considered ready only when AllServicesReady returns true on the /_localstack/health endpoint.
type Edition ¶
type Edition int
Edition represents a LocalStack product edition.
const ( // EditionAuto detects the edition from the LOCALSTACK_AUTH_TOKEN env var. // If the token is set, assumes Pro; otherwise Community. EditionAuto Edition = iota // EditionCommunity is the free, open-source LocalStack edition. EditionCommunity // EditionPro is the commercial LocalStack edition with additional services. EditionPro )
func DetectEdition ¶
DetectEdition resolves EditionAuto to a concrete edition based on the LOCALSTACK_AUTH_TOKEN environment variable.
func DetectEditionFromHealth ¶
DetectEditionFromHealth returns the Edition based on the health response's edition field.
type HealthResponse ¶
type HealthResponse struct {
Edition string `json:"edition"`
Version string `json:"version"`
Services map[string]string `json:"services"`
}
HealthResponse represents the JSON response from /_localstack/health.
func ParseHealth ¶
func ParseHealth(body []byte) (*HealthResponse, error)
ParseHealth parses a raw health response body into a HealthResponse.