ec2snap

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: 10 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 ec2snap manages EBS snapshots over the signed EC2 Query API (version 2016-11-15). Deletes only touch snapshots that carry the managed tag.

Index

Constants

View Source
const ReasonExpired = "snapshot_expired"

ReasonExpired is the cleanup plan item kind for a snapshot past retention.

View Source
const ServiceName = "ebs"

ServiceName is the key used in the guard ServicesEnabled map.

Variables

View Source
var (
	ErrNotManaged = errors.New("ec2snap: snapshot is not managed by this control plane")
	ErrNoSource   = errors.New("ec2snap: an instance or a volume id is required")
)

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 snapshots this control plane created.

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

Service is the EC2 Query API.

Functions

This section is empty.

Types

type Client

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

Client is the lazy EBS 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) CreateSnapshots

func (c *Client) CreateSnapshots(ctx context.Context, in CreateInput) ([]Snapshot, error)

CreateSnapshots takes crash consistent snapshots of all volumes of an instance (CreateSnapshots) or of one volume (CreateSnapshot). Every snapshot gets the managed tags and the expires tag from the guard.

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) DescribeSnapshots

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

DescribeSnapshots lists snapshots owned by the account (all pages), optionally for one volume.

func (*Client) DescribeVolumes

func (c *Client) DescribeVolumes(ctx context.Context, region, volumeID string) ([]Volume, error)

DescribeVolumes lists volumes (all pages), optionally the one named.

func (*Client) PlanRetentionFor

func (c *Client) PlanRetentionFor(ctx context.Context, region string, r Retention) ([]Deletion, error)

PlanRetentionFor reads the snapshots and plans deletions. It changes nothing.

type CreateInput

type CreateInput struct {
	Region, InstanceID, VolumeID, Description string
	ExcludeBoot                               bool
	Meta                                      Meta
}

CreateInput names what to snapshot: every volume of an instance, or one volume.

type Deletion

type Deletion struct {
	ID, VolumeID string
	StartTime    time.Time
	SizeGB       int
	Reason       string
}

Deletion is one snapshot the sweeper would remove.

func PlanRetention

func PlanRetention(list []Snapshot, r Retention) []Deletion

PlanRetention is a dry run: per volume it keeps the newest managed snapshot of each of the Daily most recent days and the Weekly most recent weeks, and lists the rest. Untagged and unmanaged snapshots are never listed.

type Guard

type Guard interface {
	Tags(m cloudguard.TagMeta) map[string]string
}

Guard is the tag source.

type Meta

type Meta = cloudguard.TagMeta

Meta carries the values behind the mandatory tags.

type Retention

type Retention struct{ Daily, Weekly int }

Retention is how many daily and weekly snapshots to keep per volume.

type Snapshot

type Snapshot struct {
	ID, VolumeID, State, Description string
	SizeGB                           int
	StartTime                        time.Time
	Tags                             map[string]string
}

Snapshot is the read view of one EBS snapshot.

func (Snapshot) ExpiresAt

func (s Snapshot) ExpiresAt() time.Time

ExpiresAt is the expires tag, zero when absent.

func (Snapshot) Managed

func (s Snapshot) Managed() bool

Managed reports the ownership tag.

type Volume

type Volume struct {
	ID, Type, State, AZ, InstanceID string
	SizeGB                          int
	Encrypted                       bool
	Tags                            map[string]string
}

Volume is the read view of one EBS volume.

func (Volume) Managed

func (v Volume) 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