Documentation ¶
Index ¶
- Constants
- func Int64Pointer(i int64) *int64
- func IsStackResourceEc2Instance(stackResource cloudformation.StackResource) bool
- func StringPointer(s string) *string
- type AutoScalingUtil
- type CloudformationUtil
- func (cfnu CloudformationUtil) InCloudformation(instanceId string) (in bool, stackId string, stackName string, err error)
- func (cfnu CloudformationUtil) StartEC2Instances(stackname string) error
- func (cfnu CloudformationUtil) StartEc2InstanceForStackResource(stackResource cloudformation.StackResource) error
- func (cfnu CloudformationUtil) StopEC2Instances(stackname string) error
- func (cfnu CloudformationUtil) StopEc2InstanceForStackResource(stackResource cloudformation.StackResource) error
- type CloudwatchMetricsUtil
- type FetchRunningEc2InstanceMetricsInput
- type FetchRunningEc2InstanceMetricsOuput
Constants ¶
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 IsStackResourceEc2Instance ¶
func IsStackResourceEc2Instance(stackResource cloudformation.StackResource) bool
IsStackResourceEc2Instance checks whether the StackResource parameter an EC2 instance
func StringPointer ¶
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 ¶
func (cwmu CloudwatchMetricsUtil) FetchRunningEc2InstanceMetrics(input FetchRunningEc2InstanceMetricsInput) ([]FetchRunningEc2InstanceMetricsOuput, error)
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 FetchRunningEc2InstanceMetricsOuput ¶
type FetchRunningEc2InstanceMetricsOuput struct { Namespace string Ec2InstanceId string MetricName string Metrics *cloudwatch.GetMetricStatisticsOutput }