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
- Variables
- func IsAurora(engine string) bool
- type Client
- func (c *Client) AddTags(ctx context.Context, region, arn string, tags map[string]string) error
- func (c *Client) Adopt(ctx context.Context, region, id string, m Meta) error
- func (c *Client) CopySnapshot(ctx context.Context, region, source, target string, m Meta) error
- func (c *Client) CreateCluster(ctx context.Context, in CreateInput) error
- func (c *Client) CreateClusterSnapshot(ctx context.Context, region, clusterID, snapshotID string, m Meta) error
- func (c *Client) CreateInstance(ctx context.Context, in CreateInput) error
- func (c *Client) CreateSnapshot(ctx context.Context, region, instanceID, snapshotID string, m Meta) error
- func (c *Client) DeleteClusterSnapshot(ctx context.Context, region, snapshotID string) error
- func (c *Client) DeleteInstance(ctx context.Context, in DeleteInput) error
- func (c *Client) DeleteSnapshot(ctx context.Context, region, snapshotID string) error
- func (c *Client) DescribeDBClusterSnapshots(ctx context.Context, region, clusterID, snapshotID string) ([]ClusterSnapshot, error)
- func (c *Client) DescribeDBClusters(ctx context.Context, region string, id ...string) ([]Cluster, error)
- func (c *Client) DescribeDBInstances(ctx context.Context, region string, id ...string) ([]Instance, error)
- func (c *Client) DescribeDBParameterGroups(ctx context.Context, region string) ([]ParameterGroup, error)
- func (c *Client) DescribeDBSnapshots(ctx context.Context, region, instanceID string) ([]Snapshot, error)
- func (c *Client) ListTags(ctx context.Context, region, arn string) (map[string]string, error)
- func (c *Client) ModifyInstance(ctx context.Context, in ModifyInput) error
- func (c *Client) PlanClusterRestart(ctx context.Context, region string, lead time.Duration) ([]ClusterRestartItem, error)
- func (c *Client) PlanRestop(ctx context.Context, region string, minAge time.Duration) ([]RestopItem, error)
- func (c *Client) Restop(ctx context.Context, region string, items []RestopItem) error
- func (c *Client) Start(ctx context.Context, region, id string) error
- func (c *Client) StartCluster(ctx context.Context, region, id string) error
- func (c *Client) Stop(ctx context.Context, region, id, snapshotID string) error
- func (c *Client) StopCluster(ctx context.Context, region, id string) error
- func (c *Client) WithClock(now func() time.Time) *Client
- type Cluster
- type ClusterRestartItem
- type ClusterSnapshot
- type CreateInput
- type DeleteInput
- type Guard
- type Instance
- type Meta
- type ModifyInput
- type ParameterGroup
- type RestopItem
- type Snapshot
Constants ¶
const MaxStopDays = 7
MaxStopDays is how long AWS keeps a cluster stopped before it starts it again.
const ServiceName = "rds"
ServiceName is the key used in the guard ServicesEnabled map.
Variables ¶
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.
var ExpiresTag = tagPrefix + "expires"
ExpiresTag is the teardown timer written by the guard.
var ManagedTag = tagPrefix + "managed"
ManagedTag marks resources this control plane owns.
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).
var StoppedAtTag = tagPrefix + "stopped_at"
StoppedAtTag records when the control plane stopped an instance.
Functions ¶
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 (*Client) Adopt ¶
Adopt writes the managed tags to an unmanaged instance. It changes nothing else.
func (*Client) CopySnapshot ¶
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 ¶
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 ¶
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) 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) StartCluster ¶
StartCluster starts a managed cluster and clears the stopped marker.
func (*Client) Stop ¶
Stop stops a managed instance and records when, so an AWS auto restart can be undone.
func (*Client) StopCluster ¶
StopCluster stops a managed cluster and records when; AWS restarts it after MaxStopDays.
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).
type ClusterRestartItem ¶
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 ¶
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.
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 ¶
RestopItem is one instance AWS restarted after its maximum stop period.