Documentation
¶
Index ¶
- Constants
- Variables
- type CADirConfig
- type Cluster
- type ClusterPolicy
- type ClusterRef
- type ConfigProvider
- type CreateClusterInput
- type CreateStreamInput
- type DockerConfig
- type Handler
- func (h *Handler) ChaosOperations() []string
- func (h *Handler) ChaosRegions() []string
- func (h *Handler) ChaosServiceName() string
- func (h *Handler) ExtractOperation(c *echo.Context) string
- func (h *Handler) ExtractResource(c *echo.Context) string
- func (h *Handler) GetSupportedOperations() []string
- func (h *Handler) Handler() echo.HandlerFunc
- func (h *Handler) MatchPriority() int
- func (h *Handler) Name() string
- func (h *Handler) Reset()
- func (h *Handler) Restore(ctx context.Context, data []byte) error
- func (h *Handler) RouteMatcher() service.Matcher
- func (h *Handler) Shutdown(_ context.Context)
- func (h *Handler) Snapshot(ctx context.Context) []byte
- type IAMAuthConfig
- type IAMAuthIdentityProvider
- type IAMAuthResolver
- type IAMAuthSessionProvider
- type InMemoryBackend
- func (b *InMemoryBackend) Close()
- func (b *InMemoryBackend) ConnectAddr(identifier string) (string, int, bool)
- func (b *InMemoryBackend) CreateCluster(accountID, region string, in CreateClusterInput) (*Cluster, error)
- func (b *InMemoryBackend) CreateStream(clusterIdentifier string, in CreateStreamInput) (*Stream, error)
- func (b *InMemoryBackend) DeleteCluster(identifier string) (*Cluster, error)
- func (b *InMemoryBackend) DeleteClusterPolicy(identifier, expectedVersion string) (*ClusterPolicy, error)
- func (b *InMemoryBackend) DeleteStream(clusterIdentifier, streamIdentifier string) (*Stream, error)
- func (b *InMemoryBackend) EnableDockerEngine(cfg DockerConfig) error
- func (b *InMemoryBackend) EnableEngine(l Launcher)
- func (b *InMemoryBackend) EngineCAPEM() []byte
- func (b *InMemoryBackend) GetCluster(identifier string) (*Cluster, error)
- func (b *InMemoryBackend) GetClusterPolicy(identifier string) (*ClusterPolicy, error)
- func (b *InMemoryBackend) GetStream(clusterIdentifier, streamIdentifier string) (*Stream, error)
- func (b *InMemoryBackend) GetVpcEndpointServiceName(identifier, region string) (string, string, error)
- func (b *InMemoryBackend) ListClusters(nextToken string, maxResults int) ([]*Cluster, string, error)
- func (b *InMemoryBackend) ListStreams(clusterIdentifier, nextToken string, maxResults int) ([]*Stream, string, error)
- func (b *InMemoryBackend) ListTagsForResource(resourceARN string) (map[string]string, error)
- func (b *InMemoryBackend) PutClusterPolicy(identifier, policy, expectedVersion string) (*ClusterPolicy, error)
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) SetClock(now func() time.Time)
- func (b *InMemoryBackend) SetIAMAuth(r IAMAuthResolver)
- func (b *InMemoryBackend) SetLifecycleDelay(d time.Duration)
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- func (b *InMemoryBackend) TagResource(resourceARN string, tags map[string]string) error
- func (b *InMemoryBackend) UntagResource(resourceARN string, tagKeys []string) error
- func (b *InMemoryBackend) UpdateCluster(identifier string, in UpdateClusterInput) (*Cluster, error)
- type Instance
- type Launcher
- type MultiRegionProperties
- type Provider
- type Settings
- type Snapshottable
- type StorageBackend
- type Stream
- type StreamTarget
- type UpdateClusterInput
Constants ¶
const ( EngineStub = "stub" EngineDocker = "docker" )
Engine modes for the DSQL data plane.
Variables ¶
var ( // ErrClusterNotFound is returned when a cluster identifier does not exist. ErrClusterNotFound = awserr.New("cluster not found", awserr.ErrNotFound) // ErrStreamNotFound is returned when a stream identifier does not exist. ErrStreamNotFound = awserr.New("stream not found", awserr.ErrNotFound) // ErrPolicyNotFound is returned when a cluster has no resource policy set. ErrPolicyNotFound = awserr.New("cluster policy not found", awserr.ErrNotFound) // ErrDeletionProtected is returned when DeleteCluster is called on a // cluster with deletionProtectionEnabled set. ErrDeletionProtected = awserr.New("cluster has deletion protection enabled", awserr.ErrInvalidParameter) // ErrValidation is returned when request input fails validation. ErrValidation = awserr.New("invalid argument", awserr.ErrInvalidParameter) // ErrPolicyVersionMismatch is returned when an expectedPolicyVersion does // not match the cluster's current policy version. ErrPolicyVersionMismatch = awserr.New("policy version mismatch", awserr.ErrConflict) // ErrClusterQuotaExceeded is returned when an account/region would exceed // the emulated per-region cluster quota. ErrClusterQuotaExceeded = errors.New("cluster quota exceeded") // ErrStreamQuotaExceeded is returned when a cluster would exceed the // emulated per-cluster stream quota. ErrStreamQuotaExceeded = errors.New("stream quota exceeded") )
var ErrNoSnapshot = errors.New("backend does not support restore")
ErrNoSnapshot is returned when a backend does not support snapshot/restore.
var ErrTokenReused = awserr.New("client token was already used with different parameters", awserr.ErrConflict)
ErrTokenReused is a clientToken reused with different parameters; the SDK declares only ConflictException for it.
Functions ¶
This section is empty.
Types ¶
type CADirConfig ¶
type CADirConfig interface {
GetDSQLCADir() string
}
CADirConfig locates the directory persisting the data-plane CA; empty keeps it in memory.
type Cluster ¶
type Cluster struct {
CreationTime time.Time
PendingUntil time.Time
Policy *ClusterPolicy
MultiRegion *MultiRegionProperties
Tags map[string]string
Identifier string
ARN string
Endpoint string
Status string
KmsEncryptionKey string
AccountID string
Region string
DeletionProtectionEnabled bool
}
Cluster is the persisted representation of an Aurora DSQL cluster.
type ClusterPolicy ¶
ClusterPolicy is a resource-based policy attached to a cluster.
type ClusterRef ¶
ClusterRef identifies the cluster a data plane is launched for.
type ConfigProvider ¶
type ConfigProvider interface {
GetDSQLSettings() Settings
}
ConfigProvider supplies DSQL settings from the application config.
type CreateClusterInput ¶
type CreateClusterInput struct {
MultiRegion *MultiRegionProperties
Tags map[string]string
Policy string
KmsEncryptionKey string
DeletionProtectionEnabled bool
}
CreateClusterInput carries CreateCluster's optional fields.
type CreateStreamInput ¶
type CreateStreamInput struct {
Target *StreamTarget
Tags map[string]string
Format string
Ordering string
}
CreateStreamInput carries CreateStream's fields.
type DockerConfig ¶
type DockerConfig struct {
Runtime pgengine.Runtime
Ports *portalloc.Allocator
Logger *slog.Logger
// Auth returns the IAM wiring; nil refuses every connection.
Auth func() *IAMAuthConfig
// Now is the clock token expiry is checked against; nil means time.Now.
Now func() time.Time
Image string
Host string
CADir string
StartTimeout time.Duration
}
DockerConfig configures the docker data plane: one PostgreSQL container and one TLS proxy per cluster.
type Handler ¶
type Handler struct {
Backend StorageBackend
AccountID string
DefaultRegion string
// contains filtered or unexported fields
}
Handler is the HTTP handler for the Aurora DSQL REST-JSON control-plane API.
func NewHandler ¶
func NewHandler(backend StorageBackend) *Handler
NewHandler creates a new Aurora DSQL handler backed by backend.
func (*Handler) ChaosOperations ¶
ChaosOperations returns all operations that can be fault-injected.
func (*Handler) ChaosRegions ¶
ChaosRegions returns all regions this handler handles.
func (*Handler) ChaosServiceName ¶
ChaosServiceName returns the lowercase AWS service name for fault rule matching.
func (*Handler) ExtractOperation ¶
ExtractOperation extracts the operation name from the request.
func (*Handler) ExtractResource ¶
ExtractResource extracts the resource identifier from the request.
func (*Handler) GetSupportedOperations ¶
GetSupportedOperations returns the list of supported operations.
func (*Handler) Handler ¶
func (h *Handler) Handler() echo.HandlerFunc
Handler returns the Echo handler function for Aurora DSQL requests.
func (*Handler) MatchPriority ¶
MatchPriority returns the routing priority.
func (*Handler) Restore ¶
Restore implements persistence by delegating to the backend if it supports it.
func (*Handler) RouteMatcher ¶
RouteMatcher returns a function that matches Aurora DSQL REST API requests.
/tags/{arn} is SigV4-scoped rather than claimed unconditionally: it is a generic-tagging path many restjson1 services reuse verbatim (see .claude/memories/route-matcher-prefix-collision.md), so an unscoped claim here would swallow another service's own TagResource/UntagResource/ ListTagsForResource requests.
type IAMAuthConfig ¶
type IAMAuthConfig struct {
Identities IAMAuthIdentityProvider
Sessions IAMAuthSessionProvider
// Enforce evaluates dsql:DbConnect[Admin] against the caller's policies; off, any known principal may connect.
Enforce bool
}
IAMAuthConfig wires token verification to the credential stores.
type IAMAuthIdentityProvider ¶
type IAMAuthIdentityProvider interface {
ListAllAccessKeys() []iam.AccessKey
GetUserByAccessKeyID(accessKeyID string) (*iam.User, error)
GetPoliciesForUser(userName string) ([]string, error)
GetPoliciesForRole(roleName string) ([]string, error)
}
IAMAuthIdentityProvider is the slice of the IAM backend that token verification needs.
type IAMAuthResolver ¶
type IAMAuthResolver func() IAMAuthConfig
IAMAuthResolver returns the current IAM wiring; it is called per connection so IAM may be created later.
type IAMAuthSessionProvider ¶
type IAMAuthSessionProvider interface {
LookupSession(accessKeyID, sessionToken string) *sts.SessionInfo
}
IAMAuthSessionProvider resolves STS-issued temporary credentials.
type InMemoryBackend ¶
type InMemoryBackend struct {
// contains filtered or unexported fields
}
InMemoryBackend is the in-memory implementation of StorageBackend.
func NewInMemoryBackend ¶
func NewInMemoryBackend() *InMemoryBackend
NewInMemoryBackend creates a new in-memory Aurora DSQL backend.
func (*InMemoryBackend) Close ¶
func (b *InMemoryBackend) Close()
Close stops every cluster data plane and waits for the containers to be removed.
func (*InMemoryBackend) ConnectAddr ¶
func (b *InMemoryBackend) ConnectAddr(identifier string) (string, int, bool)
ConnectAddr returns where clients reach the cluster's database once its data plane is up.
func (*InMemoryBackend) CreateCluster ¶
func (b *InMemoryBackend) CreateCluster(accountID, region string, in CreateClusterInput) (*Cluster, error)
CreateCluster creates a new Aurora DSQL cluster. New clusters start CREATING and lazily transition to ACTIVE on the next read once clusterActivationDelay elapses -- see PARITY.md for why this is a lazy deadline rather than a background reconciler.
func (*InMemoryBackend) CreateStream ¶
func (b *InMemoryBackend) CreateStream(clusterIdentifier string, in CreateStreamInput) (*Stream, error)
CreateStream creates a Kinesis change-data-capture stream on a cluster. New streams start CREATING and lazily transition to ACTIVE on the next read once streamActivationDelay elapses.
func (*InMemoryBackend) DeleteCluster ¶
func (b *InMemoryBackend) DeleteCluster(identifier string) (*Cluster, error)
DeleteCluster marks a cluster DELETING; it is lazily removed from the table clusterDeletionDelay after this call, on the next resolve. A cluster with deletion protection enabled cannot be deleted.
func (*InMemoryBackend) DeleteClusterPolicy ¶
func (b *InMemoryBackend) DeleteClusterPolicy(identifier, expectedVersion string) (*ClusterPolicy, error)
DeleteClusterPolicy removes a cluster's resource-based policy. If expectedVersion is non-empty it must match the current policy version.
func (*InMemoryBackend) DeleteStream ¶
func (b *InMemoryBackend) DeleteStream(clusterIdentifier, streamIdentifier string) (*Stream, error)
DeleteStream marks a stream DELETING; it is lazily removed streamDeletionDelay later, on the next read.
func (*InMemoryBackend) EnableDockerEngine ¶
func (b *InMemoryBackend) EnableDockerEngine(cfg DockerConfig) error
EnableDockerEngine backs every cluster with a PostgreSQL container behind an IAM-token proxy.
func (*InMemoryBackend) EnableEngine ¶
func (b *InMemoryBackend) EnableEngine(l Launcher)
EnableEngine switches the backend to launcher-backed clusters: a cluster turns ACTIVE only once its data plane is up.
func (*InMemoryBackend) EngineCAPEM ¶
func (b *InMemoryBackend) EngineCAPEM() []byte
EngineCAPEM returns the PEM of the CA that signs docker-mode cluster endpoints, or nil without an engine.
func (*InMemoryBackend) GetCluster ¶
func (b *InMemoryBackend) GetCluster(identifier string) (*Cluster, error)
GetCluster returns the current information about a cluster.
func (*InMemoryBackend) GetClusterPolicy ¶
func (b *InMemoryBackend) GetClusterPolicy(identifier string) (*ClusterPolicy, error)
GetClusterPolicy returns a cluster's resource-based policy.
func (*InMemoryBackend) GetStream ¶
func (b *InMemoryBackend) GetStream(clusterIdentifier, streamIdentifier string) (*Stream, error)
GetStream returns the current information about a stream.
func (*InMemoryBackend) GetVpcEndpointServiceName ¶
func (b *InMemoryBackend) GetVpcEndpointServiceName(identifier, region string) (string, string, error)
GetVpcEndpointServiceName returns the VPC endpoint service name and cluster-specific VPC endpoint DNS name a client would use to reach the cluster privately. There is no real VPC/PrivateLink plane behind this emulator, so both values are wire-shaped but not backed by a functioning endpoint -- see PARITY.md.
func (*InMemoryBackend) ListClusters ¶
func (b *InMemoryBackend) ListClusters(nextToken string, maxResults int) ([]*Cluster, string, error)
ListClusters returns clusters ordered by identifier, paginated by nextToken/maxResults.
func (*InMemoryBackend) ListStreams ¶
func (b *InMemoryBackend) ListStreams(clusterIdentifier, nextToken string, maxResults int) ([]*Stream, string, error)
ListStreams returns a cluster's streams ordered by stream identifier, paginated by nextToken/maxResults.
func (*InMemoryBackend) ListTagsForResource ¶
func (b *InMemoryBackend) ListTagsForResource(resourceARN string) (map[string]string, error)
ListTagsForResource returns all tags on a cluster.
func (*InMemoryBackend) PutClusterPolicy ¶
func (b *InMemoryBackend) PutClusterPolicy(identifier, policy, expectedVersion string) (*ClusterPolicy, error)
PutClusterPolicy creates or replaces a cluster's resource-based policy. If expectedVersion is non-empty it must match the current policy version (optimistic concurrency), matching PutClusterPolicyInput's expectedPolicyVersion semantics.
func (*InMemoryBackend) Restore ¶
func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
Restore deserializes backend state from a JSON snapshot.
func (*InMemoryBackend) SetClock ¶
func (b *InMemoryBackend) SetClock(now func() time.Time)
SetClock replaces the wall clock used for lifecycle deadlines; nil restores time.Now.
func (*InMemoryBackend) SetIAMAuth ¶
func (b *InMemoryBackend) SetIAMAuth(r IAMAuthResolver)
SetIAMAuth registers the resolver consulted for every connection to a docker-backed cluster.
func (*InMemoryBackend) SetLifecycleDelay ¶
func (b *InMemoryBackend) SetLifecycleDelay(d time.Duration)
SetLifecycleDelay overrides the CREATING/UPDATING/DELETING windows for clusters and streams; 0 keeps the built-in values.
func (*InMemoryBackend) Snapshot ¶
func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
Snapshot serializes backend state to JSON.
func (*InMemoryBackend) TagResource ¶
func (b *InMemoryBackend) TagResource(resourceARN string, tags map[string]string) error
TagResource adds or replaces tags on a cluster identified by its ARN.
func (*InMemoryBackend) UntagResource ¶
func (b *InMemoryBackend) UntagResource(resourceARN string, tagKeys []string) error
UntagResource removes tags from a cluster by key.
func (*InMemoryBackend) UpdateCluster ¶
func (b *InMemoryBackend) UpdateCluster(identifier string, in UpdateClusterInput) (*Cluster, error)
UpdateCluster updates a cluster's mutable configuration and transitions it through UPDATING back to ACTIVE on the next read.
type Instance ¶
type Instance interface {
// Addr is the host and port clients connect to.
Addr() (string, int)
// Close stops the data plane and releases its resources.
Close(ctx context.Context)
}
Instance is one running cluster data plane.
type Launcher ¶
type Launcher interface {
Launch(ctx context.Context, ref ClusterRef) (Instance, error)
}
Launcher starts the data plane of a cluster and returns once the database accepts connections.
type MultiRegionProperties ¶
MultiRegionProperties mirrors types.MultiRegionProperties.
type Provider ¶
type Provider struct{}
Provider implements service.Provider for the Aurora DSQL service.
func (*Provider) Init ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init initializes the Aurora DSQL service backend and handler.
type Settings ¶
type Settings struct {
Engine string `json:"engine" env:"DSQL_ENGINE" default:"stub" help:"Engine: stub or docker."`
EngineImage string `json:"engine_image" env:"DSQL_ENGINE_IMAGE" default:"postgres:17" help:"PostgreSQL image."`
}
Settings holds service-level configuration for the DSQL backend. Kong picks the fields up when the struct is embedded in the root CLI command.
type Snapshottable ¶
type Snapshottable interface {
Snapshot(ctx context.Context) []byte
Restore(context.Context, []byte) error
}
Snapshottable is an optional interface a StorageBackend may implement to support snapshot/restore for persistence or test isolation.
type StorageBackend ¶
type StorageBackend interface {
CreateCluster(accountID, region string, in CreateClusterInput) (*Cluster, error)
GetCluster(identifier string) (*Cluster, error)
ListClusters(nextToken string, maxResults int) ([]*Cluster, string, error)
UpdateCluster(identifier string, in UpdateClusterInput) (*Cluster, error)
DeleteCluster(identifier string) (*Cluster, error)
GetClusterPolicy(identifier string) (*ClusterPolicy, error)
PutClusterPolicy(identifier, policy, expectedVersion string) (*ClusterPolicy, error)
DeleteClusterPolicy(identifier, expectedVersion string) (*ClusterPolicy, error)
GetVpcEndpointServiceName(identifier, region string) (serviceName, clusterVpcEndpoint string, err error)
CreateStream(clusterIdentifier string, in CreateStreamInput) (*Stream, error)
GetStream(clusterIdentifier, streamIdentifier string) (*Stream, error)
DeleteStream(clusterIdentifier, streamIdentifier string) (*Stream, error)
ListStreams(clusterIdentifier, nextToken string, maxResults int) ([]*Stream, string, error)
TagResource(resourceARN string, tags map[string]string) error
UntagResource(resourceARN string, tagKeys []string) error
ListTagsForResource(resourceARN string) (map[string]string, error)
Reset()
}
StorageBackend is the interface for the Aurora DSQL backend.
type Stream ¶
type Stream struct {
CreationTime time.Time
PendingUntil time.Time
Target *StreamTarget
Tags map[string]string
ClusterIdentifier string
StreamIdentifier string
ARN string
Status string
Format string
Ordering string
}
Stream is the persisted representation of an Aurora DSQL change-data-capture stream.
type StreamTarget ¶
StreamTarget mirrors types.TargetDefinitionMemberKinesis.
type UpdateClusterInput ¶
type UpdateClusterInput struct {
MultiRegion *MultiRegionProperties
DeletionProtectionEnabled *bool
KmsEncryptionKey string
}
UpdateClusterInput carries UpdateCluster's optional fields. A nil pointer means "leave unchanged"; KmsEncryptionKey uses the empty string to mean "unchanged" and the reserved value "AWS_OWNED_KMS_KEY" to mean "revert to the AWS owned key", matching the real API's documented semantics.
Source Files
¶
- bootstrap.go
- clock.go
- clusters.go
- engine.go
- engine_conns.go
- engine_docker.go
- errors.go
- handler.go
- handler_clusters.go
- handler_policy.go
- handler_streams.go
- handler_tags.go
- iam_auth.go
- idempotency.go
- interfaces.go
- jobs.go
- models.go
- multiregion.go
- persistence.go
- policy.go
- provider.go
- proxy.go
- routes.go
- settings.go
- shim.go
- store.go
- store_setup.go
- streams.go
- tags.go
- validation.go
- vpcendpoint.go
- wire.go