sneakystack

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package sneakystack provides a LocalStack gap-filling HTTP proxy with an in-memory store, designed to surface AWS APIs that LocalStack itself does not cover (IAM Identity Center, Organizations, Control Tower, etc.).

The package exposes:

  • A Server that fronts both JSON-RPC (AWS json-1.1) and REST-XML protocols, dispatching to per-service handlers registered under sneakystack/services

  • A Store interface backed by plain Go maps (no external DB dependency); handlers stash and retrieve their state via the Store, keeping the package import-cycle-clean

  • A Sidecar implementation that lets libtftest's harness drive sneakystack alongside LocalStack as a single addressable endpoint

sneakystack also ships as a standalone Docker container (cmd/sneakystack), so consumer test suites that aren't using libtftest can still benefit from the gap-fillers.

See DESIGN-0001 for the Sidecar architecture and the rationale for plain Go maps over go-memdb.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = fmt.Errorf("resource not found")

ErrNotFound indicates the requested resource was not found.

Functions

This section is empty.

Types

type Config

type Config struct {
	Services []string // Service names to handle (e.g., "sso-admin", "organizations").
}

Config configures a sneakystack proxy.

type Filter

type Filter struct {
	Parent string            // E.g. instance ARN, OU id.
	Tags   map[string]string // Optional tag match.
}

Filter constrains List results.

type MapStore

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

MapStore is a Store backed by plain Go maps protected by sync.RWMutex.

func NewMapStore

func NewMapStore() *MapStore

NewMapStore creates an empty MapStore.

func (*MapStore) Delete

func (s *MapStore) Delete(_ context.Context, kind, id string) error

Delete removes an object.

func (*MapStore) Get

func (s *MapStore) Get(_ context.Context, kind, id string) (any, error)

Get retrieves an object by kind and id.

func (*MapStore) List

func (s *MapStore) List(_ context.Context, kind string, _ Filter) ([]any, error)

List returns all objects of a given kind, optionally filtered.

func (*MapStore) Put

func (s *MapStore) Put(_ context.Context, kind, id string, obj any) error

Put stores an object.

type Proxy

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

Proxy is an HTTP reverse proxy that routes requests to local service handlers for gap services and forwards everything else to LocalStack.

func NewProxy

func NewProxy(store Store, downstreamURL string) (*Proxy, error)

NewProxy creates a sneakystack proxy that forwards to the given downstream URL.

func (*Proxy) RegisterHandler

func (p *Proxy) RegisterHandler(servicePrefix string, handler ServiceHandler)

RegisterHandler maps a service prefix (from X-Amz-Target) to a handler.

func (*Proxy) ServeHTTP

func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP routes requests based on the X-Amz-Target header. If the target matches a registered handler, the request is handled locally. Otherwise, it is forwarded to LocalStack.

type ServiceHandler

type ServiceHandler interface {
	Handle(w http.ResponseWriter, r *http.Request)
}

ServiceHandler handles AWS API requests for a specific service.

type Sidecar

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

Sidecar wraps a Proxy as a harness.Sidecar implementation.

func NewSidecar

func NewSidecar(cfg Config) *Sidecar

NewSidecar creates a sneakystack Sidecar for use with harness.Run.

func (*Sidecar) Healthy

func (s *Sidecar) Healthy(ctx context.Context) bool

Healthy returns true when the sidecar is ready to accept traffic.

func (*Sidecar) Start

func (s *Sidecar) Start(ctx context.Context, localstackURL string) (string, error)

Start launches the sneakystack proxy on an ephemeral port and returns the URL callers should use instead of the raw LocalStack URL.

func (*Sidecar) Stop

func (s *Sidecar) Stop(ctx context.Context) error

Stop shuts down the proxy server.

type Store

type Store interface {
	Put(ctx context.Context, kind, id string, obj any) error
	Get(ctx context.Context, kind, id string) (any, error)
	List(ctx context.Context, kind string, filter Filter) ([]any, error)
	Delete(ctx context.Context, kind, id string) error
}

Store is the persistence abstraction for service handlers. Each service gets its own typed wrapper built on top of this.

Directories

Path Synopsis
Package services hosts the per-service handlers for sneakystack's LocalStack-gap-filling proxy.
Package services hosts the per-service handlers for sneakystack's LocalStack-gap-filling proxy.

Jump to

Keyboard shortcuts

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