Documentation
¶
Overview ¶
Package lightsail talks to Amazon Lightsail over the signed JSON 1.1 API (target prefix Lightsail_20161128). Reads are open; creates go through the guard and changes need the managed tag.
Index ¶
- Constants
- Variables
- type Blueprint
- type Bundle
- type Client
- func (c *Client) Create(ctx context.Context, in CreateInput) error
- func (c *Client) CreateSnapshot(ctx context.Context, region, instance, name string, m Meta) error
- func (c *Client) Delete(ctx context.Context, in DeleteInput) error
- func (c *Client) DeleteSnapshot(ctx context.Context, region, name string) error
- func (c *Client) GetBlueprints(ctx context.Context, region string) ([]Blueprint, error)
- func (c *Client) GetBundles(ctx context.Context, region string) ([]Bundle, error)
- func (c *Client) GetInstance(ctx context.Context, region, name string) (Instance, error)
- func (c *Client) GetInstanceSnapshots(ctx context.Context, region string) ([]Snapshot, error)
- func (c *Client) GetInstances(ctx context.Context, region string) ([]Instance, error)
- func (c *Client) GetRegions(ctx context.Context, region string) ([]Region, error)
- func (c *Client) GetStaticIps(ctx context.Context, region string) ([]StaticIP, error)
- func (c *Client) Reboot(ctx context.Context, region, name string) error
- func (c *Client) Start(ctx context.Context, region, name string) error
- func (c *Client) Stop(ctx context.Context, region, name string) error
- type CreateInput
- type DeleteInput
- type Guard
- type Instance
- type Meta
- type Region
- type Snapshot
- type StaticIP
Constants ¶
const ServiceName = "lightsail"
ServiceName is the key used in the guard ServicesEnabled map.
Variables ¶
var ( ErrRefused = errors.New("lightsail: refused") ErrNotManaged = errors.New("lightsail: resource is not managed by this control plane") ErrNeedsConfirm = errors.New("lightsail: delete needs the resource name typed as confirmation") ErrNoTimer = errors.New("lightsail: a teardown timer (expires tag) is required") )
Errors the API layer maps to HTTP statuses.
var ManagedTag = tagPrefix + "managed"
ManagedTag marks resources this control plane owns.
var Service = awsx.Service{Name: "lightsail", Prefix: "lightsail", SigningName: "lightsail", TargetPrefix: "Lightsail_20161128"}
Service is the Lightsail JSON API.
Functions ¶
This section is empty.
Types ¶
type Bundle ¶
type Bundle struct {
ID, Name string
PriceUSD float64
CPUs int
RAMGB, DiskGB float64
TransferGB int
Active bool
SupportedPlatforms []string
}
Bundle is one size and price plan. PriceUSD comes from AWS, never from a table here.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the lazy Lightsail module; it makes no call until a method runs.
func (*Client) Create ¶
func (c *Client) Create(ctx context.Context, in CreateInput) error
Create makes one managed instance after the guard, bundle allowlist and instance cap pass. The price is read from GetBundles, so the monthly cap and per create limit see the real figure.
func (*Client) CreateSnapshot ¶
CreateSnapshot snapshots a managed instance and tags the snapshot as managed.
func (*Client) Delete ¶
func (c *Client) Delete(ctx context.Context, in DeleteInput) error
Delete removes a managed instance after a typed confirm. Add-ons are not force deleted.
func (*Client) DeleteSnapshot ¶
DeleteSnapshot deletes a snapshot this control plane created.
func (*Client) GetBlueprints ¶
GetBlueprints lists blueprints (all pages).
func (*Client) GetBundles ¶
GetBundles lists bundles (all pages).
func (*Client) GetInstance ¶
GetInstance reads one instance by name.
func (*Client) GetInstanceSnapshots ¶
GetInstanceSnapshots lists instance snapshots (all pages).
func (*Client) GetInstances ¶
GetInstances lists instances (all pages) in a region.
func (*Client) GetRegions ¶
GetRegions lists Lightsail regions with their availability zones.
func (*Client) GetStaticIps ¶
GetStaticIps lists static addresses (all pages).
type CreateInput ¶
type CreateInput struct {
Account, Region, Name, Zone string
Blueprint, Bundle, KeyPair string
Meta Meta
AllowedBundles []string
// MaxManaged is the most managed instances the account may hold in the region; 0 refuses every create.
MaxManaged int
}
CreateInput describes one instance create. AllowedBundles and MaxManaged come from runtime settings.
type DeleteInput ¶
type DeleteInput struct{ Region, Name, Confirm string }
DeleteInput is a delete request. Confirm must repeat the instance name.
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 {
Name, ARN, State, BlueprintID, BundleID string
PublicIP, PrivateIP, Zone, Region string
CPUs int
RAMGB, DiskGB float64
CreatedAt time.Time
Managed bool
Tags map[string]string
}
Instance is the read view of one instance.