ec2

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: May 18, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handle

func Handle(ctx context.Context, evt Event) (bool, error)

func Running

func Running()

Types

type ChangeRecordInput

type ChangeRecordInput struct {
	Zone   string
	Action string
	Type   string
	TTL    int64
	Name   string
	Value  string
}

type Config

type Config map[string]string

func NewConfig

func NewConfig() Config

type Database

type Database interface {
	Insert(*ec2.Instance) error
	Find(string) (*ec2.Instance, error)
	Remove(string) error
}

type Event

type Event struct {
	Version    string
	ID         string
	DetailType string `json:"detail-type"`
	Source     string
	Account    string
	Time       string
	Region     string
	Test       bool
	Detail     EventDetail
	Resources  []string
}

type EventDetail

type EventDetail struct {
	Instance string `json:"instance-id"`
	State    string
}

type Handler

type Handler struct {
	Poll time.Duration
	Max  time.Duration
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(evt Event, ctx context.Context, cfg Config, svc Service, db Database) *Handler

func (*Handler) Attach

func (h *Handler) Attach(instance *ec2.Instance) error

func (*Handler) AttachAddress

func (h *Handler) AttachAddress(instance *ec2.Instance, tagName, tagValue string) error

func (*Handler) AttachRecord

func (h *Handler) AttachRecord(instance *ec2.Instance, tagName, tagValue string) error

func (*Handler) AttachVolume

func (h *Handler) AttachVolume(instance *ec2.Instance, tagName, tagValue string) error

func (*Handler) Detach

func (h *Handler) Detach(instance *ec2.Instance) error

func (*Handler) Remove

func (h *Handler) Remove(id string) error

func (*Handler) Retrieve

func (h *Handler) Retrieve(id string) (*ec2.Instance, error)

func (*Handler) Running

func (h *Handler) Running() error

func (*Handler) Store

func (h *Handler) Store(instance *ec2.Instance) error

func (*Handler) Terminated

func (h *Handler) Terminated() error

func (*Handler) Wait

func (h *Handler) Wait(id string) (*ec2.Instance, error)

type InstanceDatabase

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

func NewDatabase

func NewDatabase(table string) *InstanceDatabase

func (*InstanceDatabase) Find

func (d *InstanceDatabase) Find(id string) (*ec2.Instance, error)

func (*InstanceDatabase) Insert

func (d *InstanceDatabase) Insert(i *ec2.Instance) error

func (*InstanceDatabase) Remove

func (d *InstanceDatabase) Remove(id string) error

type InstanceService

type InstanceService struct {
	Region string
	// contains filtered or unexported fields
}

func NewService

func NewService(region string) *InstanceService

func (*InstanceService) AttachAddress

func (s *InstanceService) AttachAddress(instance *ec2.Instance, address *ec2.Address) error

func (*InstanceService) AttachRecord

func (s *InstanceService) AttachRecord(id, tagName, tagValue string) error

func (*InstanceService) AttachVolume

func (s *InstanceService) AttachVolume(instance *ec2.Instance, volume *ec2.Volume) error

func (*InstanceService) ChangeRecord

func (s *InstanceService) ChangeRecord(change *ChangeRecordInput) error

func (*InstanceService) FindAddress

func (s *InstanceService) FindAddress(id, tagName, tagValue string) (*ec2.Address, error)

func (*InstanceService) FindVolume

func (s *InstanceService) FindVolume(id, tagName, tagValue string) (*ec2.Volume, error)

func (*InstanceService) GetInstance

func (s *InstanceService) GetInstance(id string) (*ec2.Instance, error)

func (*InstanceService) GetInstanceZone

func (s *InstanceService) GetInstanceZone(id string) (string, error)

func (*InstanceService) GetTags

func (s *InstanceService) GetTags(raw []*ec2.Tag) map[string]string

type Service

type Service interface {
	GetInstance(id string) (*ec2.Instance, error)
	GetInstanceZone(id string) (string, error)
	GetTags([]*ec2.Tag) map[string]string

	FindVolume(id, tagName, tagValue string) (*ec2.Volume, error)
	FindAddress(id, tagName, tagValue string) (*ec2.Address, error)

	AttachVolume(*ec2.Instance, *ec2.Volume) error
	AttachAddress(*ec2.Instance, *ec2.Address) error
	AttachRecord(id, tagName, tagValue string) error
}

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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