aws

package
v0.0.0-...-e01fbee Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Overview

The interfaces are here to make the callers of these API's testable, giving us the ability to mock them. At the time of writing github.com/aws/aws-sdk-go-v2 does not provide interfaces that can be mocked. Add new function signatures as necessary.

Index

Constants

View Source
const (
	AwsMaxRCU       = 40000
	AwsMaxWCU       = 40000
	SafeScaleFactor = 2.0
)

defaults for the dynamodb settings config as set by AWS https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ServiceQuotas.html#default-limits-throughput-capacity-modes

View Source
const (
	Name = "clutch.service.aws"
)
View Source
const TableBillingUnspecified = "UNSPECIFIED"

constant to cover edge case where billing mode is not in table description and we cannot infer the billing mode from the provisioned throughput numbers

Variables

This section is empty.

Functions

func ConvertError

func ConvertError(e error) error

Use error handling techniques outlined in https://aws.github.io/aws-sdk-go-v2/docs/handling-errors/ to extract embedded HTTP status information and error messages from AWS SDK errors and create the corresponding gRPC status.

func New

func New(cfg *anypb.Any, logger *zap.Logger, scope tally.Scope) (service.Service, error)

Types

type Client

type Client interface {
	DescribeInstances(ctx context.Context, account, region string, ids []string) ([]*ec2v1.Instance, error)
	TerminateInstances(ctx context.Context, account, region string, ids []string) error
	RebootInstances(ctx context.Context, account, region string, ids []string) error

	DescribeAutoscalingGroups(ctx context.Context, account, region string, names []string) ([]*ec2v1.AutoscalingGroup, error)
	ResizeAutoscalingGroup(ctx context.Context, account, region string, name string, size *ec2v1.AutoscalingGroupSize) error

	DescribeKinesisStream(ctx context.Context, account, region, streamName string) (*kinesisv1.Stream, error)
	UpdateKinesisShardCount(ctx context.Context, account, region, streamName string, targetShardCount int32) error

	S3GetBucketPolicy(ctx context.Context, account, region, bucket, accountID string) (*s3.GetBucketPolicyOutput, error)
	S3StreamingGet(ctx context.Context, account, region, bucket, key string) (io.ReadCloser, error)

	DescribeTable(ctx context.Context, account, region, tableName string) (*dynamodbv1.Table, error)
	UpdateCapacity(ctx context.Context, account, region, tableName string, targetTableCapacity *dynamodbv1.Throughput, indexUpdates []*dynamodbv1.IndexUpdateAction, ignoreMaximums bool) (*dynamodbv1.Table, error)
	BatchGetItem(ctx context.Context, account, region string, params *dynamodb.BatchGetItemInput) (*dynamodb.BatchGetItemOutput, error)
	DescribeContinuousBackups(ctx context.Context, account, region string, tableName string) (*dynamodbv1.ContinuousBackups, error)

	GetCallerIdentity(ctx context.Context, account, region string) (*sts.GetCallerIdentityOutput, error)

	SimulateCustomPolicy(ctx context.Context, account, region string, customPolicySimulatorParams *iam.SimulateCustomPolicyInput) (*iam.SimulateCustomPolicyOutput, error)

	Accounts() []string
	AccountsAndRegions() map[string][]string
	GetAccountsInRegion(region string) []string
	GetPrimaryAccountAlias() string
	Regions() []string

	GetDirectClient(account string, region string) (DirectClient, error)
}

type DirectClient

type DirectClient interface {
	Autoscaling() *autoscaling.Client
	Config() *aws.Config
	DynamoDB() *dynamodb.Client
	EC2() *ec2.Client
	IAM() *iam.Client
	Kinesis() *kinesis.Client
	S3() *s3.Client
	STS() *sts.Client
}

DirectClient gives access to the underlying AWS clients from the Golang SDK. This allows arbitrary feature development on top of AWS from other services and modules without having to contribute to the upstream interface. Using these clients will make mocking extremely difficult since it returns the AWS SDK's struct types and not an interface that can be substituted for. It is recommended following initial development of a feature that you add the calls to a service interface so they can be tested more easily.

Jump to

Keyboard shortcuts

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