aws

package
v0.0.0-...-3f1c2bf Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2022 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckMetricTimeValidation

func CheckMetricTimeValidation(startTime time.Time, endTime time.Time) bool

CheckMetricTimeValidation validates metric time

func GetAwsSession

func GetAwsSession() *session.Session

GetAwsSession generates new aws session

Types

type Client

type Client struct {
	Region            string
	EC2Service        EC2Client
	ELBV2Service      ELBV2Client
	ELBService        ELBClient
	CloudWatchService CloudWatchClient
	SSMService        SSMClient
}

func BootstrapServices

func BootstrapServices(region string, assumeRole string) Client

BootstrapServices creates AWS client list

type CloudWatchClient

type CloudWatchClient struct {
	Client *cloudwatch.CloudWatch
}

func NewCloudWatchClient

func NewCloudWatchClient(session client.ConfigProvider, region string, creds *credentials.Credentials) CloudWatchClient

NewCloudWatchClient creates Cloudwatch client

func (CloudWatchClient) CreateCloudWatchAlarm

func (c CloudWatchClient) CreateCloudWatchAlarm(asgName string, alarm schemas.AlarmConfigs) error

CreateCloudWatchAlarm creates cloudwatch alarms for autoscaling group

func (CloudWatchClient) CreateScalingAlarms

func (c CloudWatchClient) CreateScalingAlarms(asgName string, alarms []schemas.AlarmConfigs, policyArns map[string]string) error

CreateScalingAlarms creates scaling alarms

func (CloudWatchClient) GetLoadBalancerRequestStatistics

func (c CloudWatchClient) GetLoadBalancerRequestStatistics(loadbalancers []*string, startTime, terminatedDate time.Time, logger *Logger.Logger) (map[string]map[string]float64, error)

GetLoadBalancerRequestStatistics returns statistics for terminating autoscaling group

func (CloudWatchClient) GetOneDayStatisticsOfLoadBalancer

func (c CloudWatchClient) GetOneDayStatisticsOfLoadBalancer(lb string, startTime, endTime time.Time, period int64, id string) (map[string]float64, float64, error)

GetOneDayStatisticsOfLoadBalancer returns all stats of one day

func (CloudWatchClient) GetOneDayStatisticsOfTargetGroup

func (c CloudWatchClient) GetOneDayStatisticsOfTargetGroup(tg string, startTime, endTime time.Time, period int64, id string) (map[string]float64, float64, error)

GetOneDayStatisticsOfTargetGroup returns all stats of one day

func (CloudWatchClient) GetTargetGroupRequestStatistics

func (c CloudWatchClient) GetTargetGroupRequestStatistics(tgs []*string, startTime, terminatedDate time.Time, logger *Logger.Logger) (map[string]map[string]float64, error)

GetTargetGroupRequestStatistics returns statistics for terminating autoscaling group

type DynamoDBClient

type DynamoDBClient struct {
	Client *dynamodb.DynamoDB
}

func NewDynamoDBClient

func NewDynamoDBClient(session client.ConfigProvider, region string, creds *credentials.Credentials) DynamoDBClient

func (DynamoDBClient) CheckTableExists

func (d DynamoDBClient) CheckTableExists(tableName string) (bool, error)

func (DynamoDBClient) CreateTable

func (d DynamoDBClient) CreateTable(tableName string) error

func (DynamoDBClient) GetSingleItem

func (d DynamoDBClient) GetSingleItem(asg, tableName string) (map[string]*dynamodb.AttributeValue, error)

GetSingleItem retrieves single item for single autoscaling group

func (DynamoDBClient) MakeRecord

func (d DynamoDBClient) MakeRecord(stack, config, tags string, asg string, tableName string, status, timezone string, additionalFields map[string]string) error

func (DynamoDBClient) UpdateRecord

func (d DynamoDBClient) UpdateRecord(updateKey, asg string, tableName string, status, timezone string, updateFields map[string]interface{}) error

func (DynamoDBClient) UpdateStatistics

func (d DynamoDBClient) UpdateStatistics(asg string, tableName, timezone string, updateFields map[string]interface{}) error

UpdateStatistics updates the status value on metric table

type EC2Client

type EC2Client struct {
	Client   *ec2.EC2
	AsClient *autoscaling.AutoScaling
}

func NewEC2Client

func NewEC2Client(session client.ConfigProvider, region string, creds *credentials.Credentials) EC2Client

func (EC2Client) AttachAsgToTargetGroups

func (e EC2Client) AttachAsgToTargetGroups(asg string, targetGroups []*string) error

AttachAsgToTargetGroups attaches autoscaling group to target groups of ELB

func (EC2Client) CreateAutoScalingGroup

func (e EC2Client) CreateAutoScalingGroup(name, launchTemplateName, healthcheckType string,
	healthcheckGracePeriod int64,
	capacity schemas.Capacity,
	loadbalancers, availabilityZones []string,
	targetGroupArns, terminationPolicies []*string,
	tags []*(autoscaling.Tag),
	subnets []string,
	mixedInstancePolicy schemas.MixedInstancesPolicy,
	hooks []*autoscaling.LifecycleHookSpecification) error

CreateAutoScalingGroup creates new autoscaling group

func (EC2Client) CreateNewLaunchConfiguration

func (e EC2Client) CreateNewLaunchConfiguration(name, ami, instanceType, keyName, iamProfileName, userdata string, ebsOptimized bool, securityGroups []*string, blockDevices []*autoscaling.BlockDeviceMapping) bool

Create New Launch Configuration

func (EC2Client) CreateNewLaunchTemplate

func (e EC2Client) CreateNewLaunchTemplate(name, ami, instanceType, keyName, iamProfileName, userdata string, ebsOptimized, mixedInstancePolicyEnabled bool, securityGroups []*string, blockDevices []*ec2.LaunchTemplateBlockDeviceMappingRequest, instanceMarketOptions *schemas.InstanceMarketOptions, detailedMonitoringEnabled bool) error

Create New Launch Template

func (EC2Client) CreateNewLaunchTemplateVersion

func (e EC2Client) CreateNewLaunchTemplateVersion(lt *ec2.LaunchTemplateVersion, sgs []*string) (*ec2.LaunchTemplateVersion, error)

CreateNewLaunchTemplateVersion creates new version of launch template

func (EC2Client) CreateScalingPolicy

func (e EC2Client) CreateScalingPolicy(policy schemas.ScalePolicy, asgName string) (*string, error)

CreateScalingPolicy creates scaling policy

func (EC2Client) CreateScheduledActions

func (e EC2Client) CreateScheduledActions(asg string, actions []schemas.ScheduledAction) error

CreateScheduledActions creates scheduled actions

func (EC2Client) CreateSecurityGroup

func (e EC2Client) CreateSecurityGroup(sgName string, vpcID *string) (*string, error)

CreateSecurityGroup creates new security group

func (EC2Client) DeleteAutoscalingSet

func (e EC2Client) DeleteAutoscalingSet(asgName string) error

Delete Autoscaling group Set

func (EC2Client) DeleteCanaryTag

func (e EC2Client) DeleteCanaryTag(asg string) error

DeleteCanaryTag deletes canary tag from auto scaling group

func (EC2Client) DeleteLaunchConfigurations

func (e EC2Client) DeleteLaunchConfigurations(asgName string) error

DeleteLaunchConfigurations deletes All Launch Configurations belongs to the autoscaling group

func (EC2Client) DeleteLaunchTemplates

func (e EC2Client) DeleteLaunchTemplates(asgName string) error

DeleteLaunchTemplates deletes all launch template belongs to the autoscaling group

func (EC2Client) DeleteSecurityGroup

func (e EC2Client) DeleteSecurityGroup(sg string) error

DeleteSecurityGroup deletes security group

func (EC2Client) DescribeAMIArchitecture

func (e EC2Client) DescribeAMIArchitecture(amiID string) (string, error)

$ aws ec2 describe-images --filters Name=image-id,Values=ami-01288945bd24ed49a --query "Images[*].Architecture"

func (EC2Client) DescribeInstanceRefreshes

func (e EC2Client) DescribeInstanceRefreshes(name, id *string) (*autoscaling.InstanceRefresh, error)

DescribeInstanceRefreshes describes instance refresh information

func (EC2Client) DescribeInstanceTypes

func (e EC2Client) DescribeInstanceTypes() ([]string, error)

aws ec2 describe-instance-types --filters Name=processor-info.supported-architecture,Values=arm64 --query "InstanceTypes[*].InstanceType"

func (EC2Client) DescribeInstances

func (e EC2Client) DescribeInstances(instanceIds []*string) ([]*ec2.Instance, error)

DescribeInstances return detailed information of instances

func (EC2Client) DetachAsgFromTargetGroups

func (e EC2Client) DetachAsgFromTargetGroups(asg string, targetGroups []*string) error

DetachAsgFromTargetGroups detaches autoscaling group from target groups of ELB

func (EC2Client) DetachLoadBalancerTargetGroup

func (e EC2Client) DetachLoadBalancerTargetGroup(asg string, tgARNs []*string) error

DetachLoadBalancerTargetGroup detaches target group from autoscaling group

func (EC2Client) EnableMetrics

func (e EC2Client) EnableMetrics(asgName string) error

EnableMetrics enables metric monitoring of autoscaling group

func (EC2Client) GenerateLifecycleHooks

func (e EC2Client) GenerateLifecycleHooks(hooks schemas.LifecycleHooks) []*autoscaling.LifecycleHookSpecification

GenerateLifecycleHooks generate lifecycle hooks

func (EC2Client) GetAllMatchingAutoscalingGroupsWithPrefix

func (e EC2Client) GetAllMatchingAutoscalingGroupsWithPrefix(prefix string) ([]*autoscaling.Group, error)

Get All matching autoscaling groups with aws prefix By this function, you could get the latest version of deployment

func (EC2Client) GetAvailabilityZones

func (e EC2Client) GetAvailabilityZones(vpc string, azs []string) ([]string, error)

GetAvailabilityZones get all available availability zones

func (EC2Client) GetMatchingAutoscalingGroup

func (e EC2Client) GetMatchingAutoscalingGroup(name string) (*autoscaling.Group, error)

GetMatchingAutoscalingGroup returns only one matching autoscaling group information

func (EC2Client) GetMatchingLaunchTemplate

func (e EC2Client) GetMatchingLaunchTemplate(ltID string) (*ec2.LaunchTemplateVersion, error)

GetMatchingLaunchTemplate returns information of launch template with matched ID

func (EC2Client) GetSecurityGroup

func (e EC2Client) GetSecurityGroup(sgName string) (*string, error)

GetSecurityGroup retrieves group id of existing security group

func (EC2Client) GetSecurityGroupDetails

func (e EC2Client) GetSecurityGroupDetails(sgIds []*string) ([]*ec2.SecurityGroup, error)

GetSecurityGroupDetails returns detailed information for security group

func (EC2Client) GetSecurityGroupList

func (e EC2Client) GetSecurityGroupList(vpc string, sgList []string) ([]*string, error)

Get All Security Group Information New Launch Configuration

func (EC2Client) GetSubnets

func (e EC2Client) GetSubnets(vpc string, usePublicSubnets bool, azs []string) ([]string, error)

GetSubnets retrieves all subnets available

func (EC2Client) GetTargetGroups

func (e EC2Client) GetTargetGroups(asgName string) ([]*string, error)

GetTargetGroups returns list of target group ARN of autoscaling group

func (EC2Client) GetVPCId

func (e EC2Client) GetVPCId(vpc string) (string, error)

func (EC2Client) MakeBlockDevices

func (e EC2Client) MakeBlockDevices(blocks []schemas.BlockDevice) []*autoscaling.BlockDeviceMapping

MakeBlockDevices returns list of block device mapping for launch configuration

func (EC2Client) MakeLaunchTemplateBlockDeviceMappings

func (e EC2Client) MakeLaunchTemplateBlockDeviceMappings(blocks []schemas.BlockDevice) []*ec2.LaunchTemplateBlockDeviceMappingRequest

MakeLaunchTemplateBlockDeviceMappings returns list of block device mappings for launch template

func (EC2Client) ModifyNetworkInterfaces

func (e EC2Client) ModifyNetworkInterfaces(eni *string, groups []*string) error

ModifyNetworkInterfaces modifies network interface attributes

func (EC2Client) RevokeInboundRulesWithGroup

func (e EC2Client) RevokeInboundRulesWithGroup(sgID, protocol string, fromSg *string, fromPort, toPort int64) error

RevokeInboundRulesWithGroup revokes inbound rules for security group with other security group

func (EC2Client) StartInstanceRefresh

func (e EC2Client) StartInstanceRefresh(name *string, instanceWarmup, minHealthyPercentage int64) (*string, error)

StartInstanceRefresh starts instance refresh

func (EC2Client) UpdateAutoScalingGroup

func (e EC2Client) UpdateAutoScalingGroup(asg string, capacity schemas.Capacity) error

UpdateAutoScalingGroup updates auto scaling group information

func (EC2Client) UpdateAutoScalingGroupSize

func (e EC2Client) UpdateAutoScalingGroupSize(asg string, min, max, desired, retry int64) (int64, error)

Update Autoscaling Group size

func (EC2Client) UpdateAutoScalingLaunchTemplate

func (e EC2Client) UpdateAutoScalingLaunchTemplate(asg string, lt *ec2.LaunchTemplateVersion) error

UpdateAutoScalingLaunchTemplate updates autoscaling launch template

func (EC2Client) UpdateInboundRules

func (e EC2Client) UpdateInboundRules(sgID, protocol, cidr, description string, fromPort, toPort int64) error

UpdateInboundRules updates inbound rules for security group with IP

func (EC2Client) UpdateInboundRulesWithGroup

func (e EC2Client) UpdateInboundRulesWithGroup(sgID, protocol, description string, fromSg *string, fromPort, toPort int64) error

UpdateInboundRulesWithGroup updates inbound rules for security group with other security group

func (EC2Client) UpdateOutboundRules

func (e EC2Client) UpdateOutboundRules(sgID, protocol, cidr, description string, fromPort, toPort int64) error

UpdateOutboundRules updates inbound rules for security group with IP

type ELBClient

type ELBClient struct {
	Client *elb.ELB
}

func NewELBClient

func NewELBClient(session client.ConfigProvider, region string, creds *credentials.Credentials) ELBClient

func (ELBClient) GetHealthyHostInELB

func (e ELBClient) GetHealthyHostInELB(group *autoscaling.Group, elbName string) ([]HealthcheckHost, error)

GetHostInELB returns instances in ELB

type ELBV2Client

type ELBV2Client struct {
	Client *elbv2.ELBV2
}

func NewELBV2Client

func NewELBV2Client(session client.ConfigProvider, region string, creds *credentials.Credentials) ELBV2Client

func (ELBV2Client) CreateLoadBalancer

func (e ELBV2Client) CreateLoadBalancer(app string, subnets []string, groupID *string) (*elbv2.LoadBalancer, error)

CreateLoadBalancer retrieves all load balancers

func (ELBV2Client) CreateNewListener

func (e ELBV2Client) CreateNewListener(loadBalancerArn string, targetGroupArn string) error

CreateNewListener creates a new listener and attach target group to load balancer

func (ELBV2Client) CreateTargetGroup

func (e ELBV2Client) CreateTargetGroup(tg *elbv2.TargetGroup, tgName string) (*elbv2.TargetGroup, error)

CreateTargetGroup creates a new target group

func (ELBV2Client) DeleteLoadBalancer

func (e ELBV2Client) DeleteLoadBalancer(lb string) error

DeleteLoadBalancer deletes a load balancer

func (ELBV2Client) DeleteTargetGroup

func (e ELBV2Client) DeleteTargetGroup(targetGroup *string) error

DeleteTargetGroup deletes a target group

func (ELBV2Client) DescribeListeners

func (e ELBV2Client) DescribeListeners(loadBalancerArn string) ([]*elbv2.Listener, error)

DescribeListeners describes all listeners in the load balancer

func (ELBV2Client) DescribeLoadBalancers

func (e ELBV2Client) DescribeLoadBalancers() ([]*elbv2.LoadBalancer, error)

DescribeLoadBalancers retrieves all load balancers

func (ELBV2Client) DescribeTargetGroups

func (e ELBV2Client) DescribeTargetGroups(targetGroups []*string) ([]*elbv2.TargetGroup, error)

DescribeTargetGroups returns arn list of target groups with detailed information

func (ELBV2Client) GetHostInTarget

func (e ELBV2Client) GetHostInTarget(group *autoscaling.Group, targetGroupArn *string, isUpdate, downSizingUpdate bool) ([]HealthcheckHost, error)

GetHostInTarget gets host instance

func (ELBV2Client) GetLoadBalancerFromTG

func (e ELBV2Client) GetLoadBalancerFromTG(targetGroups []*string) ([]*string, error)

GetLoadBalancerFromTG returns list of loadbalancer from target groups

func (ELBV2Client) GetMatchingLoadBalancer

func (e ELBV2Client) GetMatchingLoadBalancer(lb string) (*elbv2.LoadBalancer, error)

DescribeLoadBalancers retrieves matching load balancer

func (ELBV2Client) GetTargetGroupARNs

func (e ELBV2Client) GetTargetGroupARNs(targetGroups []string) ([]*string, error)

GetTargetGroupARNs returns arn list of target groups

func (ELBV2Client) ModifyListener

func (e ELBV2Client) ModifyListener(listenerArn *string, targetGroupArn string) error

ModifyListener modifies the existing listener and change target to newly created target group

type HealthcheckHost

type HealthcheckHost struct {
	InstanceID     string
	LifecycleState string
	TargetStatus   string
	HealthStatus   string
	Valid          bool
}

type ManifestClient

type ManifestClient struct {
	Region    string
	S3Service S3Client
}

func BootstrapManifestService

func BootstrapManifestService(region string, assumeRole string) ManifestClient

type MetricClient

type MetricClient struct {
	Region            string
	DynamoDBService   DynamoDBClient
	CloudWatchService CloudWatchClient
}

func BootstrapMetricService

func BootstrapMetricService(region string, assumeRole string) MetricClient

type S3Client

type S3Client struct {
	Client *s3.S3
}

func NewS3Client

func NewS3Client(session client.ConfigProvider, region string, creds *credentials.Credentials) S3Client

func (S3Client) GetManifest

func (s S3Client) GetManifest(bucket, key string) ([]byte, error)

type SSMClient

type SSMClient struct {
	Client *ssm.SSM
}

func NewSSMClient

func NewSSMClient(session client.ConfigProvider, region string, creds *credentials.Credentials) SSMClient

func (SSMClient) SendCommand

func (s SSMClient) SendCommand(target []*string, commands []*string) bool

SSM Send command

Jump to

Keyboard shortcuts

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