ec2

package
v0.0.0-...-b425644 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	API_VERSIONS_EC2       = "2013-08-15"
	CANONICAL_OWNER_ID     = "099720109477"
	SELF_OWNER_ID          = "self"
	UBUNTU_ALL             = "ubuntu/images/*"
	UBUNTU_PREFIX          = "ubuntu-*"
	UBUNTU_RARING_PREFIX   = "ubuntu-raring*"
	UBUNTU_TRUSTY_PREFIX   = "ubuntu-trusty*"
	UBUNTU_SAUCY_PREFIX    = "ubuntu-saucy*"
	ImagePrefixRaringAmd64 = "ubuntu-raring-13.04-amd64*"
)
View Source
const (
	VolumeTypeGp       = "gp2"
	VolumeTypeIo1      = "io1"
	VolumeTypeStandard = "standard"
)
View Source
const DESC_LINUX_UNIX = "Linux/UNIX"
View Source
const TIME_FORMAT = "2006-01-02T15:04:05.999Z"

Variables

This section is empty.

Functions

func IpForSsh

func IpForSsh(instance *Instance) (openIp string, e error)

func WaitForInstances

func WaitForInstances(instances []*Instance, timeout time.Duration) error

Types

type Address

type Address struct {
	PublicIp                string `xml:"publicIp"`                // 203.0.113.41</publicIp>
	AllocationId            string `xml:"allocationId"`            // eipalloc-08229861</allocationId>
	Domain                  string `xml:"domain"`                  // vpc</domain>
	InstanceId              string `xml:"instanceId"`              // i-64600030</instanceId>
	AssociationId           string `xml:"associationId"`           // eipassoc-f0229899</associationId>
	NetworkInterfaceId      string `xml:"networkInterfaceId"`      // eni-ef229886</networkInterfaceId>
	NetworkInterfaceOwnerId string `xml:"networkInterfaceOwnerId"` // 053230519467</networkInterfaceOwnerId>
	PrivateIpAddress        string `xml:"privateIpAddress"`        // 10.0.0.228</privateIpAddress>
}

type Attachment

type Attachment struct {
	VolumeId            string `xml:"volumeId"`            // vol-1a2b3c4d</volumeId>
	InstanceId          string `xml:"instanceId"`          // i-1a2b3c4d</instanceId>
	Device              string `xml:"device"`              // /dev/sdh</device>
	Status              string `xml:"status"`              // attached</status>
	AttachTime          string `xml:"attachTime"`          // YYYY-MM-DDTHH:MM:SS.SSSZ</attachTime>
	DeleteOnTermination string `xml:"deleteOnTermination"` // false</deleteOnTermination>
}

type BlockDeviceMapping

type BlockDeviceMapping struct {
	DeviceName string `xml:"deviceName,omitempty" json:",omitempty"`
	Ebs        *Ebs   `xml:"ebs,omitempty" json:",omitempty"`
}

type Client

type Client struct {
	*aws.Client
}

func NewFromEnv

func NewFromEnv() *Client

func (*Client) CreateImage

func (client *Client) CreateImage(opts *CreateImageOptions) (rsp *CreateImageResponse, e error)

func (*Client) CreateTags

func (client *Client) CreateTags(resourceIds []string, tags map[string]string) error

func (*Client) DescribeAddresses

func (client *Client) DescribeAddresses() (addresses []*Address, e error)

func (*Client) DescribeImages

func (client *Client) DescribeImages() (images []*Image, e error)

func (*Client) DescribeImagesWithFilter

func (client *Client) DescribeImagesWithFilter(filter *ImageFilter) (images ImageList, e error)

func (*Client) DescribeInstances

func (client *Client) DescribeInstances() (instances []*Instance, e error)

func (*Client) DescribeInstancesWithOptions

func (client *Client) DescribeInstancesWithOptions(options *DescribeInstancesOptions) (instances []*Instance, e error)

func (*Client) DescribeKeyPairs

func (client *Client) DescribeKeyPairs() (pairs []*KeyPair, e error)

func (*Client) DescribeSecurityGroups

func (client *Client) DescribeSecurityGroups(params *DescribeSecurityGroupsParameters) (groups []*SecurityGroup, e error)

func (*Client) DescribeSpotPriceHistory

func (client *Client) DescribeSpotPriceHistory(filter *SpotPriceFilter) (prices []*SpotPrice, e error)

func (*Client) DescribeSubnets

func (client *Client) DescribeSubnets(params *DescribeSubnetsParameters) (*DescribeSubnetsResponse, error)

func (*Client) DescribeTags

func (client *Client) DescribeTags() (tags TagList, e error)

func (*Client) Endpoint

func (client *Client) Endpoint() string

func (*Client) RunInstances

func (client *Client) RunInstances(config *RunInstancesConfig) (list InstanceList, e error)

func (*Client) TerminateInstances

func (client *Client) TerminateInstances(ids []string) (*aws.Response, error)

type CreateImageOptions

type CreateImageOptions struct {
	InstanceId  string // required
	Name        string // required
	Description string
	NoReboot    bool
}

type CreateImageResponse

type CreateImageResponse struct {
	XMLName   xml.Name `xml:"CreateImageResponse"`
	RequestId string   `xml:"requestId"`
	ImageId   string   `xml:"imageId"`
}

type CreateNetworkInterface

type CreateNetworkInterface struct {
	DeviceIndex              int      `json:",omitempty"`
	AssociatePublicIpAddress bool     `json:",omitempty"`
	SubnetId                 string   `json:",omitempty"`
	SecurityGroupIds         []string `json:",omitempty"`
}

type DeregisterImage

type DeregisterImage struct {
	ImageId string
}

func (*DeregisterImage) Execute

func (d *DeregisterImage) Execute(client *Client) error

type DescribeAddressesResponse

type DescribeAddressesResponse struct {
	Addresses []*Address `xml:"addressesSet>item"`
}

type DescribeImages

type DescribeImages struct {
	ExecutableBys []string
	ImageIds      []string
	Owners        []string
	Filters       []*Filter
}

func (*DescribeImages) Execute

func (action *DescribeImages) Execute(client *Client) (*DescribeImagesResponse, error)

type DescribeImagesResponse

type DescribeImagesResponse struct {
	XMLName   xml.Name `xml:"DescribeImagesResponse"`
	RequestId string   `xml:"requestId"`
	Images    []*Image `xml:"imagesSet>item"`
}

type DescribeInstances

type DescribeInstances struct {
	InstanceIds []string
	Filters     []*Filter
}

func (*DescribeInstances) Execute

func (action *DescribeInstances) Execute(client *Client) (*DescribeInstancesResponse, error)

type DescribeInstancesOptions

type DescribeInstancesOptions struct {
	InstanceIds []string
	Filters     []*Filter
}

type DescribeInstancesResponse

type DescribeInstancesResponse struct {
	XMLName      xml.Name       `xml:"DescribeInstancesResponse"`
	RequestId    string         `xml:"requestId"`
	Reservations []*Reservation `xml:"reservationSet>item"`
}

func (*DescribeInstancesResponse) Instances

func (rsp *DescribeInstancesResponse) Instances() []*Instance

type DescribeKeyPairsResponse

type DescribeKeyPairsResponse struct {
	KeyPairs []*KeyPair `xml:"keySet>item"`
}

type DescribeSecurityGroupsParameters

type DescribeSecurityGroupsParameters struct {
	GroupNames []string
	GroupIds   []string
	Filters    []*Filter
}

type DescribeSecurityGroupsResponse

type DescribeSecurityGroupsResponse struct {
	SecurityGroups []*SecurityGroup `xml:"securityGroupInfo>item"`
}

type DescribeSpotPriceHistoryResponse

type DescribeSpotPriceHistoryResponse struct {
	SpotPrices []*SpotPrice `xml:"spotPriceHistorySet>item"`
}

type DescribeSubnetsOptions

type DescribeSubnetsOptions struct {
	SubnetIds []string
	Filters   []*Filter
}

type DescribeSubnetsParameters

type DescribeSubnetsParameters struct {
	Filters []*Filter
}

type DescribeSubnetsResponse

type DescribeSubnetsResponse struct {
	XMLName xml.Name  `xml:"DescribeSubnetsResponse"`
	Subnets []*Subnet `xml:"subnetSet>item"`
}

type DescribeTagsResponse

type DescribeTagsResponse struct {
	Tags []*Tag `xml:"tagSet>item"`
}

type DescribeVolumes

type DescribeVolumes struct {
	VolumeIds []string
	Filters   []*Filter
}

func (*DescribeVolumes) Execute

func (action *DescribeVolumes) Execute(client *Client) (*DescribeVolumesResponse, error)

type DescribeVolumesResponse

type DescribeVolumesResponse struct {
	XMLName xml.Name  `xml:"DescribeVolumesResponse"`
	Volumes []*Volume `xml:"volumeSet>item"`
}

type Ebs

type Ebs struct {
	SnapshotId          string `xml:"snapshotId,omitempty" json:",omitempty"`
	VolumeId            string `xml:"volumeId,omitempty"`
	VolumeSize          int    `xml:"volumeSize,omitempty" json:",omitempty"`
	DeleteOnTermination bool   `xml:"deleteOnTermination,omitempty" json:",omitempty"`
	VolumeType          string `xml:"volumeType,omitempty json:",omitempty""` // see VolumeType... (e.g. gp, io1, standard)
	Iops                int    `xml:"iops,omitempty" json:",omitempty"`
	Encrypted           bool   `xml:"encrypted,omitempty" json:",omitempty"`
}

type Error

type Error struct {
	Code    string `xml:"Code"`
	Message string `xml:"Message"`
}

type ErrorResponse

type ErrorResponse struct {
	XMLName   xml.Name `xml:"Response"`
	RequestID string   `xml:"RequestID"`
	Errors    []*Error `xml:"Errors>Error"`
}

func (*ErrorResponse) ErrorStrings

func (er *ErrorResponse) ErrorStrings() string

type Filter

type Filter struct {
	Name   string
	Values []string
}

type IamInstanceProfile

type IamInstanceProfile struct {
	Arn string `xml:"arn"`
	Id  string `xml:"id"`
}

type Image

type Image struct {
	ImageId             string                `xml:"imageId"`
	ImageLocation       string                `xml:"imageLocation"`
	ImageState          string                `xml:"imageState"`
	ImageOwnerId        string                `xml:"imageOwnerId"`
	IsPublic            bool                  `xml:"isPublic"`
	Architecture        string                `xml:"architecture"`
	ImageType           string                `xml:"imageType"`
	ImageOwnerAlias     string                `xml:"imageOwnerAlias"`
	Name                string                `xml:"name"`
	RootDeviceType      string                `xml:"rootDeviceType"`
	VirtualizationType  string                `xml:"virtualizationType"`
	Hypervisor          string                `xml:"hypervisor"`
	BlockDeviceMappings []*BlockDeviceMapping `xml:"blockDeviceMapping>item"`
	ProductCodes        []*ProductCode        `xml:"productCodes>item"`
	Tags                []*Tag                `xml:"tagSet>item"`
}

type ImageFilter

type ImageFilter struct {
	Owner    string
	Name     string
	ImageIds []string
}

type ImageList

type ImageList []*Image

func (ImageList) Len

func (list ImageList) Len() int

func (ImageList) Less

func (list ImageList) Less(a, b int) bool

func (ImageList) Swap

func (list ImageList) Swap(a, b int)

type Instance

type Instance struct {
	InstanceId                string    `xml:"instanceId"`
	ImageId                   string    `xml:"imageId"`
	InstanceStateCode         int       `xml:"instanceState>code"`
	InstanceStateName         string    `xml:"instanceState>name"`
	PrivateDnsName            string    `xml:"privateDnsName"`
	DnsName                   string    `xml:"dnsName"`
	Reason                    string    `xml:"reason"`
	KeyName                   string    `xml:"keyName"`
	AmiLaunchIndex            int       `xml:"amiLaunchIndex"`
	InstanceType              string    `xml:"instanceType"`
	LaunchTime                time.Time `xml:"launchTime"`
	PlacementAvailabilityZone string    `xml:"placement>availabilityZone"`
	PlacementTenancy          string    `xml:"placement>tenancy"`
	KernelId                  string    `xml:"kernelId"`
	MonitoringState           string    `xml:"monitoring>state"`
	SubnetId                  string    `xml:"subnetId"`
	VpcId                     string    `xml:"vpcId"`
	PrivateIpAddress          string    `xml:"privateIpAddress"`
	IpAddress                 string    `xml:"ipAddress"`
	SourceDestCheck           string    `xml:"sourceDestCheck"`
	Architecture              string    `xml:"architecture"`
	RootDeviceType            string    `xml:"rootDeviceType"`
	RootDeviceName            string    `xml:"rootDeviceName"`
	VirtualizationType        string    `xml:"virtualizationType"`
	ClientToken               string    `xml:"clientToken"`
	Hypervisor                string    `xml:"hypervisor"`
	EbsOptimized              string    `xml:"ebsOptimized"`

	BlockDeviceMappings []*BlockDeviceMapping `xml:"blockDeviceMapping>item"`
	SecurityGroups      []*SecurityGroup      `xml:"groupSet>item"`
	Tags                []*Tag                `xml:"tagSet>item"`
	NetworkInterfaces   []*NetworkInterface   `xml:"networkInterfaceSet>item"`
	IamInstanceProfile  *IamInstanceProfile   `xml:"iamInstanceProfile"`
}

func (*Instance) Name

func (instance *Instance) Name() string

type InstanceList

type InstanceList []*Instance

type IpAddress

type IpAddress struct {
	PrivateIpAddress string `xml:"privateIpAddress"`
	PrivateDnsName   string `xml:"privateDnsName"`
	Primary          bool   `xml:"primary"`
	PublicIp         string `xml:"publicIp"`
	PublicDnsName    string `xml:"publicDnsName"`
	IpOwnerId        string `xml:"ipOwnerId"`
}

type IpPermission

type IpPermission struct {
	IpProtocol string           `xml:"ipProtocol,omitempty"`  // tcp</ipProtocol>
	FromPort   int              `xml:"fromPort,omitempty"`    // 80</fromPort>
	ToPort     int              `xml:"toPort,omitempty"`      // 80</toPort>
	Groups     []*SecurityGroup `xml:"groups>item,omitempty"` //
	IpRanges   []string         `xml:"ipRanges>item>cidrIp"`
}

type KeyPair

type KeyPair struct {
	KeyName        string `xml:"keyName"`
	KeyFingerprint string `xml:"keyFingerprint"`
}

type NetworkInterface

type NetworkInterface struct {
	NetworkInterfaceId            string           `xml:"networkInterfaceId"`
	SubnetId                      string           `xml:"subnetId"`
	VpcId                         string           `xml:"vpcId"`
	Description                   string           `xml:"description"`
	OwnerId                       string           `xml:"ownerId"`
	Status                        string           `xml:"status"`
	MacAddress                    string           `xml:"macAddress"`
	PrivateIpAddress              string           `xml:"privateIpAddress"`
	PrivateDnsName                string           `xml:"privateDnsName"`
	SourceDestCheck               bool             `xml:"sourceDestCheck"`
	SecurityGroups                []*SecurityGroup `xml:"groupSet>item"`
	AttachmentAttachmentId        string           `xml:"attachment>attachmentId"`
	AttachmentDeviceIndex         int              `xml:"attachment>deviceIndex"`
	AttachmentStatus              string           `xml:"attachment>status"`
	AttachmentAttachTime          time.Time        `xml:"attachment>attachTime"`
	AttachmentDeleteOnTermination bool             `xml:"attachment>deleteOnTermination"`
	AssociationPublicIp           string           `xml:"association>publicIp"`
	AssociationPublicDnsName      string           `xml:"association>publicDnsName"`
	AssociationIpOwnerId          string           `xml:"association>ipOwnerId"`

	PrivateIpAddresses []*IpAddress `xml:"privateIpAddressesSet>item"`
}

type ProductCode

type ProductCode struct {
	ProductCode string `xml:"productCode"`
	Type        string `xml:"type"`
}

type Reservation

type Reservation struct {
	ReservationId string      `xml:"reservationId"`
	OwnerId       string      `xml:"ownerId"`
	Instances     []*Instance `xml:"instancesSet>item"`
}

type RunInstances

type RunInstances struct {
	InstanceType                      string
	ImageId                           string
	MinCount                          int
	MaxCount                          int
	KeyName                           string
	SecurityGroupIds                  []string
	SubnetId                          string
	UserData                          string
	AvailabilityZone                  string
	InstanceInitiatedShutdownBehavior string
	IamInstanceProfileName            string
	BlockDeviceMapings                []*BlockDeviceMapping

	NetworkInterfaces []*CreateNetworkInterface
}

func (*RunInstances) AddPublicIp

func (config *RunInstances) AddPublicIp()

func (*RunInstances) Execute

func (action *RunInstances) Execute(client *Client) (*RunInstancesResponse, error)

type RunInstancesConfig

type RunInstancesConfig struct {
	ImageId                string                    `json:",omitempty"`
	MinCount               int                       `json:",omitempty"`
	MaxCount               int                       `json:",omitempty"`
	InstanceType           string                    `json:",omitempty"`
	AvailabilityZone       string                    `json:",omitempty"`
	KeyName                string                    `json:",omitempty"`
	SecurityGroups         []string                  `json:",omitempty"`
	SubnetId               string                    `json:",omitempty"`
	NetworkInterfaces      []*CreateNetworkInterface `json:",omitempty"`
	BlockDeviceMappings    []*BlockDeviceMapping     `json:",omitempty"`
	UserData               string                    `json:",omitempty"`
	IamInstanceProfileName string                    `json:",omitempty"`
	EbsOptimized           bool                      `json:",omitempty"`
}

func (*RunInstancesConfig) AddPublicIp

func (config *RunInstancesConfig) AddPublicIp() error

func (*RunInstancesConfig) Values

func (config *RunInstancesConfig) Values() (url.Values, error)

type RunInstancesResponse

type RunInstancesResponse struct {
	XMLName       xml.Name    `xml:"RunInstancesResponse"`
	RequestId     string      `xml:"requestId"`
	ReservationId string      `xml:"reservationId"`
	OwnerId       string      `xml:"ownerId"`
	Instances     []*Instance `xml:"instancesSet>item"`
}

type SecurityGroup

type SecurityGroup struct {
	OwnerId          string          `xml:"ownerId,omitempty"`          // 111122223333</ownerId>
	GroupId          string          `xml:"groupId,omitempty"`          // sg-1a2b3c4d</groupId>
	GroupName        string          `xml:"groupName,omitempty"`        // WebServers</groupName>
	GroupDescription string          `xml:"groupDescription,omitempty"` // Web Servers</groupDescription>
	VpcId            string          `xml:"vpcId,omitempty"`            //
	IpPermissions    []*IpPermission `xml:"ipPermissions>item"`
}

type SpotPrice

type SpotPrice struct {
	InstanceType       string    `xml:"instanceType"`       // m1.small</instanceType>
	ProductDescription string    `xml:"productDescription"` // Linux/UNIX</productDescription>
	SpotPrice          float64   `xml:"spotPrice"`          // 0.287</spotPrice>
	Timestamp          time.Time `xml:"timestamp"`          // 2009-12-04T20:56:05.000Z</timestamp>
	AvailabilityZone   string    `xml:"availabilityZone"`   // us-east-1a</availabilityZone>
}

type SpotPriceFilter

type SpotPriceFilter struct {
	InstanceTypes       []string
	AvailabilityZones   []string
	ProductDescriptions []string
	StartTime           time.Time
	EndTime             time.Time
}

type Subnet

type Subnet struct {
	SubnetId                string `xml:"subnetId"`
	State                   string `xml:"state"`
	VpcId                   string `xml:"vpcId"`
	CidrBlock               string `xml:"cidrBlock"`
	AvailableIpAddressCount int    `xml:"availableIpAddressCount"`
	AvailabilityZone        string `xml:"availabilityZone"`
	DefaultForAz            bool   `xml:"defaultForAz"`
	MapPublicIpOnLaunch     bool   `xml:"mapPublicIpOnLaunch"`
}

type Tag

type Tag struct {
	Key          string `xml:"key,omitempty"`
	Value        string `xml:"value,omitempty"`
	ResourceId   string `xml:"resourceId,omitempty"`
	ResourceType string `xml:"resourceType,omitempty"`
}

func (*Tag) String

func (tag *Tag) String() string

type TagList

type TagList []*Tag

func (TagList) Len

func (list TagList) Len() int

func (TagList) Less

func (list TagList) Less(a, b int) bool

func (TagList) Swap

func (list TagList) Swap(a, b int)

type Volume

type Volume struct {
	VolumeId         string    `xml:"volumeId"`         // vol-1a2b3c4d</volumeId>
	Size             string    `xml:"size"`             // 80</size>
	SnapshotId       string    `xml:"snapshotId/"`      //
	AvailabilityZone string    `xml:"availabilityZone"` // us-east-1a</availabilityZone>
	Status           string    `xml:"status"`           // in-use</status>
	CreateTime       time.Time `xml:"createTime"`       // YYYY-MM-DDTHH:MM:SS.SSSZ</createTime>

	Attachments []*Attachment `xml:"attachmentSet>item"`
}

Jump to

Keyboard shortcuts

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