util

package
v0.38.2 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2025 License: MIT Imports: 20 Imported by: 2

Documentation

Index

Constants

View Source
const AWSAccessDeniedException string = "AccessDeniedException"
View Source
const AWsUnauthorizedError string = "UnauthorizedOperation"
View Source
const (
	AccountIdKey = "accountId"
)
View Source
const AwsDryRunSuccess string = "Request would have succeeded, but DryRun flag is set."
View Source
const (
	ExcludeFirstSeenTagKey = "exclude-first-seen-tag"
)
View Source
const (
	// FirstSeenTagKey A tag used to set custom AWS Tags to resources that do not support `created at` timestamp> - EIP & ECS Clusters.
	// This is used in relation to the `--older-than <duration>` filtering that `cloud-nuke` allows.
	// Due to its destructive nature, `cloud-nuke` has been configured not to delete AWS resources without known creation time,
	// and instead tag them with the `firstSeenTagKey`.
	// The next time `cloud-nuke aws --older-than <duration>` is run, it will use the tag to determine if the AWS resource should be deleted or not.
	FirstSeenTagKey = "cloud-nuke-first-seen"
)

Variables

View Source
var ErrContextExecutionTimeout = errors.New("error:EXECUTION_TIMEOUT")
View Source
var ErrDeleteProtectionEnabled = errors.New("error:DeleteProtectionEnabled")
View Source
var ErrDifferentOwner = errors.New("error:DIFFERENT_OWNER")
View Source
var ErrInSufficientPermission = errors.New("error:INSUFFICIENT_PERMISSION")
View Source
var ErrInterfaceIDNotFound = errors.New("error:InterfaceIdNotFound")
View Source
var ErrInvalidPermisionNotFound = errors.New("error:InvalidPermission.NotFound")
View Source
var ErrResourceNotFoundException = errors.New("error:ErrResourceNotFoundException")

Functions

func ConvertAutoScalingTagsToMap added in v0.33.0

func ConvertAutoScalingTagsToMap(tags []autoscaling.TagDescription) map[string]string

func ConvertIAMTagsToMap added in v0.33.0

func ConvertIAMTagsToMap(tags []iam.Tag) map[string]string

func ConvertNetworkFirewallTagsToMap added in v0.36.0

func ConvertNetworkFirewallTagsToMap(tags []networkfirewalltypes.Tag) map[string]string

func ConvertRDSTypeTagsToMap added in v0.38.0

func ConvertRDSTypeTagsToMap(tags []rdstypes.Tag) map[string]string

func ConvertS3TypesTagsToMap added in v0.38.0

func ConvertS3TypesTagsToMap(tags []s3types.Tag) map[string]string

func ConvertStringPtrTagsToMap added in v0.33.0

func ConvertStringPtrTagsToMap(tags map[string]*string) map[string]string

func ConvertTypesTagsToMap added in v0.38.0

func ConvertTypesTagsToMap(tags []ec2types.Tag) map[string]string

func Difference added in v0.33.0

func Difference(a, b []*string) []*string

Difference returns the elements in `a` that aren't in `b`.

func FormatTimestamp added in v0.33.0

func FormatTimestamp(timestamp time.Time) string

func GetBoolFromContext added in v0.36.0

func GetBoolFromContext(ctx context.Context, key string) (bool, error)

func GetCurrentAccountId added in v0.13.0

func GetCurrentAccountId(config aws.Config) (string, error)

func GetEC2ResourceNameTagValue added in v0.34.0

func GetEC2ResourceNameTagValue(tags []ec2types.Tag) *string

func GetOrCreateFirstSeen added in v0.36.0

func GetOrCreateFirstSeen(ctx context.Context, client interface{}, identifier *string, tags map[string]string) (*time.Time, error)

func IsFirstSeenTag added in v0.33.0

func IsFirstSeenTag(key *string) bool

func ParseTimestamp added in v0.33.0

func ParseTimestamp(timestamp *string) (*time.Time, error)

func RemoveNewlines added in v0.34.0

func RemoveNewlines(s string) string

RemoveNewlines will delete all the newlines in a given string, which is useful for making error messages "sit" more nicely within their specified table cells in the terminal

func Split added in v0.33.0

func Split(identifiers []string, limit int) [][]string

func TransformAWSError added in v0.34.0

func TransformAWSError(err error) error

TransformAWSError this function is used to handle AWS errors and mapping them to a custom error message This could be part of a larger error-handling strategy that interacts with AWS services, providing a more human-readable error message for certain conditions ref : https://docs.aws.amazon.com/AWSEC2/latest/APIReference/errors-overview.html

func Truncate added in v0.34.0

func Truncate(s string, maxLen int) string

Truncate accepts a string and a max length. If the max length is less than the string's current length, then only the first maxLen characters of the string are returned

func UniqueID

func UniqueID() string

Returns a unique (ish) id we can attach to resources and tfstate files so they don't conflict with each other Uses base 62 to generate a 6 character string that's unlikely to collide with the handful of tests we run in parallel. Based on code here: http://stackoverflow.com/a/9543797/483528

Types

type ResourceExecutionTimeout added in v0.35.0

type ResourceExecutionTimeout struct {
	Timeout time.Duration
}

func (ResourceExecutionTimeout) Error added in v0.35.0

func (err ResourceExecutionTimeout) Error() string

Jump to

Keyboard shortcuts

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