ec2helper

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCredentialsFromRole

func GetCredentialsFromRole(sess *session.Session) (*credentials.Credentials, error)

GetCredentialsFromRole get credentials from role when app is running in ec2

func GetCredentialsFromRoleWithoutSession

func GetCredentialsFromRoleWithoutSession(region string) (*credentials.Credentials, error)

GetCredentialsFromRoleWithoutSession get credentials from role when app is running in ec2

Types

type Client

type Client struct {
	Client  *ec2.EC2
	Session *session.Session

	Ec2InstanceIps        []string
	Ec2InstancePrivateIps []string
	// contains filtered or unexported fields
}

Client ...

func NewEC2Client

func NewEC2Client(region string, tags map[string]string) *Client

NewEC2Client ... ctor region is the region of the bucket you want to access leave it blank to use AWS_REGION environment variable

func NewEC2ClientWithSession

func NewEC2ClientWithSession(sess *session.Session, tags map[string]string) *Client

NewEC2ClientWithSession ... ctor

func (*Client) CreateInstance

func (c *Client) CreateInstance(instanceType string,
	iamProfile string,
	imageID string,
	subnetId string,
	securityGroupIDs []string,
	userData string,
	keyName string,
	minCount int64,
	maxCount int64) (*ec2.Reservation, error)

CreateInstance creates an EC2 instance

func (*Client) CreateInstanceAndWaitUntilReady

func (c *Client) CreateInstanceAndWaitUntilReady(instanceName string,
	instanceType string,
	iamProfile string,
	imageID string,
	subnetId string,
	securityGroupIDs []string,
	spotPrice string,
	userData string,
	keyName string,
	minCount int64,
	maxCount int64) error

CreateInstanceAndWaitUntilReady creates a ec2 spot instance and waits until it is ready

func (*Client) CreateSpotInstanceAndWaitUntilReady

func (c *Client) CreateSpotInstanceAndWaitUntilReady(instanceName string, instanceType string, iamProfile string, imageID string, subnetId string, securityGroupIDs []string, spotPrice string, userData string, keyName string, instanceCount int64) error

CreateSpotInstanceAndWaitUntilReady creates a ec2 spot instance and waits until it is ready

func (*Client) GetAllPrivateIPsOfStackByChildPrivateDNSName added in v1.4.0

func (c *Client) GetAllPrivateIPsOfStackByChildPrivateDNSName(childPrivateDNSName string) ([]*string, error)

GetAllPrivateIPsOfStackByChildPrivateDNSName returns all private IPs of the stack of a given child private DNS name

func (*Client) GetAllPrivateIPsOfStackByStackID added in v1.4.0

func (c *Client) GetAllPrivateIPsOfStackByStackID(stackID *string) ([]*string, error)

GetAllPrivateIPsOfStackByStackID returns all private IPs of the stack of a given stack ID

func (*Client) GetAllRunningInstanceIDs

func (c *Client) GetAllRunningInstanceIDs() ([]*string, error)

GetAllRunningInstanceIDs returns all running instance IDs of region account

func (*Client) GetAllRunningInstanceIDsFilteredByName

func (c *Client) GetAllRunningInstanceIDsFilteredByName(name string) ([]*string, error)

GetAllRunningInstanceIDsFilteredByName returns all running instances ids filtered by name name is the name of the instance as defined in the tag "Name" it is also possible to use wildcards in the name e.g. "*my-*" or "my-*"

func (*Client) GetAllRunningInstancesFilteredByTag

func (c *Client) GetAllRunningInstancesFilteredByTag(tag string, value string) ([]*ec2.Instance, error)

GetAllRunningInstanceIDsFilteredByTagNameAndValue returns all running instances filtered by tag name and value

func (*Client) GetInstancesInfos

func (c *Client) GetInstancesInfos(params *ec2.DescribeInstancesInput, mapFunc interface{}) (interface{}, error)

GetInstancesInfos returns a list of instances infos matching the given filters

func (*Client) GetStackIDByPrivateDNSName added in v1.4.0

func (c *Client) GetStackIDByPrivateDNSName(dnsName string) (*string, error)

GetStackIDByPrivateDNSName returns the stack ID of a given private DNS name of a stack child

func (*Client) RequestSpotInstance

func (c *Client) RequestSpotInstance(instanceType string, iamProfile string, imageID string, subnetId string, securityGroupIDs []string, spotPrice string, userData string, keyName string, instanceCount int64) (*ec2.RequestSpotInstancesOutput, error)

CreateSpotInstance creates a ec2 spot instance

func (*Client) RestoreRunningInstancesByName

func (c *Client) RestoreRunningInstancesByName(name string) error

GetAllRunningInstancesByName returns all running instances with the given name to the client name is the name of the instance as defined in the tag "Name" it is also possible to use wildcards in the name e.g. "*my-*" or "my-*"

func (*Client) SetTags

func (c *Client) SetTags(instanceName string, instanceIDs []*string) error

SetTags set tags on ec2 instances with name

func (*Client) TerminateAllEC2Instances

func (c *Client) TerminateAllEC2Instances() (*ec2.TerminateInstancesOutput, error)

TerminateAllEC2Instances terminate all running EC2 instances created by this client

func (*Client) TerminateAllEC2InstancesAndWait

func (c *Client) TerminateAllEC2InstancesAndWait() error

TerminateAllEC2InstancesAndWait terminate all running EC2 instances created by this client and wait until shutdown

Jump to

Keyboard shortcuts

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