awsutil

package module
v0.0.0-...-0870824 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2017 License: Apache-2.0 Imports: 14 Imported by: 0

README

CircleCI GoDoc Coverage Status Go Report Card codebeat badge CLA assistant License

A collection of utilities to automate tasks on AWS that aren't covered by the AWS CLI or SDK.

$ go get -v -t github.com/tleyden/awsutil/...

Stop all instances in Cloudformation Stack

$ awsutil cloudformation stop-instances --region us-east-1 --stackname yourstack

This will stop all EC2 instances in the yourstack Cloudformation Stack.

Restart all instances in Cloudformation Stack

$ awsutil cloudformation start-instances --region us-east-1 --stackname yourstack

This will restart all EC2 instances in the yourstack Cloudformation Stack.

Documentation

Index

Constants

View Source
const (

	// AWS_EC2_INSTANCE is an Ec2 instance resource type
	AWS_EC2_INSTANCE = "AWS::EC2::Instance"

	// AWS_EC2_HOST is an Ec2 host resource type
	AWS_EC2_HOST = "AWS::EC2::Host"

	// EC2_INSTANCE_STATE_RUNNING is an Ec2 instance in a "running" state
	EC2_INSTANCE_STATE_RUNNING = "running"
)

Variables

This section is empty.

Functions

func Int64Pointer

func Int64Pointer(i int64) *int64

Int64Pointer converts an int64 -> *int64

func IsStackResourceEc2Instance

func IsStackResourceEc2Instance(stackResource cloudformation.StackResource) bool

IsStackResourceEc2Instance checks whether the StackResource parameter an EC2 instance

func StringPointer

func StringPointer(s string) *string

StringPointer converts a string -> *string

Types

type AutoScalingUtil

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

AutoScalingUtil wraps the AWS AutoScaling SDK API and provides additional utilities

func NewAutoScalingUtil

func NewAutoScalingUtil(asgAPI autoscalingiface.AutoScalingAPI, ec2Api ec2iface.EC2API) (*AutoScalingUtil, error)

NewAutoScalingUtil creates a AutoScalingUtil given the underlying AWS api implementations (or mocks)

func NewAutoScalingUtilFromRegion

func NewAutoScalingUtilFromRegion(region string) (*AutoScalingUtil, error)

NewAutoScalingUtilFromRegion creates a AutoScalingUtil from a region

func (AutoScalingUtil) ASG_ARN_fromName

func (cfnu AutoScalingUtil) ASG_ARN_fromName(asgName string) (asgARN string, err error)

ASG_ARN_fromName returns the ARN of an autoscaling group given its name

func (AutoScalingUtil) InAutoScaling

func (cfnu AutoScalingUtil) InAutoScaling(instanceId string) (in bool, asgName string, err error)

InAutoScaling checks whether the given instance id is part of an AutoScaling group. If it is, it returns a nil error and the asgName.

type CloudformationUtil

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

CloudformationUtil wraps the AWS Cloudformation SDK API and provides additional utilities

func NewCloudformationUtil

func NewCloudformationUtil(cfnApi cloudformationiface.CloudFormationAPI, ec2Api ec2iface.EC2API) (*CloudformationUtil, error)

NewCloudformationUtil creates a CloudformationUtil given the underlying AWS api implementations (or mocks)

func NewCloudformationUtilFromRegion

func NewCloudformationUtilFromRegion(region string) (*CloudformationUtil, error)

NewCloudformationUtilFromRegion creates a CloudformationUtil from a region

func (CloudformationUtil) InCloudformation

func (cfnu CloudformationUtil) InCloudformation(instanceId string) (in bool, stackId string, stackName string, err error)

InCloudformation checks whether the given instance id is part of a Cloudformation. If it is, it returns a nil error and the stack Id and stack name. Otherwise it returns a n

func (CloudformationUtil) StartEC2Instances

func (cfnu CloudformationUtil) StartEC2Instances(stackname string) error

StartEC2Instances starts/restarts all EC2 Instances in a cloudformation stack

func (CloudformationUtil) StartEc2InstanceForStackResource

func (cfnu CloudformationUtil) StartEc2InstanceForStackResource(stackResource cloudformation.StackResource) error

StartEc2InstanceForStackResource starts the EC2 Instance in given Stack Resource

func (CloudformationUtil) StopEC2Instances

func (cfnu CloudformationUtil) StopEC2Instances(stackname string) error

StopEC2Instances stops all EC2 Instances in a cloudformation stack

func (CloudformationUtil) StopEc2InstanceForStackResource

func (cfnu CloudformationUtil) StopEc2InstanceForStackResource(stackResource cloudformation.StackResource) error

StopEc2InstanceForStackResource stops the EC2 Instance for the given Stack Resource

type CloudwatchMetricsUtil

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

func NewCloudwatchMetricsUtil

func NewCloudwatchMetricsUtil(ec2Api ec2iface.EC2API, cwApi cloudwatchiface.CloudWatchAPI) (*CloudwatchMetricsUtil, error)

func NewCloudwatchMetricsUtilFromRegion

func NewCloudwatchMetricsUtilFromRegion(region string) (*CloudwatchMetricsUtil, error)

func (CloudwatchMetricsUtil) FetchRunningEc2InstanceMetrics

FetchRunningEc2InstanceMetrics fetches certain metrics for running EC2 instances

Steps

- For each of the running ec2 instances

  • Collect metrics with time range based on Frequency param and --dimensions Name=InstanceId,Value=<cur_instance>

- Return struct result

func (CloudwatchMetricsUtil) GetEc2InstancesWithStates

func (cwmu CloudwatchMetricsUtil) GetEc2InstancesWithStates(states []string) ([]*ec2.Instance, error)

type FetchRunningEc2InstanceMetricsInput

type FetchRunningEc2InstanceMetricsInput struct {
	RecentTimeSpan time.Duration
	Namespace      string
	MetricName     string
}

type FetchRunningEc2InstanceMetricsOuput

type FetchRunningEc2InstanceMetricsOuput struct {
	Namespace     string
	Ec2InstanceId string
	MetricName    string
	Metrics       *cloudwatch.GetMetricStatisticsOutput
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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