awsservice

package
v0.0.0-...-c638bfa Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT-0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StandardRetries = 3
)

Variables

View Source
var (
	Ec2Client            = ec2.NewFromConfig(awsCfg)
	EcsClient            = ecs.NewFromConfig(awsCfg)
	SsmClient            = ssm.NewFromConfig(awsCfg)
	ImdsClient           = imds.NewFromConfig(awsCfg)
	CwmClient            = cloudwatch.NewFromConfig(awsCfg)
	CwlClient            = cloudwatchlogs.NewFromConfig(awsCfg)
	DynamodbClient       = dynamodb.NewFromConfig(awsCfg)
	S3Client             = s3.NewFromConfig(awsCfg)
	CloudformationClient = cloudformation.NewFromConfig(awsCfg)
	XrayClient           = xray.NewFromConfig(awsCfg)
)
View Source
var (
	StandardExponentialBackoff = backoff.WithMaxRetries(&backoff.ExponentialBackOff{
		InitialInterval:     30 * time.Second,
		RandomizationFactor: 2,
		Multiplier:          2,
		MaxInterval:         60 * time.Second,
		MaxElapsedTime:      30 * time.Second,
		Stop:                backoff.Stop,
		Clock:               backoff.SystemClock,
	}, StandardRetries)
)

Functions

func AddItemIntoDatabaseIfNotExist

func AddItemIntoDatabaseIfNotExist(databaseName string, checkingAttribute, checkingAttributeValue []string, packet map[string]interface{}) error

func BuildDimensionFilterList

func BuildDimensionFilterList(appendDimension int) []types.DimensionFilter

func CreateStackName

func CreateStackName(stackPrefix string) string

func DeleteLogGroup

func DeleteLogGroup(logGroupName string)

DeleteLogGroup cleans up log group by name

func DeleteLogGroupAndStream

func DeleteLogGroupAndStream(logGroupName, logStreamName string)

DeleteLogGroupAndStream cleans up a log group and stream by name. This gracefully handles ResourceNotFoundException errors from calling the APIs

func DeleteLogStream

func DeleteLogStream(logGroupName, logStreamName string)

DeleteLogStream cleans up log stream by name

func DeleteStack

func DeleteStack(ctx context.Context, stackName string, client *cloudformation.Client)

func DescribeInstances

func DescribeInstances(instanceIds []string) (*ec2.DescribeInstancesOutput, error)

func DownloadFile

func DownloadFile(bucket, key, outFilename string) error

func FilterExpression

func FilterExpression(annotations map[string]interface{}) string

func FindStackInstanceId

func FindStackInstanceId(ctx context.Context, stackName string, client *cloudformation.Client, timeOutMinutes int) string

func GetBatchTraces

func GetBatchTraces(traceIDs []string) ([]types.Trace, error)

func GetClusterName

func GetClusterName(clusterArn string) string

func GetContainerInstanceArns

func GetContainerInstanceArns(clusterArn string) ([]string, error)

func GetContainerInstanceId

func GetContainerInstanceId(containerInstanceArn string) string

func GetImageId

func GetImageId() string

func GetImdsMetadata

func GetImdsMetadata() *imds.GetInstanceIdentityDocumentOutput

TODO: Refactor Structure and Interface for more easier follow that shares the same session

func GetInstanceId

func GetInstanceId() string

func GetInstancePrivateIpDns

func GetInstancePrivateIpDns(instanceId string) (*string, error)

func GetInstanceType

func GetInstanceType() string

func GetItemInDatabase

func GetItemInDatabase(databaseName, indexName string, checkingAttribute, checkingAttributeValue []string, packet map[string]interface{}) (map[string]interface{}, error)

func GetLogQueryStats

func GetLogQueryStats(logGroupName string, startTime, endTime int64, queryString string) (*types.QueryStatistics, error)

GetLogQueryStats for the log group between start/end (in epoch seconds) for the query string.

func GetLogStreamNames

func GetLogStreamNames(logGroupName string) []string

func GetLogStreams

func GetLogStreams(logGroupName string) []types.LogStream

func GetMetricData

func GetMetricData(metricDataQueries []types.MetricDataQuery, startTime, endTime time.Time) (*cloudwatch.GetMetricDataOutput, error)

GetMetricData takes the metric name, metric dimension and metric namespace and return the query metrics

func GetMetricStatistics

func GetMetricStatistics(
	metricName string,
	namespace string,
	dimensions []types.Dimension,
	startTime time.Time,
	endTime time.Time,
	periodInSeconds int32,
	statType []types.Statistic,
	extendedStatType []string,
) (*cloudwatch.GetMetricStatisticsOutput, error)

func GetSegments

func GetSegments(traceIDs []string) ([]types.Segment, error)

func GetStringParameter

func GetStringParameter(name string) string

func GetTraceIDs

func GetTraceIDs(startTime time.Time, endTime time.Time, filter string) ([]string, error)

func IsLogGroupExists

func IsLogGroupExists(logGroupName string, logGroupClassArg ...types.LogGroupClass) bool

IsLogGroupExists confirms whether the logGroupName exists or not

func PutStringParameter

func PutStringParameter(name, value string) error

func ReplaceItemInDatabase

func ReplaceItemInDatabase(databaseName string, packet map[string]interface{}) error

func ReportMetric

func ReportMetric(namespace string,
	name string,
	value float64,
	units types.StandardUnit,
) error

ReportMetric sends a single metric to CloudWatch. Does not support sending dimensions.

func RestartDaemonService

func RestartDaemonService(clusterArn, serviceName string) error

func RestartService

func RestartService(clusterArn string, desiredCount *int32, serviceName string) error

func StartStack

func StartStack(ctx context.Context, stackName string, client *cloudformation.Client, templateText string, timeOutInMinutes int32, parameters []types.Parameter)

func ValidateLogs

func ValidateLogs(logGroup, logStream string, since, until *time.Time, validators ...LogEventsValidator) error

ValidateLogs queries a given LogGroup/LogStream combination given the start and end times, and executes an arbitrary validator function on the found logs.

func ValidateMetric

func ValidateMetric(metricName, namespace string, dimensionsFilter []types.DimensionFilter) error

func ValidateMetricWithTest

func ValidateMetricWithTest(t *testing.T, metricName, namespace string, dimensionsFilter []types.DimensionFilter, retries int, retryTime time.Duration)

ValidateMetricWithTest takes the metric name, metric dimension and corresponding namespace that contains the metric

func ValidateSampleCount

func ValidateSampleCount(metricName, namespace string, dimensions []types.Dimension,
	startTime time.Time, endTime time.Time,
	lowerBoundInclusive int, upperBoundInclusive int, periodInSeconds int32) bool

Types

type ContainerInstance

type ContainerInstance struct {
	ContainerInstanceArn string
	ContainerInstanceId  string
	EC2InstanceId        string
}

func GetContainerInstances

func GetContainerInstances(clusterArn string) ([]ContainerInstance, error)

type EKSClusterType

type EKSClusterType struct {
	Type string
}

type EKSInstance

type EKSInstance struct {
	InstanceName *string
}

func GetEKSInstances

func GetEKSInstances(clusterName string) ([]EKSInstance, error)

type LogEventValidator

type LogEventValidator func(event types.OutputLogEvent) error

func AssertLogContainsSubstring

func AssertLogContainsSubstring(substr string) LogEventValidator

func AssertLogSchema

func AssertLogSchema(schemaRetriever SchemaRetriever) LogEventValidator

type LogEventsValidator

type LogEventsValidator func(events []types.OutputLogEvent) error

func AssertLogsCount

func AssertLogsCount(count int) LogEventsValidator

func AssertLogsNotEmpty

func AssertLogsNotEmpty() LogEventsValidator

func AssertNoDuplicateLogs

func AssertNoDuplicateLogs() LogEventsValidator

func AssertPerLog

func AssertPerLog(validators ...LogEventValidator) LogEventsValidator

AssertPerLog runs each validator on each of the log events. Fails fast.

type SchemaRetriever

type SchemaRetriever func(message string) (string, error)

func WithSchema

func WithSchema(schema string) SchemaRetriever

Jump to

Keyboard shortcuts

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