Documentation
¶
Index ¶
- Constants
- Variables
- func ConvertAutoScalingTagsToMap(tags []autoscaling.TagDescription) map[string]string
- func ConvertCloudFormationTagsToMap(tags []cloudformationtypes.Tag) map[string]string
- func ConvertEFSTagsToMap(tags []efstypes.Tag) map[string]string
- func ConvertIAMTagsToMap(tags []iam.Tag) map[string]string
- func ConvertNetworkFirewallTagsToMap(tags []networkfirewalltypes.Tag) map[string]string
- func ConvertOpenSearchTagsToMap(tags []opensearchtypes.Tag) map[string]string
- func ConvertRDSTypeTagsToMap(tags []rdstypes.Tag) map[string]string
- func ConvertRedshiftTagsToMap(tags []redshifttypes.Tag) map[string]string
- func ConvertRoute53TagsToMap(tags []route53types.Tag) map[string]string
- func ConvertS3TypesTagsToMap(tags []s3types.Tag) map[string]string
- func ConvertSageMakerTagsToMap(tags []sagemakertypes.Tag) map[string]string
- func ConvertSecretsManagerTagsToMap(tags []secretsmanagertypes.Tag) map[string]string
- func ConvertStringPtrTagsToMap(tags map[string]*string) map[string]string
- func ConvertTypesTagsToMap(tags []ec2types.Tag) map[string]string
- func DerefString(p *string) string
- func DerefStringSlice(ps []*string) []string
- func Difference(a, b []*string) []*string
- func FormatTimestamp(timestamp time.Time) string
- func GetBoolFromContext(ctx context.Context, key ContextKey) (bool, error)
- func GetCurrentAccountId(config aws.Config) (string, error)
- func GetEC2ResourceNameTagValue(tags []ec2types.Tag) *string
- func GetOrCreateFirstSeen(ctx context.Context, client interface{}, identifier *string, ...) (*time.Time, error)
- func IsFirstSeenTag(key *string) bool
- func IsThrottlingError(err error) bool
- func IsWarningError(err error) bool
- func ParseTimestamp(timestamp *string) (*time.Time, error)
- func PollUntil(ctx context.Context, description string, interval, timeout time.Duration, ...) error
- func RemoveNewlines(s string) string
- func Split(identifiers []string, limit int) [][]string
- func ToStringPtrSlice(strs []string) []*string
- func TransformAWSError(err error) error
- func Truncate(s string, maxLen int) string
- func UniqueID() string
- type ContextKey
- type ResourceExecutionTimeout
Constants ¶
const AWSAccessDeniedException string = "AccessDeniedException"
const AwsDryRunSuccess string = "Request would have succeeded, but DryRun flag is set."
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 ¶
var ErrContextExecutionTimeout = errors.New("error:EXECUTION_TIMEOUT")
var ErrDeleteProtectionEnabled = errors.New("error:DeleteProtectionEnabled")
var ErrDifferentOwner = errors.New("error:DIFFERENT_OWNER")
var ErrInSufficientPermission = errors.New("error:INSUFFICIENT_PERMISSION")
var ErrInterfaceIDNotFound = errors.New("error:InterfaceIdNotFound")
var ErrInvalidGroupNotFound = errors.New("error:InvalidGroup.NotFound")
var ErrInvalidPermisionNotFound = errors.New("error:InvalidPermission.NotFound")
var ErrInvalidSnapshotNotFound = errors.New("error:InvalidSnapshot.NotFound")
var ErrResourceNotFoundException = errors.New("error:ErrResourceNotFoundException")
Functions ¶
func ConvertAutoScalingTagsToMap ¶ added in v0.33.0
func ConvertAutoScalingTagsToMap(tags []autoscaling.TagDescription) map[string]string
func ConvertCloudFormationTagsToMap ¶ added in v0.43.0
func ConvertCloudFormationTagsToMap(tags []cloudformationtypes.Tag) map[string]string
func ConvertEFSTagsToMap ¶ added in v0.47.0
func ConvertIAMTagsToMap ¶ added in v0.33.0
func ConvertNetworkFirewallTagsToMap ¶ added in v0.36.0
func ConvertNetworkFirewallTagsToMap(tags []networkfirewalltypes.Tag) map[string]string
func ConvertOpenSearchTagsToMap ¶ added in v0.47.0
func ConvertOpenSearchTagsToMap(tags []opensearchtypes.Tag) map[string]string
func ConvertRDSTypeTagsToMap ¶ added in v0.38.0
func ConvertRedshiftTagsToMap ¶ added in v0.47.0
func ConvertRedshiftTagsToMap(tags []redshifttypes.Tag) map[string]string
func ConvertRoute53TagsToMap ¶ added in v0.42.0
func ConvertRoute53TagsToMap(tags []route53types.Tag) map[string]string
func ConvertS3TypesTagsToMap ¶ added in v0.38.0
func ConvertSageMakerTagsToMap ¶ added in v0.41.0
func ConvertSageMakerTagsToMap(tags []sagemakertypes.Tag) map[string]string
ConvertSageMakerTagsToMap converts SageMaker tags to a map[string]string
func ConvertSecretsManagerTagsToMap ¶ added in v0.43.0
func ConvertSecretsManagerTagsToMap(tags []secretsmanagertypes.Tag) map[string]string
func ConvertStringPtrTagsToMap ¶ added in v0.33.0
func ConvertTypesTagsToMap ¶ added in v0.38.0
func DerefString ¶ added in v0.47.0
DerefString safely dereferences a string pointer, returning "" for nil.
func DerefStringSlice ¶ added in v0.47.0
DerefStringSlice dereferences a slice of string pointers to a slice of strings.
func Difference ¶ added in v0.33.0
Difference returns the elements in `a` that aren't in `b`.
func FormatTimestamp ¶ added in v0.33.0
func GetBoolFromContext ¶ added in v0.36.0
func GetBoolFromContext(ctx context.Context, key ContextKey) (bool, error)
func GetCurrentAccountId ¶ added in v0.13.0
func GetEC2ResourceNameTagValue ¶ added in v0.34.0
func GetOrCreateFirstSeen ¶ added in v0.36.0
func IsFirstSeenTag ¶ added in v0.33.0
func IsThrottlingError ¶ added in v0.47.0
IsThrottlingError checks if the error is an AWS API throttling error using structured error code matching via smithy.APIError.
func IsWarningError ¶ added in v0.47.0
IsWarningError checks if the error is a transient/expected failure that should be logged as a warning rather than causing a non-zero exit code. These errors fall into two categories:
Ordering/dependency errors — resources deleted in the wrong order. The dependent resource will be cleaned up on the next nuke run once the parent is gone:
- DependencyViolation: EC2 subnet/ENI/SG still referenced by another resource
- InvalidDBSubnetGroupStateFault: RDS subnet group in use by a DB instance
- InvalidDBClusterStateFault: RDS cluster can't be deleted while its instances exist
- InvalidClusterState: Redshift cluster has an operation in progress
- InvalidHomeRegionException: CloudTrail trail can only be deleted from its home region
Already-deleted errors — resource was deleted between the scan and nuke phases (e.g., by another concurrent nuke run or TTL expiry). Safe to ignore:
- DBSubnetGroupNotFoundFault: RDS subnet group no longer exists
- DBParameterGroupNotFound: RDS parameter group no longer exists
- InvalidSubnetID.NotFound: EC2 subnet no longer exists
- InvalidNetworkInterfaceID.NotFound: EC2 ENI no longer exists
- TrailNotFoundException: CloudTrail trail already deleted by another region/job
func PollUntil ¶ added in v0.47.0
func PollUntil(ctx context.Context, description string, interval, timeout time.Duration, condition func(ctx context.Context) (bool, error)) error
PollUntil repeatedly calls condition until it returns true, the timeout elapses, or the context is cancelled. The condition is checked immediately on the first iteration (before any sleep). This is useful for waiting on async AWS operations that lack a built-in SDK waiter (e.g., VPN gateway detachment).
The interval is the delay between condition checks. The caller must ensure interval > 0 to avoid a hot spin loop.
func RemoveNewlines ¶ added in v0.34.0
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 ToStringPtrSlice ¶ added in v0.47.0
ToStringPtrSlice converts a slice of strings to a slice of string pointers.
func TransformAWSError ¶ added in v0.34.0
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
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 ContextKey ¶ added in v0.46.0
type ContextKey string
ContextKey is a custom type to avoid collisions when using context.WithValue
const AccountIdKey ContextKey = "accountId"
AccountIdKey is the context key used to store the AWS account ID.
const (
ExcludeFirstSeenTagKey ContextKey = "exclude-first-seen-tag"
)
type ResourceExecutionTimeout ¶ added in v0.35.0
func (ResourceExecutionTimeout) Error ¶ added in v0.35.0
func (err ResourceExecutionTimeout) Error() string