awscommons

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package awscommons contains routines for interacting with AWS. Meant to provide high level interfaces used throughout various Gruntwork CLIs. NOTE: The routines in this package are adapted for aws-sdk-go-v2, not V1.

Index

Constants

View Source
const (
	DefaultRegion = "us-east-1"
)

Variables

This section is empty.

Functions

func DetachInstances added in v0.13.4

func DetachInstances(opts *Options, asgName string, idList []string) error

DetachInstances requests AWS to detach the instances, removing them from the ASG. It will also request to auto decrement the desired capacity.

func GetAllEnabledRegions added in v0.10.2

func GetAllEnabledRegions(opts *Options) ([]string, error)

GetAllEnabledRegions will return the list of AWS regions (e.g., us-east-1) that are enabled and available to use in the account.

func GetAsgByName added in v0.13.4

func GetAsgByName(opts *Options, asgName string) (*autoscalingTypes.AutoScalingGroup, error)

GetAsgByName finds the Auto Scaling Group matching the given name. Returns an error if it cannot find a match.

func GetSecretsManagerMetadata

func GetSecretsManagerMetadata(opts *Options, secretID string) (*secretsmanager.DescribeSecretOutput, error)

GetSecretsManagerMetadata returns the metadata of the Secrets Manager entry with the given ID.

func GetSecretsManagerSecretString

func GetSecretsManagerSecretString(opts *Options, arn string) (string, error)

GetSecretsManagerSecretString will return the secret value stored at the given Secrets Manager ARN.

func NewAutoScalingClient added in v0.13.4

func NewAutoScalingClient(opts *Options) (*autoscaling.Client, error)

NewAutoscalingClient returns a new AWS SDK client for interacting with AWS Autoscaling.

func NewDefaultConfig

func NewDefaultConfig(opts *Options) (aws.Config, error)

NewDefaultConfig will retrieve a new authenticated AWS config using SDK default credentials. This config can be used to setup new AWS service clients.

func NewEC2Client added in v0.10.2

func NewEC2Client(opts *Options) (*ec2.Client, error)

NewEC2Client will return a new AWS SDK client for interacting with AWS EC2.

func NewS3Client added in v0.10.0

func NewS3Client(opts *Options) (*s3.Client, error)

NewS3Client will return a new AWS SDK client for interacting with AWS S3.

func NewSecretsManagerClient

func NewSecretsManagerClient(opts *Options) (*secretsmanager.Client, error)

NewSecretsManagerClient will return a new AWS SDK client for interacting with AWS Secrets Manager.

func ScaleUp added in v0.13.4

func ScaleUp(
	opts *Options,
	asgName string,
	originalInstanceIds []string,
	desiredCapacity int32,
	maxRetries int,
	sleepBetweenRetries time.Duration,
) ([]string, error)

ScaleUp sets the desired capacity, waits until all the instances are available, and returns the new instance IDs.

func SecretsManagerEntryExists

func SecretsManagerEntryExists(opts *Options, arn string) (bool, error)

SecretsManagerEntryExists returns whether or not the SecretsManager Entry with the given ARN exists. This will return an error if it exists, but is not accessible due to permission issues, or if there is an authentication issue.

func SetAsgMaxSize added in v0.13.4

func SetAsgMaxSize(client *autoscaling.Client, opts *Options, asgName string, maxSize int32) error

SetAsgMaxSize sets the max size on the auto scaling group. Note that updating the max size does not typically change the cluster size.

func UploadObjectString added in v0.10.0

func UploadObjectString(opts *Options, bucket, key, contents string) error

UploadObjectString will upload the provided string to the given S3 bucket as an object under the specified key.

Types

type CouldNotMeetASGCapacityError added in v0.13.4

type CouldNotMeetASGCapacityError struct {
	// contains filtered or unexported fields
}

CouldNotMeetASGCapacityError represents an error related to waiting for ASG to reach desired capacity.

func NewCouldNotMeetASGCapacityError added in v0.13.4

func NewCouldNotMeetASGCapacityError(asgName string, message string) CouldNotMeetASGCapacityError

func (CouldNotMeetASGCapacityError) Error added in v0.13.4

type LookupError added in v0.13.4

type LookupError struct {
	// contains filtered or unexported fields
}

LookupError represents an error related to looking up data on an object.

func NewLookupError added in v0.13.4

func NewLookupError(objectType string, objectId string, objectProperty string) LookupError

NewLookupError constructs a new LookupError object that can be used to return an error related to a look up error.

func (LookupError) Error added in v0.13.4

func (err LookupError) Error() string

type MultipleLookupErrors added in v0.13.4

type MultipleLookupErrors struct {
	// contains filtered or unexported fields
}

MultipleLookupErrors represents multiple errors found while looking up a resource

func NewMultipleLookupErrors added in v0.13.4

func NewMultipleLookupErrors() MultipleLookupErrors

func (MultipleLookupErrors) AddError added in v0.13.4

func (err MultipleLookupErrors) AddError(newErr error)

func (MultipleLookupErrors) Error added in v0.13.4

func (err MultipleLookupErrors) Error() string

func (MultipleLookupErrors) IsEmpty added in v0.13.4

func (err MultipleLookupErrors) IsEmpty() bool

type Options

type Options struct {
	Region string

	Context context.Context
}

Options represents all the parameters necessary for setting up authentication credentials with AWS.

func NewOptions

func NewOptions(region string) *Options

NewOptions will create a new aws.Options struct that provides reasonable defaults for unspecified values.

Jump to

Keyboard shortcuts

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