aws

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package aws provides AWS SDK abstractions and utilities for EKS cluster management. It implements clean patterns for AMI resolution, cluster discovery, and error handling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AvailableClusters added in v0.5.0

func AvailableClusters(ctx context.Context, awsCfg aws.Config) ([]string, error)

AvailableClusters returns all EKS cluster names in the current region.

func CheckAWSCredentials added in v0.5.12

func CheckAWSCredentials(ctx context.Context, awsCfg aws.Config) error

CheckAWSCredentials validates AWS credentials and, on failure, prints a red error message followed by credential setup guidance. It returns a sentinel error so callers can return immediately without further decoration.

func ClusterName

func ClusterName(ctx context.Context, awsCfg aws.Config, cliFlag string) (string, error)

ClusterName resolves the EKS cluster name from CLI flag or kubeconfig. It supports partial name matching and prompts for confirmation when multiple matches exist.

func ConfirmNodegroupSelection

func ConfirmNodegroupSelection(matches []string, pattern string) ([]string, error)

ConfirmNodegroupSelection prompts user to confirm when multiple nodegroups match. Returns the selected nodegroups or error if user cancels.

func CurrentAmiID

func CurrentAmiID(ctx context.Context, ng *types.Nodegroup, ec2Client *ec2.Client, autoscalingClient *autoscaling.Client) string

CurrentAmiID resolves the current AMI ID for a nodegroup. It attempts resolution in order: launch template, then ASG instance.

func FormatAWSError added in v0.1.8

func FormatAWSError(err error, operation string) error

FormatAWSError provides user-friendly error messages for AWS errors.

Classification order matters: context cancellation is user-initiated and needs no remediation help; typed API errors carry an authoritative error code and must win over substring heuristics (an IAM denial that mentions "region" in its message is not a region misconfiguration); substring matching is the last resort for transport/credential-chain failures that never reached the API.

func IsCredentialError added in v0.1.8

func IsCredentialError(err error) bool

IsCredentialError checks if the error is related to AWS credentials.

func IsNetworkError added in v0.1.8

func IsNetworkError(err error) bool

IsNetworkError checks if the error is network-related.

func IsPermissionError added in v0.3.0

func IsPermissionError(err error) bool

IsPermissionError checks if the error is permissions-related.

func IsRegionError added in v0.3.0

func IsRegionError(err error) bool

IsRegionError checks if the error is related to AWS region configuration. Matching is deliberately narrow: many unrelated AWS errors merely mention a region name ("user is not authorized ... in region us-east-1"), and those must not be diagnosed as region misconfiguration.

func LatestAmiIDForType added in v0.2.2

func LatestAmiIDForType(ctx context.Context, ssmClient *ssm.Client, k8sVersion string, amiType types.AMITypes) string

LatestAmiIDForType returns the latest recommended AMI ID for a specific AMI type. It queries AWS SSM Parameter Store for the EKS-optimized AMI. Supports AL2, AL2023, Bottlerocket, and Windows AMI types.

func LatestReleaseVersionForType added in v0.7.0

func LatestReleaseVersionForType(ctx context.Context, ssmClient *ssm.Client, k8sVersion string, amiType types.AMITypes) string

LatestReleaseVersionForType returns the latest recommended AMI *release version* (e.g. "1.31.0-20260601") for an AMI type — the human-meaningful counterpart of LatestAmiIDForType, used for changelog/version-delta display. Returns "" for custom AMIs or when the SSM parameter is unavailable.

func ListAllPages added in v0.7.0

func ListAllPages[O, T any](
	ctx context.Context,
	operation string,
	call func(ctx context.Context, token *string) (O, error),
	extract func(O) (items []T, next *string),
) ([]T, error)

ListAllPages pages through an AWS list API, retrying each page call with common.DefaultRetryConfig and formatting failures with FormatAWSError. call fetches one page for the given token; extract pulls the items and the next token out of the page output.

It replaces the Paginate(WithRetry(...)) sandwich previously duplicated by every list-style service method, so the retry and error-formatting policy lives in one place.

func MatchingClusters

func MatchingClusters(clusters []string, pattern string) []string

MatchingClusters returns cluster names that contain the given pattern. If pattern is empty, returns all clusters.

func MatchingNodegroups

func MatchingNodegroups(nodegroups []string, pattern string) []string

MatchingNodegroups returns nodegroup names that contain the given pattern. If pattern is empty, returns all nodegroups.

func PrintCredentialHelp added in v0.1.8

func PrintCredentialHelp()

PrintCredentialHelp displays helpful credential setup information.

func ValidateAWSCredentials added in v0.1.8

func ValidateAWSCredentials(ctx context.Context, awsCfg aws.Config) error

ValidateAWSCredentials performs a basic validation of AWS credentials.

Types

This section is empty.

Jump to

Keyboard shortcuts

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