rds

package
v0.0.1-alpha.21 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package rds provides emulation of Amazon RDS.

Implemented: CreateDBInstance, DescribeDBInstances, DeleteDBInstance, DescribeDBEngineVersions, StopDBInstance, StartDBInstance, ModifyDBInstance, CreateDBSubnetGroup, DeleteDBSubnetGroup, DescribeDBSubnetGroups, CreateDBParameterGroup, DeleteDBParameterGroup, DescribeDBParameterGroups, DescribeOrderableDBInstanceOptions. All other operations return HTTP 501 Not Implemented.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBCluster

type DBCluster struct {
	DBClusterIdentifier string            `json:"DBClusterIdentifier"`
	DBClusterArn        string            `json:"DBClusterArn"`
	Engine              string            `json:"Engine"`
	EngineVersion       string            `json:"EngineVersion"`
	Status              string            `json:"Status"`
	MasterUsername      string            `json:"MasterUsername"`
	DatabaseName        string            `json:"DatabaseName,omitempty"`
	Port                int               `json:"Port"`
	Endpoint            string            `json:"Endpoint,omitempty"`
	ReaderEndpoint      string            `json:"ReaderEndpoint,omitempty"`
	MultiAZ             bool              `json:"MultiAZ"`
	StorageType         string            `json:"StorageType"`
	ClusterCreateTime   string            `json:"ClusterCreateTime,omitempty"`
	DBClusterMembers    []DBClusterMember `json:"DBClusterMembers,omitempty"`
}

DBCluster represents a stored Aurora DB cluster.

type DBClusterMember

type DBClusterMember struct {
	DBInstanceIdentifier          string `json:"DBInstanceIdentifier"`
	IsClusterWriter               bool   `json:"IsClusterWriter"`
	DBClusterParameterGroupStatus string `json:"DBClusterParameterGroupStatus"`
	PromotionTier                 int    `json:"PromotionTier"`
}

DBClusterMember represents one DB instance that belongs to an Aurora cluster.

type DBInstance

type DBInstance struct {
	DBInstanceIdentifier string    `json:"DBInstanceIdentifier"`
	DBInstanceClass      string    `json:"DBInstanceClass"`
	Engine               string    `json:"Engine"`
	EngineVersion        string    `json:"EngineVersion"`
	DBInstanceStatus     string    `json:"DBInstanceStatus"`
	MasterUsername       string    `json:"MasterUsername"`
	MasterUserPassword   string    `json:"MasterUserPassword,omitempty"`
	DBName               string    `json:"DBName,omitempty"`
	AllocatedStorage     int       `json:"AllocatedStorage"`
	Endpoint             *Endpoint `json:"Endpoint,omitempty"`
	DBInstanceArn        string    `json:"DBInstanceArn"`
	InstanceCreateTime   string    `json:"InstanceCreateTime,omitempty"`
	MultiAZ              bool      `json:"MultiAZ"`
	StorageType          string    `json:"StorageType"`
	Port                 int       `json:"Port"`
	DockerContainerID    string    `json:"DockerContainerID,omitempty"`
	HostPort             int       `json:"HostPort,omitempty"`
	DBClusterIdentifier  string    `json:"DBClusterIdentifier,omitempty"`
	DBSubnetGroupName    string    `json:"DBSubnetGroupName,omitempty"`
	VpcID                string    `json:"VpcId,omitempty"`
}

DBInstance represents a stored RDS DB instance.

type DBParameterGroup

type DBParameterGroup struct {
	DBParameterGroupName   string `json:"dbParameterGroupName"`
	DBParameterGroupFamily string `json:"dbParameterGroupFamily"`
	Description            string `json:"description"`
	DBParameterGroupArn    string `json:"dbParameterGroupArn"`
}

DBParameterGroup represents a stored RDS DB parameter group.

type DBSubnetGroup

type DBSubnetGroup struct {
	DBSubnetGroupName        string   `json:"DBSubnetGroupName"`
	DBSubnetGroupDescription string   `json:"DBSubnetGroupDescription"`
	DBSubnetGroupArn         string   `json:"DBSubnetGroupArn"`
	VpcId                    string   `json:"VpcId"`
	SubnetIds                []string `json:"SubnetIds"`
	Status                   string   `json:"Status"`
}

DBSubnetGroup represents a stored RDS DB subnet group.

type Endpoint

type Endpoint struct {
	Address string `json:"Address"`
	Port    int    `json:"Port"`
}

Endpoint represents the connection endpoint for a DB instance.

type Handler

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

Handler handles RDS Query-protocol requests.

func (*Handler) AddTagsToResource

func (h *Handler) AddTagsToResource(w http.ResponseWriter, r *http.Request)

AddTagsToResource adds metadata tags to an Amazon RDS resource.

func (*Handler) CreateDBCluster

func (h *Handler) CreateDBCluster(w http.ResponseWriter, r *http.Request)

CreateDBCluster creates a new Aurora DB cluster. Only aurora-mysql and aurora-postgresql engines are accepted. The cluster is a logical resource — Docker containers are started when instances are added via CreateDBInstance.

func (*Handler) CreateDBClusterSnapshot

func (h *Handler) CreateDBClusterSnapshot(w http.ResponseWriter, r *http.Request)

CreateDBClusterSnapshot creates a snapshot of an Aurora DB cluster.

func (*Handler) CreateDBInstance

func (h *Handler) CreateDBInstance(w http.ResponseWriter, r *http.Request)

CreateDBInstance creates a new RDS DB instance (metadata-only).

func (*Handler) CreateDBParameterGroup

func (h *Handler) CreateDBParameterGroup(w http.ResponseWriter, r *http.Request)

CreateDBParameterGroup creates a new DB parameter group.

func (*Handler) CreateDBSnapshot

func (h *Handler) CreateDBSnapshot(w http.ResponseWriter, r *http.Request)

CreateDBSnapshot creates a snapshot of a DB instance.

func (*Handler) CreateDBSubnetGroup

func (h *Handler) CreateDBSubnetGroup(w http.ResponseWriter, r *http.Request)

CreateDBSubnetGroup creates a new DB subnet group.

func (*Handler) DeleteDBCluster

func (h *Handler) DeleteDBCluster(w http.ResponseWriter, r *http.Request)

DeleteDBCluster deletes an Aurora DB cluster. The cluster is marked "deleting" immediately and removed asynchronously. Member instances are not automatically deleted — callers should delete instances first (matching AWS behaviour).

func (*Handler) DeleteDBClusterSnapshot

func (h *Handler) DeleteDBClusterSnapshot(w http.ResponseWriter, r *http.Request)

DeleteDBClusterSnapshot deletes a DB cluster snapshot.

func (*Handler) DeleteDBInstance

func (h *Handler) DeleteDBInstance(w http.ResponseWriter, r *http.Request)

DeleteDBInstance deletes a DB instance. It immediately transitions to "deleting" (matching AWS behaviour), then asynchronously stops/removes the Docker container (if any) and removes the record from the store. All Docker cleanup steps are best-effort and fault-tolerant: a missing or already-stopped container will not block deletion.

func (*Handler) DeleteDBParameterGroup

func (h *Handler) DeleteDBParameterGroup(w http.ResponseWriter, r *http.Request)

DeleteDBParameterGroup deletes a DB parameter group.

func (*Handler) DeleteDBSnapshot

func (h *Handler) DeleteDBSnapshot(w http.ResponseWriter, r *http.Request)

DeleteDBSnapshot deletes a DB snapshot.

func (*Handler) DeleteDBSubnetGroup

func (h *Handler) DeleteDBSubnetGroup(w http.ResponseWriter, r *http.Request)

DeleteDBSubnetGroup deletes a DB subnet group.

func (*Handler) DescribeDBClusterSnapshots

func (h *Handler) DescribeDBClusterSnapshots(w http.ResponseWriter, r *http.Request)

DescribeDBClusterSnapshots returns information about DB cluster snapshots.

func (*Handler) DescribeDBClusters

func (h *Handler) DescribeDBClusters(w http.ResponseWriter, r *http.Request)

DescribeDBClusters returns Aurora DB clusters, optionally filtered by identifier.

func (*Handler) DescribeDBEngineVersions

func (h *Handler) DescribeDBEngineVersions(w http.ResponseWriter, r *http.Request)

DescribeDBEngineVersions returns the supported engine versions.

func (*Handler) DescribeDBInstances

func (h *Handler) DescribeDBInstances(w http.ResponseWriter, r *http.Request)

DescribeDBInstances returns DB instances, optionally filtered by identifier.

func (*Handler) DescribeDBLogFiles

func (h *Handler) DescribeDBLogFiles(w http.ResponseWriter, r *http.Request)

DescribeDBLogFiles returns a list of DB log files for the DB instance.

func (*Handler) DescribeDBParameterGroups

func (h *Handler) DescribeDBParameterGroups(w http.ResponseWriter, r *http.Request)

DescribeDBParameterGroups returns DB parameter groups, optionally filtered by name.

func (*Handler) DescribeDBSnapshots

func (h *Handler) DescribeDBSnapshots(w http.ResponseWriter, r *http.Request)

DescribeDBSnapshots returns information about DB snapshots.

func (*Handler) DescribeDBSubnetGroups

func (h *Handler) DescribeDBSubnetGroups(w http.ResponseWriter, r *http.Request)

DescribeDBSubnetGroups returns DB subnet groups, optionally filtered by name.

func (*Handler) DescribeOrderableDBInstanceOptions

func (h *Handler) DescribeOrderableDBInstanceOptions(w http.ResponseWriter, r *http.Request)

DescribeOrderableDBInstanceOptions returns static orderable instance options.

func (*Handler) DownloadDBLogFilePortion

func (h *Handler) DownloadDBLogFilePortion(w http.ResponseWriter, r *http.Request)

DownloadDBLogFilePortion downloads all or a portion of a specified log file.

func (*Handler) GetInstanceLogs

func (h *Handler) GetInstanceLogs(w http.ResponseWriter, r *http.Request)

GetInstanceLogs returns the last 200 lines of logs for an RDS instance's Docker container. This is an emulator-only endpoint.

func (*Handler) ListTagsForResource

func (h *Handler) ListTagsForResource(w http.ResponseWriter, r *http.Request)

ListTagsForResource lists all tags on an Amazon RDS resource.

func (*Handler) ModifyDBCluster

func (h *Handler) ModifyDBCluster(w http.ResponseWriter, r *http.Request)

ModifyDBCluster updates settings on an Aurora DB cluster.

func (*Handler) ModifyDBInstance

func (h *Handler) ModifyDBInstance(w http.ResponseWriter, r *http.Request)

ModifyDBInstance modifies metadata properties of an existing DB instance.

func (*Handler) RebootDBInstance

func (h *Handler) RebootDBInstance(w http.ResponseWriter, r *http.Request)

RebootDBInstance reboots a DB instance.

func (*Handler) RemoveTagsFromResource

func (h *Handler) RemoveTagsFromResource(w http.ResponseWriter, r *http.Request)

RemoveTagsFromResource removes metadata tags from an Amazon RDS resource.

func (*Handler) RestoreDBInstanceFromDBSnapshot

func (h *Handler) RestoreDBInstanceFromDBSnapshot(w http.ResponseWriter, r *http.Request)

RestoreDBInstanceFromDBSnapshot restores a DB instance from a snapshot.

func (*Handler) StartDBCluster

func (h *Handler) StartDBCluster(w http.ResponseWriter, r *http.Request)

StartDBCluster starts a stopped Aurora DB cluster.

func (*Handler) StartDBInstance

func (h *Handler) StartDBInstance(w http.ResponseWriter, r *http.Request)

StartDBInstance starts a previously stopped DB instance.

func (*Handler) StopDBCluster

func (h *Handler) StopDBCluster(w http.ResponseWriter, r *http.Request)

StopDBCluster stops a running Aurora DB cluster.

func (*Handler) StopDBInstance

func (h *Handler) StopDBInstance(w http.ResponseWriter, r *http.Request)

StopDBInstance stops a running DB instance.

type Service

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

Service implements router.Service and router.QueryDispatcher for RDS. Uses the AWS Query protocol (form-encoded POST, XML responses) and identifies itself by the API version "2014-10-31".

func New

func New(cfg *config.Config, store state.Store, logger *zap.Logger, clk clock.Clock) *Service

New returns a configured RDS Service.

func (*Service) DispatchQuery

func (s *Service) DispatchQuery(w http.ResponseWriter, r *http.Request)

DispatchQuery satisfies router.QueryDispatcher; routes to the correct handler.

func (*Service) InitBus

func (s *Service) InitBus(bus *events.Bus)

InitBus wires the event bus for RDS lifecycle events and subscribes to Docker container events so instance status stays in sync with container state.

func (*Service) Name

func (s *Service) Name() string

Name satisfies router.Service.

func (*Service) Operations

func (s *Service) Operations() []op.Operation

Operations implements router.ProtocolService.

func (*Service) OwnsAction

func (s *Service) OwnsAction(action string) bool

OwnsAction satisfies router.QueryActionOwner.

func (*Service) OwnsVersion

func (s *Service) OwnsVersion(version string) bool

OwnsVersion satisfies router.QueryVersionOwner.

func (*Service) ReconcileContainers

func (s *Service) ReconcileContainers(ctx context.Context, containers []docker.ContainerSummary)

ReconcileContainers satisfies router.ContainerReconciler. It is called once after Docker becomes available at startup and syncs stored RDS instance statuses against the actual container state.

func (*Service) RegisterRoutes

func (s *Service) RegisterRoutes(r chi.Router)

RegisterRoutes satisfies router.Service. Registers emulator-only endpoints.

func (*Service) SetDocker

func (s *Service) SetDocker(dc *docker.Client)

SetDocker wires the Docker client for RDS container management and starts the DockGC background remove loop.

func (*Service) SetVPCResolver

func (s *Service) SetVPCResolver(r VPCNetworkResolver)

SetVPCResolver wires the EC2 VPC resolver for DB subnet group launches.

func (*Service) Stop

func (s *Service) Stop(ctx context.Context)

Stop cancels pending lifecycle transitions and cleans up Docker containers via the GC. The GC does a Docker-level sweep so even orphaned containers (whose store record was already deleted) are caught and removed.

func (*Service) SupportedProtocols

func (s *Service) SupportedProtocols() []codec.Codec

SupportedProtocols implements router.ProtocolService.

type VPCNetworkResolver

type VPCNetworkResolver interface {
	VpcIDForSubnet(ctx context.Context, subnetID string) string
	VPCNetworkStatus(ctx context.Context, vpcID string) string
	DockerNetworkForVpc(ctx context.Context, vpcID string) string
}

VPCNetworkResolver resolves DB subnet groups back to EC2 VPC network state.

Jump to

Keyboard shortcuts

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