ec2

package
v0.2.0-alpha Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2022 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package ec2 contains methods for interacting and obtaining AWS instances

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyInstanceIsNotRunning

func AnyInstanceIsNotRunning(instances []types.Instance) bool

func AnyInstanceIsNotStoppedOrStopping

func AnyInstanceIsNotStoppedOrStopping(instances []types.Instance) bool

func GetClient

func GetClient(c aws.Config) *ec2.Client

GetClient returns a new ec2 client from the given config

func GetInstancesFromReservasions

func GetInstancesFromReservasions(reservations []types.Reservation) (instances []types.Instance)

func GetInstancesPublicDnsName

func GetInstancesPublicDnsName(instances []types.Instance) (publicDnsNames []string)

func GetInstancesWithFilters

func GetInstancesWithFilters(c context.Context, client EC2DescribeInstancesAPI, f []types.Filter) (*ec2.DescribeInstancesOutput, error)

GetInstancesWithFilters returns instances matching filters.

func StartAllInstancesWait

func StartAllInstancesWait(c context.Context, client EC2StartInstancesAPI, instances []types.Instance, waitForSeconds int) error

func StopAllInstances

func StopAllInstances(c context.Context, client EC2StopInstancesAPI, instances []types.Instance) error

StopAllInstancesWait will attempt to stop all instances,

Types

type EC2DescribeInstancesAPI

type EC2DescribeInstancesAPI interface {
	DescribeInstances(ctx context.Context,
		params *ec2.DescribeInstancesInput,
		optFns ...func(*ec2.Options)) (*ec2.DescribeInstancesOutput, error)
}

EC2DescribeInstancesAPI defines the interface for the DescribeInstances function. We use this interface to test the function using a mocked service.

type EC2StartInstancesAPI

type EC2StartInstancesAPI interface {
	StartInstances(ctx context.Context,
		params *ec2.StartInstancesInput,
		optFns ...func(*ec2.Options)) (*ec2.StartInstancesOutput, error)
}

type EC2StopInstancesAPI

type EC2StopInstancesAPI interface {
	StopInstances(ctx context.Context,
		params *ec2.StopInstancesInput,
		optFns ...func(*ec2.Options)) (*ec2.StopInstancesOutput, error)
}

Jump to

Keyboard shortcuts

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