ec2_manager

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

This is a group of functions to interact with EC2 instances in AWS. The instances modified by these functions are added to the field Instances of Ec2Client.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoInstancesFound is returned when no instances are found with the given tag.
	ErrNoInstancesFound = fmt.Errorf("no instances found with the given tag")
)

Functions

This section is empty.

Types

type Ec2Client

type Ec2Client struct {
	*ec2.Client
	Instances []string
}

func NewEc2Client

func NewEc2Client(ctx context.Context) (*Ec2Client, error)

func (*Ec2Client) DescribeInstancesTagState

func (e *Ec2Client) DescribeInstancesTagState(ctx context.Context, state string, t Tags) ([]string, error)

DescribeInstancesTagState returns a list of all instances with the given tag and state.

func (*Ec2Client) StartInstancesWithTag

func (e *Ec2Client) StartInstancesWithTag(ctx context.Context, t Tags) error

StopInstancesWithTag stops all instances with the given tag. It only works if the instances are in the "running" state. The instances that were stopped are added to the field Instances of Ec2Client.

func (*Ec2Client) StopInstancesWithTag

func (e *Ec2Client) StopInstancesWithTag(ctx context.Context, t Tags) error

StopInstancesWithTag stops all instances with the given tag. It only works if the instances are in the "running" state. The instances that were stopped are added to the field Instances of Ec2Client.

type Tags

type Tags struct {
	Key   string
	Value []string
}

Jump to

Keyboard shortcuts

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