aws

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 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 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.

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.4.1

func IsPermissionError(err error) bool

IsPermissionError checks if the error is permissions-related.

func IsRegionError added in v0.4.1

func IsRegionError(err error) bool

IsRegionError checks if the error is related to AWS region configuration.

func LatestAmiID

func LatestAmiID(ctx context.Context, ssmClient *ssm.Client, k8sVersion string) string

LatestAmiID returns the latest recommended AMI ID for a given Kubernetes version. It defaults to AL2 x86_64 for backward compatibility.

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 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 Nodegroups

func Nodegroups(ctx context.Context, awsCfg aws.Config, clusterName string) ([]refreshTypes.NodegroupInfo, error)

Nodegroups retrieves all nodegroups for a cluster with their AMI status.

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

type AMICache added in v0.4.1

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

AMICache provides thread-safe caching for AMI lookups.

func NewAMICache added in v0.4.1

func NewAMICache() *AMICache

NewAMICache creates a new AMI cache instance.

func (*AMICache) Get added in v0.4.1

func (c *AMICache) Get(key string) (string, bool)

Get retrieves a value from the cache in a thread-safe manner.

func (*AMICache) Set added in v0.4.1

func (c *AMICache) Set(key, value string)

Set stores a value in the cache in a thread-safe manner.

type AMIResolver added in v0.4.1

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

AMIResolver handles AMI ID resolution for EKS nodegroups. It supports caching to reduce API calls for repeated lookups.

func NewAMIResolver added in v0.4.1

func NewAMIResolver(ec2Client *ec2.Client, autoscalingClient *autoscaling.Client, ssmClient *ssm.Client) *AMIResolver

NewAMIResolver creates a new AMI resolver with the provided AWS clients.

type AWSError added in v0.4.1

type AWSError struct {
	Operation string
	Err       error
	Category  ErrorCategory
}

AWSError wraps an error with AWS-specific context.

func (*AWSError) Error added in v0.4.1

func (e *AWSError) Error() string

func (*AWSError) Unwrap added in v0.4.1

func (e *AWSError) Unwrap() error

type ClusterResolver added in v0.4.1

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

ClusterResolver handles cluster name resolution and matching.

func NewClusterResolver added in v0.4.1

func NewClusterResolver(awsCfg aws.Config) *ClusterResolver

NewClusterResolver creates a new cluster resolver.

type ErrorCategory added in v0.4.1

type ErrorCategory int

ErrorCategory classifies the type of AWS error.

const (
	ErrorCategoryUnknown ErrorCategory = iota
	ErrorCategoryCredential
	ErrorCategoryNetwork
	ErrorCategoryPermission
	ErrorCategoryRegion
	ErrorCategoryAPI
)

type NodegroupClient added in v0.4.1

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

NodegroupClient handles nodegroup operations.

func NewNodegroupClient added in v0.4.1

func NewNodegroupClient(awsCfg aws.Config) *NodegroupClient

NewNodegroupClient creates a new nodegroup client.

Jump to

Keyboard shortcuts

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