rds

package
v1.5.8 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package rds talks to RDS and Aurora over the signed Query API (version 2014-10-31). Creates go through the guard; only managed resources are changed.

Index

Constants

View Source
const MaxStopDays = 7

MaxStopDays is how long AWS keeps a cluster stopped before it starts it again.

View Source
const ServiceName = "rds"

ServiceName is the key used in the guard ServicesEnabled map.

Variables

View Source
var (
	ErrRefused      = errors.New("rds: refused")
	ErrNotManaged   = errors.New("rds: resource is not managed by this control plane")
	ErrNeedsConfirm = errors.New("rds: Multi-AZ and Aurora need an explicit confirm")
	ErrNoTimer      = errors.New("rds: a stop or teardown timer (expires tag) is required")
	ErrNeedsRoot    = errors.New("rds: delete needs a root caller and a final snapshot")
)

Errors the API layer maps to HTTP statuses.

View Source
var ExpiresTag = tagPrefix + "expires"

ExpiresTag is the teardown timer written by the guard.

View Source
var ManagedTag = tagPrefix + "managed"

ManagedTag marks resources this control plane owns.

View Source
var Service = awsx.Service{Name: "rds", Prefix: "rds", SigningName: "rds"}

Service is the RDS Query API (endpoint prefix and version checked against the botocore model).

View Source
var StoppedAtTag = tagPrefix + "stopped_at"

StoppedAtTag records when the control plane stopped an instance.

Functions

func IsAurora

func IsAurora(engine string) bool

IsAurora reports an Aurora engine name.

Types

type Client

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

Client is the lazy RDS module; it makes no call until a method runs.

func New

func New(c *awsx.Client, g Guard) *Client

New wraps a shared client and guard.

func (*Client) AddTags

func (c *Client) AddTags(ctx context.Context, region, arn string, tags map[string]string) error

AddTags writes tags to a resource ARN.

func (*Client) Adopt

func (c *Client) Adopt(ctx context.Context, region, id string, m Meta) error

Adopt writes the managed tags to an unmanaged instance. It changes nothing else.

func (*Client) CopySnapshot

func (c *Client) CopySnapshot(ctx context.Context, region, source, target string, m Meta) error

CopySnapshot copies a snapshot inside the region; the copy is tagged managed.

func (*Client) CreateCluster

func (c *Client) CreateCluster(ctx context.Context, in CreateInput) error

CreateCluster creates an Aurora cluster with no members; add one with CreateInstance and ClusterID.

func (*Client) CreateClusterSnapshot

func (c *Client) CreateClusterSnapshot(ctx context.Context, region, clusterID, snapshotID string, m Meta) error

CreateClusterSnapshot snapshots a managed cluster and tags the snapshot as managed.

func (*Client) CreateInstance

func (c *Client) CreateInstance(ctx context.Context, in CreateInput) error

CreateInstance creates an instance, or an Aurora member when ClusterID is set. The master password is generated by RDS and kept in Secrets Manager.

func (*Client) CreateSnapshot

func (c *Client) CreateSnapshot(ctx context.Context, region, instanceID, snapshotID string, m Meta) error

CreateSnapshot snapshots a managed instance and tags the snapshot as managed.

func (*Client) DeleteClusterSnapshot

func (c *Client) DeleteClusterSnapshot(ctx context.Context, region, snapshotID string) error

DeleteClusterSnapshot removes a cluster snapshot only when it carries the managed tag.

func (*Client) DeleteInstance

func (c *Client) DeleteInstance(ctx context.Context, in DeleteInput) error

DeleteInstance deletes a managed instance after a final snapshot. It never skips the snapshot.

func (*Client) DeleteSnapshot

func (c *Client) DeleteSnapshot(ctx context.Context, region, snapshotID string) error

DeleteSnapshot removes a snapshot only when it carries the managed tag.

func (*Client) DescribeDBClusterSnapshots

func (c *Client) DescribeDBClusterSnapshots(ctx context.Context, region, clusterID, snapshotID string) ([]ClusterSnapshot, error)

DescribeDBClusterSnapshots lists cluster snapshots (all pages), optionally for one cluster or one snapshot.

func (*Client) DescribeDBClusters

func (c *Client) DescribeDBClusters(ctx context.Context, region string, id ...string) ([]Cluster, error)

DescribeDBClusters lists clusters (all pages), or the one named.

func (*Client) DescribeDBInstances

func (c *Client) DescribeDBInstances(ctx context.Context, region string, id ...string) ([]Instance, error)

DescribeDBInstances lists instances (all pages), or the one named.

func (*Client) DescribeDBParameterGroups

func (c *Client) DescribeDBParameterGroups(ctx context.Context, region string) ([]ParameterGroup, error)

DescribeDBParameterGroups lists parameter groups (all pages).

func (*Client) DescribeDBSnapshots

func (c *Client) DescribeDBSnapshots(ctx context.Context, region, instanceID string) ([]Snapshot, error)

DescribeDBSnapshots lists manual and automated snapshots, optionally for one instance.

func (*Client) ListTags

func (c *Client) ListTags(ctx context.Context, region, arn string) (map[string]string, error)

ListTags reads the tags of a resource ARN.

func (*Client) ModifyInstance

func (c *Client) ModifyInstance(ctx context.Context, in ModifyInput) error

ModifyInstance resizes a managed instance. The guard sees the instance tags, so the class allowlist and caps apply to the new class.

func (*Client) PlanClusterRestart

func (c *Client) PlanClusterRestart(ctx context.Context, region string, lead time.Duration) ([]ClusterRestartItem, error)

PlanClusterRestart lists managed stopped clusters whose automatic restart falls inside the lead window. It only reports, so the owner can stop them again or act.

func (*Client) PlanRestop

func (c *Client) PlanRestop(ctx context.Context, region string, minAge time.Duration) ([]RestopItem, error)

PlanRestop lists managed instances that we stopped, that are running again and whose stop is older than minAge. It never changes anything.

func (*Client) Restop

func (c *Client) Restop(ctx context.Context, region string, items []RestopItem) error

Restop stops each planned instance again.

func (*Client) Start

func (c *Client) Start(ctx context.Context, region, id string) error

Start starts a managed instance and clears the stopped marker.

func (*Client) StartCluster

func (c *Client) StartCluster(ctx context.Context, region, id string) error

StartCluster starts a managed cluster and clears the stopped marker.

func (*Client) Stop

func (c *Client) Stop(ctx context.Context, region, id, snapshotID string) error

Stop stops a managed instance and records when, so an AWS auto restart can be undone.

func (*Client) StopCluster

func (c *Client) StopCluster(ctx context.Context, region, id string) error

StopCluster stops a managed cluster and records when; AWS restarts it after MaxStopDays.

func (*Client) WithClock

func (c *Client) WithClock(now func() time.Time) *Client

WithClock replaces the clock, for tests.

type Cluster

type Cluster struct {
	ID, ARN, Engine, EngineVersion, Status string
	Endpoint, ReaderEndpoint               string
	Port                                   int
	MultiAZ, Encrypted                     bool
	Members                                []string
	SecretARN, MasterUsername              string
	AutoRestartAt                          time.Time
	Tags                                   map[string]string
}

Cluster is the read view of one DB cluster (Aurora or Multi-AZ).

func (Cluster) Managed

func (k Cluster) Managed() bool

Managed reports the ownership tag.

type ClusterRestartItem

type ClusterRestartItem struct {
	ID            string
	StoppedAt     time.Time
	AutoRestartAt time.Time
}

ClusterRestartItem is a stopped cluster that AWS will start again soon.

type ClusterSnapshot

type ClusterSnapshot struct {
	ID, ARN, ClusterID, Engine, Status, Type string
	AllocatedGB                              int
	CreatedAt                                time.Time
	Tags                                     map[string]string
}

ClusterSnapshot is the read view of one cluster snapshot.

func (ClusterSnapshot) Managed

func (s ClusterSnapshot) Managed() bool

Managed reports the ownership tag.

type CreateInput

type CreateInput struct {
	Account, Region, ID string
	Engine, Class       string
	MasterUsername      string
	DBName              string
	AllocatedGB         int
	MultiAZ             bool
	// ClusterID adds an Aurora member to an existing cluster.
	ClusterID        string
	SubnetGroup      string
	SecurityGroupIDs []string
	BackupRetention  int
	// Confirm is the explicit flag Multi-AZ and Aurora require.
	Confirm             bool
	Meta                Meta
	EstimatedMonthlyUSD float64
}

CreateInput describes one instance or cluster create.

type DeleteInput

type DeleteInput struct {
	Region, ID      string
	Root            bool
	FinalSnapshotID string
}

DeleteInput is the delete request. Root and a final snapshot are both mandatory.

type Guard

type Guard interface {
	Check(ctx context.Context, r cloudguard.CreateRequest) cloudguard.Decision
	Tags(m cloudguard.TagMeta) map[string]string
}

Guard is the create gate and tag source.

type Instance

type Instance struct {
	ID, ARN, Engine, EngineVersion, Class, Status string
	Host                                          string
	Port                                          int
	AllocatedGB                                   int
	MultiAZ, Encrypted, Public                    bool
	ClusterID, SecretARN, MasterUsername, DBName  string
	AutoRestartAt                                 time.Time
	Tags                                          map[string]string
}

Instance is the read view of one DB instance.

func (Instance) Managed

func (i Instance) Managed() bool

Managed reports the ownership tag.

type Meta

type Meta = cloudguard.TagMeta

Meta carries the values behind the mandatory tags.

type ModifyInput

type ModifyInput struct {
	Account, Region, ID string
	Class               string
	AllocatedGB         int
	ApplyImmediately    bool
	EstimatedMonthlyUSD float64
}

ModifyInput changes class or storage of a managed instance.

type ParameterGroup

type ParameterGroup struct{ Name, Family, Description string }

ParameterGroup is the read view of one parameter group.

type RestopItem

type RestopItem struct {
	ID        string
	StoppedAt time.Time
}

RestopItem is one instance AWS restarted after its maximum stop period.

type Snapshot

type Snapshot struct {
	ID, ARN, InstanceID, Engine, Status, Type string
	AllocatedGB                               int
	CreatedAt                                 time.Time
	Tags                                      map[string]string
}

Snapshot is the read view of one DB snapshot.

func (Snapshot) Managed

func (s Snapshot) Managed() bool

Managed reports the ownership tag.

Jump to

Keyboard shortcuts

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