Documentation ¶
Overview ¶
Package aws provides functionality to interact with AWS services such as EC2 and CloudWatch. It includes functions to initialize a CloudWatch client and fetch CPU utilization metrics for EC2 instances.
Package aws contains functionalities related to AWS services.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FetchCpuUtilizationMetric ¶
func FetchCpuUtilizationMetric(instanceId string, cwClient cloudwatchiface.CloudWatchAPI) (*cloudwatch.GetMetricDataOutput, error)
FetchCpuUtilizationMetric fetches the CPU utilization metric for the specified EC2 instance. It uses the provided CloudWatch client to fetch the metric data from the last 24 hours, with a period of 1 hour. The function returns the metric data output and any error encountered.
func NewCloudWatchClient ¶
func NewCloudWatchClient(sess *session.Session) cloudwatchiface.CloudWatchAPI
NewCloudWatchClient initializes a new CloudWatch client using the provided AWS session. It returns an interface to the CloudWatch API, which can be used to interact with the service.
Types ¶
type EC2Handler ¶
type EC2Handler struct{}
EC2Handler is a type that implements the EC2Service interface, providing methods to interact with EC2 instances.
func (*EC2Handler) CheckEC2Instances ¶
func (e *EC2Handler) CheckEC2Instances(ec2Svc ec2iface.EC2API)
CheckEC2Instances connects to AWS, performs a health check of EC2 instances, and lists the IDs of all active EC2 instances. It takes an EC2 service client as a parameter and queries EC2 instances, outputting their IDs.
func (*EC2Handler) NewAWSSession ¶
func (e *EC2Handler) NewAWSSession() (ec2iface.EC2API, error)
NewAWSSession creates a new AWS session and returns an EC2 service. It returns an EC2 service as an ec2iface.EC2API interface, which can be used to interact with EC2. If there is a problem creating the AWS session, it returns an error.