appconfigdata

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 22 Imported by: 0

README

AppConfig Data

Parity grade: A · SDK aws-sdk-go-v2/service/appconfigdata@v1.23.20 · last audited 2026-07-24 (128350087c039303f08b6d8113ec9f9ac4cbc4b9)

Coverage

Metric Value
Operations audited 2 (2 ok)
Known gaps 1
Deferred items 0
Resource leaks clean
Known gaps
  • appconfigdata's config content store (SetConfiguration) is entirely self-contained and is never populated by services/appconfig (the control-plane service that owns applications/environments/configuration-profiles/hosted-config-versions/deployments). SetConfiguration is reachable only via the internal dashboard admin endpoints (cli.go:6091, dashboard/ui.go:1345/2020), not from any real AppConfig deployment flow. Real AWS semantics: GetLatestConfiguration serves whatever the active deployment for the app/env/profile currently is; StartConfigurationSession 404s (ErrNoActiveDeployment) until one exists. gopherstack instead requires a manual/dashboard SetConfiguration call to seed content per app/env/profile key -- functionally similar per-session but with no link to services/appconfig's deployment lifecycle (no deployment-state transitions, no rollback-on-deploy, no version pinning to a specific DeploymentId even though ConfigVersion.DeploymentId exists as a field and is never populated). This is a cross-service wiring gap in services/appconfig + cli.go/dashboard, out of scope for an appconfigdata-only edit -- fixing it means wiring a Set-style accessor into cli.go's provider-init sequence (the same pattern used by wireIoTRules/wireAppSyncLambda for other control-plane/data-plane service pairs), and this pass's mandate explicitly forbids editing cli.go. Re-confirmed still open and already tracked: bd issue gopherstack-uiyi ("appconfigdata disconnected from appconfig control-plane"), open, priority 2.

More

Documentation

Overview

Package appconfigdata provides an in-memory stub for the AWS AppConfigData service, which is used to retrieve deployed configuration data for applications at runtime.

Index

Constants

View Source
const (
	// DefaultJanitorInterval is how often the janitor sweeps expired sessions.
	DefaultJanitorInterval = time.Hour
)
View Source
const (

	// DefaultSessionTTL is how long a session may be idle before the janitor evicts it.
	// AWS tokens expire after ~24 h; we use 1 h idle TTL with absolute 24 h cap.
	DefaultSessionTTL = 1 * time.Hour
)

Variables

View Source
var (
	// ErrSessionNotFound is returned when the requested session token does not exist in the map.
	ErrSessionNotFound = errors.New("bad request: invalid configuration token")
	// ErrTokenCorrupted is returned when the token format or HMAC is invalid.
	ErrTokenCorrupted = errors.New("bad request: configuration token is corrupted")
	// ErrTokenExpired is returned when the session token has passed its expiry time.
	// AWS returns BadRequestException (400) for expired tokens, not 401.
	ErrTokenExpired = errors.New("bad request: configuration token has expired")
	// ErrProfileNotFound is returned when no configuration has been stored for a profile.
	ErrProfileNotFound = errors.New("resource not found: configuration profile not found")
	// ErrResourceRemoved is returned when a session's app/env/profile was deleted after the session started.
	ErrResourceRemoved = errors.New("resource not found: application, environment, or profile no longer exists")
	// ErrContentTooLarge is returned when configuration content exceeds the size limit.
	ErrContentTooLarge = errors.New("bad request: content exceeds maximum size of 1 MiB")
	// ErrInvalidPollInterval is returned when RequiredMinimumPollIntervalInSeconds is out of range.
	ErrInvalidPollInterval = errors.New(
		"bad request: RequiredMinimumPollIntervalInSeconds must be 0 or between 15 and 86400",
	)
	// ErrPollTooFrequent is returned when a client polls faster than its declared minimum interval.
	ErrPollTooFrequent = errors.New(
		"bad request: polling too frequently — wait for the interval in Next-Poll-Interval-In-Seconds",
	)
	// ErrContentTypeMismatch is returned when content is declared as JSON but is not valid JSON.
	ErrContentTypeMismatch = errors.New("bad request: content is not valid for the declared content type")
	// ErrNoActiveDeployment is returned when StartConfigurationSession is called for a profile
	// that has no active deployment (no configuration has been published yet).
	ErrNoActiveDeployment = errors.New(
		"resource not found: no active deployment found for the given application, environment, and configuration profile",
	)
	// ErrIdentifierTooLong is returned when an identifier exceeds the maximum allowed length.
	ErrIdentifierTooLong = errors.New("bad request: identifier exceeds maximum length of 128 characters")
)

Functions

This section is empty.

Types

type ConfigVersion

type ConfigVersion struct {
	UpdatedAt     time.Time `json:"updatedAt"`
	Content       string    `json:"content"`
	ContentType   string    `json:"contentType"`
	ContentHash   string    `json:"contentHash"`
	VersionLabel  string    `json:"versionLabel"`
	DeploymentID  string    `json:"deploymentId"`
	VersionNumber int       `json:"versionNumber"`
}

ConfigVersion records a historical snapshot of configuration content.

type ConfigurationProfile

type ConfigurationProfile struct {
	UpdatedAt                      time.Time       `json:"updatedAt"`
	ApplicationIdentifier          string          `json:"applicationIdentifier"`
	EnvironmentIdentifier          string          `json:"environmentIdentifier"`
	ConfigurationProfileIdentifier string          `json:"configurationProfileIdentifier"`
	Content                        string          `json:"content"`
	ContentType                    string          `json:"contentType"`
	ContentHash                    string          `json:"contentHash"`
	VersionLabel                   string          `json:"versionLabel"`
	DeploymentID                   string          `json:"deploymentId"`
	History                        []ConfigVersion `json:"history"`
	VersionNumber                  int             `json:"versionNumber"`
}

ConfigurationProfile stores configuration content for an application/environment/profile combination.

type Handler

type Handler struct {
	Backend *InMemoryBackend
}

Handler is the Echo HTTP handler for AppConfigData operations.

func NewHandler

func NewHandler(backend *InMemoryBackend) *Handler

NewHandler creates a new AppConfigData Handler.

func (*Handler) ChaosOperations

func (h *Handler) ChaosOperations() []string

ChaosOperations returns all operations that can be fault-injected.

func (*Handler) ChaosRegions

func (h *Handler) ChaosRegions() []string

ChaosRegions returns all regions this handler instance handles.

func (*Handler) ChaosServiceName

func (h *Handler) ChaosServiceName() string

ChaosServiceName returns the lowercase AWS service name for fault rule matching.

func (*Handler) ExtractOperation

func (h *Handler) ExtractOperation(c *echo.Context) string

ExtractOperation returns the operation name based on the request path.

func (*Handler) ExtractResource

func (h *Handler) ExtractResource(c *echo.Context) string

ExtractResource returns a stable, non-sensitive resource label for telemetry. For GetLatestConfiguration, it resolves the session to return app/env/profile; for other operations it returns a fixed label to avoid high-cardinality metrics.

func (*Handler) GetSupportedOperations

func (h *Handler) GetSupportedOperations() []string

GetSupportedOperations returns the list of supported operations.

func (*Handler) Handler

func (h *Handler) Handler() echo.HandlerFunc

Handler returns the Echo handler function for AppConfigData operations.

func (*Handler) MatchPriority

func (h *Handler) MatchPriority() int

MatchPriority returns the routing priority.

func (*Handler) Name

func (h *Handler) Name() string

Name returns the service name.

func (*Handler) Restore

func (h *Handler) Restore(ctx context.Context, data []byte) error

Restore implements persistence.Persistable by delegating to the backend.

func (*Handler) RouteMatcher

func (h *Handler) RouteMatcher() service.Matcher

RouteMatcher returns a function matching AppConfigData requests.

func (*Handler) Snapshot

func (h *Handler) Snapshot(ctx context.Context) []byte

Snapshot implements persistence.Persistable by delegating to the backend. Handler previously had no Snapshot/Restore of its own -- and neither did InMemoryBackend -- so cli.go's generic setupPersistence (which type-asserts the registered service.Registerable, i.e. the Handler, for a Snapshot/Restore pair) never picked AppConfigData up at all: dead wiring, with no persistence underneath it either. This delegation (matching the cleanrooms/appconfig/codecommit pattern) is what wires AppConfigData into persistence for the first time.

func (*Handler) StartWorker

func (h *Handler) StartWorker(ctx context.Context) error

StartWorker starts the background janitor for AppConfig Data retrieval sessions.

type InMemoryBackend

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

InMemoryBackend implements StorageBackend for AppConfigData.

func NewInMemoryBackend

func NewInMemoryBackend() *InMemoryBackend

NewInMemoryBackend creates a new InMemoryBackend with a freshly generated signing key.

func (*InMemoryBackend) DeleteProfile

func (b *InMemoryBackend) DeleteProfile(app, env, profile string) bool

DeleteProfile removes a configuration profile and its associated sessions.

func (*InMemoryBackend) EndSession

func (b *InMemoryBackend) EndSession(token string) bool

EndSession terminates the session with the given token. Returns false if not found.

func (*InMemoryBackend) GetLatestConfiguration

func (b *InMemoryBackend) GetLatestConfiguration(
	token string,
) ([]byte, string, string, string, string, error)

GetLatestConfiguration retrieves configuration data for the given token and returns a new token. The token is rotated on every successful call; the old token enters a short grace window so that clients can safely retry after a transient failure without losing their session.

Returned values: content, contentType, nextToken, contentHash, versionLabel, error.

func (*InMemoryBackend) GetStats

func (b *InMemoryBackend) GetStats() ServiceStats

GetStats returns aggregate service statistics.

func (*InMemoryBackend) ListProfiles

func (b *InMemoryBackend) ListProfiles() []ConfigurationProfile

ListProfiles returns all stored configuration profiles.

func (*InMemoryBackend) ListSessions

func (b *InMemoryBackend) ListSessions() []Session

ListSessions returns all active sessions.

func (*InMemoryBackend) ListSessionsSafe

func (b *InMemoryBackend) ListSessionsSafe() []SafeSession

ListSessionsSafe returns all active sessions with tokens truncated for safe display. Use this for admin list endpoints; never return full tokens in list responses.

func (*InMemoryBackend) LookupSession

func (b *InMemoryBackend) LookupSession(token string) *Session

LookupSession returns the session for the given token, or nil if not found. This is a read-only lookup; it does not rotate the token.

func (*InMemoryBackend) Restore

func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error

Restore deserializes backend state from a snapshot. It implements persistence.Persistable.

func (*InMemoryBackend) SetConfiguration

func (b *InMemoryBackend) SetConfiguration(app, env, profile, content, contentType string) error

SetConfiguration stores or updates configuration content for a profile. Returns ErrContentTooLarge if content exceeds maxContentBytes. Returns ErrContentTypeMismatch if contentType indicates JSON but content is not valid JSON.

func (*InMemoryBackend) Snapshot

func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte

Snapshot serializes the backend state to JSON. It implements persistence.Persistable.

func (*InMemoryBackend) StartSession

func (b *InMemoryBackend) StartSession(
	app, env, profile string,
	pollIntervalInSeconds int,
) (string, error)

StartSession creates a new retrieval session and returns the initial token. pollIntervalInSeconds must be 0 (use default) or between minPollIntervalSeconds and maxPollIntervalSeconds (inclusive). Returns ErrNoActiveDeployment when no configuration has been published for the profile.

func (*InMemoryBackend) SweepExpiredSessions

func (b *InMemoryBackend) SweepExpiredSessions(ctx context.Context, ttl time.Duration)

SweepExpiredSessions removes sessions that have been idle longer than ttl OR that have exceeded the absolute session lifetime (sessionAbsoluteMaxTTL from CreatedAt). Expired grace tokens are also purged in the same pass.

type Janitor

type Janitor struct {
	Backend    *InMemoryBackend
	Interval   time.Duration
	SessionTTL time.Duration
}

Janitor is the AppConfig Data background worker that prunes expired retrieval sessions.

func NewJanitor

func NewJanitor(backend *InMemoryBackend) *Janitor

NewJanitor creates a new AppConfig Data Janitor with default settings.

func (*Janitor) Run

func (j *Janitor) Run(ctx context.Context)

Run runs the janitor loop until ctx is cancelled.

type Provider

type Provider struct{}

Provider implements service.Provider for the AppConfigData service.

func (*Provider) Init

Init initialises the AppConfigData backend and handler.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the service provider name.

type SafeSession

type SafeSession struct {
	CreatedAt                      time.Time `json:"createdAt"`
	LastAccessedAt                 time.Time `json:"lastAccessedAt"`
	LastPollAt                     time.Time `json:"lastPollAt"`
	ExpiresAt                      time.Time `json:"expiresAt"`
	TokenPrefix                    string    `json:"tokenPrefix"` // first8…last4, e.g. "abcd1234...ef12"
	TokenFamilyID                  string    `json:"tokenFamilyId"`
	ApplicationIdentifier          string    `json:"applicationIdentifier"`
	EnvironmentIdentifier          string    `json:"environmentIdentifier"`
	ConfigurationProfileIdentifier string    `json:"configurationProfileIdentifier"`
	PollIntervalInSeconds          int       `json:"pollIntervalInSeconds"`
	PollCount                      int       `json:"pollCount"`
}

SafeSession mirrors Session but truncates the token for safe display in admin UIs. The full token is never returned in list responses; only via authenticated audit endpoints.

type ServiceStats

type ServiceStats struct {
	LastSweepAt              time.Time `json:"lastSweepAt"`
	SessionTTL               string    `json:"sessionTtl"`
	JanitorPeriod            string    `json:"janitorPeriod"`
	SessionCount             int       `json:"sessionCount"`
	ProfileCount             int       `json:"profileCount"`
	TotalPollCount           int64     `json:"totalPollCount"`
	TotalPollFailures        int64     `json:"totalPollFailures"`
	ConfigurationChangeCount int64     `json:"configurationChangeCount"`
}

ServiceStats holds aggregate metrics for the AppConfigData service.

type Session

type Session struct {
	CreatedAt                      time.Time `json:"createdAt"`
	LastAccessedAt                 time.Time `json:"lastAccessedAt"`
	LastPollAt                     time.Time `json:"lastPollAt"`
	ExpiresAt                      time.Time `json:"expiresAt"`
	Token                          string    `json:"token"`
	TokenFamilyID                  string    `json:"tokenFamilyId"`
	PreviousContentHash            string    `json:"previousContentHash"`
	ApplicationIdentifier          string    `json:"applicationIdentifier"`
	EnvironmentIdentifier          string    `json:"environmentIdentifier"`
	ConfigurationProfileIdentifier string    `json:"configurationProfileIdentifier"`
	PollIntervalInSeconds          int       `json:"pollIntervalInSeconds"`
	PollCount                      int       `json:"pollCount"`
}

Session represents an active configuration retrieval session.

type StorageBackend

type StorageBackend interface {
	// Snapshot and Restore implement persistence.Persistable. Handler
	// delegates to them (see persistence.go) so cli.go's generic
	// setupPersistence picks AppConfigData up.
	Snapshot(ctx context.Context) []byte
	Restore(ctx context.Context, data []byte) error

	// SetConfiguration stores or updates configuration content for a profile.
	SetConfiguration(app, env, profile, content, contentType string) error
	// StartSession creates a new retrieval session and returns the initial token.
	StartSession(app, env, profile string, pollIntervalInSeconds int) (string, error)
	// GetLatestConfiguration retrieves configuration for the token.
	// Returns content, contentType, nextToken, contentHash, versionLabel.
	GetLatestConfiguration(
		token string,
	) (content []byte, contentType string, nextToken string, contentHash string, versionLabel string, err error)
	// LookupSession returns the session for the given token, or nil if not found.
	LookupSession(token string) *Session
	// ListProfiles returns all stored configuration profiles.
	ListProfiles() []ConfigurationProfile
	// ListSessions returns all active sessions (includes full tokens — use only internally).
	ListSessions() []Session
	// ListSessionsSafe returns all active sessions with tokens truncated for safe display.
	ListSessionsSafe() []SafeSession
	// EndSession terminates the session with the given token. Returns false if not found.
	EndSession(token string) bool
	// DeleteProfile removes a configuration profile and its associated sessions.
	DeleteProfile(app, env, profile string) bool
	// GetStats returns aggregate service statistics.
	GetStats() ServiceStats
	// SweepExpiredSessions removes sessions idle longer than ttl or past absolute expiry.
	SweepExpiredSessions(ctx context.Context, ttl time.Duration)
}

StorageBackend defines the operations supported by the AppConfigData in-memory backend.

Jump to

Keyboard shortcuts

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