Documentation
¶
Overview ¶
Package aws provides AWS cloud provider implementation
Package aws provides service client implementations
Index ¶
- func NewEC2Client(cfg aws.Config) provider.ServiceClient
- func NewEC2ClientDirect(cfg aws.Config) *ec2.Client
- func NewElastiCacheClient(cfg aws.Config) provider.ServiceClient
- func NewMemoryDBClient(cfg aws.Config) provider.ServiceClient
- func NewOpenSearchClient(cfg aws.Config) provider.ServiceClient
- func NewRDSClient(cfg aws.Config) provider.ServiceClient
- func NewRecommendationsClient(cfg aws.Config) provider.RecommendationsClient
- func NewRedshiftClient(cfg aws.Config) provider.ServiceClient
- func NewSavingsPlansClient(cfg aws.Config, planType sptypes.SavingsPlanType) provider.ServiceClient
- type AWSProvider
- func (p *AWSProvider) DisplayName() string
- func (p *AWSProvider) GetAccounts(ctx context.Context) ([]common.Account, error)
- func (p *AWSProvider) GetCredentials() (provider.Credentials, error)
- func (p *AWSProvider) GetDefaultRegion() string
- func (p *AWSProvider) GetRecommendationsClient(ctx context.Context) (provider.RecommendationsClient, error)
- func (p *AWSProvider) GetRegions(ctx context.Context) ([]common.Region, error)
- func (p *AWSProvider) GetServiceClient(ctx context.Context, service common.ServiceType, region string) (provider.ServiceClient, error)
- func (p *AWSProvider) GetSupportedServices() []common.ServiceType
- func (p *AWSProvider) IsConfigured() bool
- func (p *AWSProvider) Name() string
- func (p *AWSProvider) SetConfigLoader(loader ConfigLoader)
- func (p *AWSProvider) SetEC2Client(client EC2Client)
- func (p *AWSProvider) SetOrganizationsPaginator(paginator OrganizationsPaginator)
- func (p *AWSProvider) SetSTSClient(client STSClient)
- func (p *AWSProvider) ValidateCredentials(ctx context.Context) error
- type ConfigLoader
- type EC2Client
- type OrganizationsClient
- type OrganizationsPaginator
- type RecommendationsClientAdapter
- func (r *RecommendationsClientAdapter) GetAllRecommendations(ctx context.Context) ([]common.Recommendation, error)
- func (r *RecommendationsClientAdapter) GetRICoverageMap(ctx context.Context, lookbackDays int, regions []string) (recommendations.PoolCoverageMap, error)
- func (r *RecommendationsClientAdapter) GetRIUtilization(ctx context.Context, lookbackDays int, region string) ([]recommendations.RIUtilization, error)
- func (r *RecommendationsClientAdapter) GetRecommendations(ctx context.Context, params *common.RecommendationParams) ([]common.Recommendation, error)
- func (r *RecommendationsClientAdapter) GetRecommendationsForService(ctx context.Context, service common.ServiceType) ([]common.Recommendation, error)
- func (r *RecommendationsClientAdapter) SetRecLookbackPeriod(period string)
- type STSClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewEC2Client ¶
func NewEC2Client(cfg aws.Config) provider.ServiceClient
NewEC2Client creates a new EC2 service client
func NewEC2ClientDirect ¶
NewEC2ClientDirect creates a new EC2 client returning the concrete type (needed for ListConvertibleReservedInstances which is not part of the generic provider interface).
func NewElastiCacheClient ¶
func NewElastiCacheClient(cfg aws.Config) provider.ServiceClient
NewElastiCacheClient creates a new ElastiCache service client
func NewMemoryDBClient ¶
func NewMemoryDBClient(cfg aws.Config) provider.ServiceClient
NewMemoryDBClient creates a new MemoryDB service client
func NewOpenSearchClient ¶
func NewOpenSearchClient(cfg aws.Config) provider.ServiceClient
NewOpenSearchClient creates a new OpenSearch service client
func NewRDSClient ¶
func NewRDSClient(cfg aws.Config) provider.ServiceClient
NewRDSClient creates a new RDS service client
func NewRecommendationsClient ¶
func NewRecommendationsClient(cfg aws.Config) provider.RecommendationsClient
NewRecommendationsClient creates a new recommendations client
func NewRedshiftClient ¶
func NewRedshiftClient(cfg aws.Config) provider.ServiceClient
NewRedshiftClient creates a new Redshift service client
func NewSavingsPlansClient ¶
func NewSavingsPlansClient(cfg aws.Config, planType sptypes.SavingsPlanType) provider.ServiceClient
NewSavingsPlansClient creates a Savings Plans service client scoped to one AWS plan type. The four per-plan-type slugs (Compute, EC2Instance, SageMaker, Database) each get their own client instance via the AWS provider's GetServiceClient dispatch — see provider.go.
Types ¶
type AWSProvider ¶
type AWSProvider struct {
// contains filtered or unexported fields
}
AWSProvider implements the Provider interface for AWS
func NewAWSProvider ¶
func NewAWSProvider(config *provider.ProviderConfig) (*AWSProvider, error)
NewAWSProvider creates a new AWS provider instance.
Profile resolution order:
- config.AWSProfile (typed field, preferred)
- config.Profile (deprecated overload — kept for backwards compatibility)
func (*AWSProvider) DisplayName ¶
func (p *AWSProvider) DisplayName() string
DisplayName returns the human-readable provider name
func (*AWSProvider) GetAccounts ¶
GetAccounts returns all accessible AWS accounts
func (*AWSProvider) GetCredentials ¶
func (p *AWSProvider) GetCredentials() (provider.Credentials, error)
GetCredentials returns AWS credentials
func (*AWSProvider) GetDefaultRegion ¶
func (p *AWSProvider) GetDefaultRegion() string
GetDefaultRegion returns the default AWS region.
Priority order:
- p.region if explicitly set on the provider.
- p.cfg.Region if the caller pre-populated cfg (e.g. tests with a synthetic config) — checked BEFORE IsConfigured to avoid the SDK's credentials/config chain overwriting a caller-supplied region with the ambient AWS_REGION / ~/.aws/config default.
- The SDK-loaded region (via IsConfigured → loadConfig).
- "us-east-1" as a last-resort default.
Step 2 is what fixes #96: previously this function called IsConfigured() unconditionally, which triggers cfgOnce.Do(loadConfig) and lets the SDK's credentials/config chain populate p.cfg.Region from the developer's ambient environment, masking a region the test had set explicitly. Reading the already-set p.cfg.Region first keeps test fixtures honest while still falling through to the SDK chain when no caller has touched cfg.
func (*AWSProvider) GetRecommendationsClient ¶
func (p *AWSProvider) GetRecommendationsClient(ctx context.Context) (provider.RecommendationsClient, error)
GetRecommendationsClient returns a recommendations client
func (*AWSProvider) GetRegions ¶
GetRegions returns all available AWS regions using EC2 DescribeRegions API
func (*AWSProvider) GetServiceClient ¶
func (p *AWSProvider) GetServiceClient(ctx context.Context, service common.ServiceType, region string) (provider.ServiceClient, error)
GetServiceClient returns a service client for the specified service and region
func (*AWSProvider) GetSupportedServices ¶
func (p *AWSProvider) GetSupportedServices() []common.ServiceType
GetSupportedServices returns the list of services supported by AWS provider. Savings Plans are exposed as four distinct services (one per AWS plan type) so users can configure term/payment defaults per plan type via ServiceConfig.
func (*AWSProvider) IsConfigured ¶
func (p *AWSProvider) IsConfigured() bool
IsConfigured checks if AWS credentials are available. The config is loaded at most once (thread-safe via sync.Once) to avoid data races on concurrent calls.
func (*AWSProvider) SetConfigLoader ¶
func (p *AWSProvider) SetConfigLoader(loader ConfigLoader)
SetConfigLoader sets the config loader (for testing)
func (*AWSProvider) SetEC2Client ¶
func (p *AWSProvider) SetEC2Client(client EC2Client)
SetEC2Client sets the EC2 client (for testing)
func (*AWSProvider) SetOrganizationsPaginator ¶
func (p *AWSProvider) SetOrganizationsPaginator(paginator OrganizationsPaginator)
SetOrganizationsPaginator sets the organizations paginator (for testing)
func (*AWSProvider) SetSTSClient ¶
func (p *AWSProvider) SetSTSClient(client STSClient)
SetSTSClient sets the STS client (for testing)
func (*AWSProvider) ValidateCredentials ¶
func (p *AWSProvider) ValidateCredentials(ctx context.Context) error
ValidateCredentials validates that AWS credentials are working
type ConfigLoader ¶
type ConfigLoader interface {
LoadDefaultConfig(ctx context.Context, optFns ...func(*config.LoadOptions) error) (aws.Config, error)
}
ConfigLoader interface for loading AWS config (enables mocking)
type EC2Client ¶
type EC2Client interface {
DescribeRegions(ctx context.Context, params *ec2.DescribeRegionsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeRegionsOutput, error)
}
EC2Client interface for EC2 operations (enables mocking)
type OrganizationsClient ¶
type OrganizationsClient interface {
ListAccounts(ctx context.Context, params *organizations.ListAccountsInput, optFns ...func(*organizations.Options)) (*organizations.ListAccountsOutput, error)
}
OrganizationsClient interface for Organizations operations (enables mocking)
type OrganizationsPaginator ¶
type OrganizationsPaginator interface {
HasMorePages() bool
NextPage(ctx context.Context, optFns ...func(*organizations.Options)) (*organizations.ListAccountsOutput, error)
}
OrganizationsPaginator interface for Organizations pagination (enables mocking)
type RecommendationsClientAdapter ¶
type RecommendationsClientAdapter struct {
// contains filtered or unexported fields
}
RecommendationsClientAdapter adapts the recommendations client to the provider interface
func NewRecommendationsClientDirect ¶
func NewRecommendationsClientDirect(cfg aws.Config) *RecommendationsClientAdapter
NewRecommendationsClientDirect creates a new recommendations client returning the concrete type (needed for GetRIUtilization which is not part of the generic provider interface).
func (*RecommendationsClientAdapter) GetAllRecommendations ¶
func (r *RecommendationsClientAdapter) GetAllRecommendations(ctx context.Context) ([]common.Recommendation, error)
GetAllRecommendations gets recommendations for all supported services
func (*RecommendationsClientAdapter) GetRICoverageMap ¶
func (r *RecommendationsClientAdapter) GetRICoverageMap(ctx context.Context, lookbackDays int, regions []string) (recommendations.PoolCoverageMap, error)
GetRICoverageMap returns the per-pool RI coverage % over the last lookbackDays days, keyed by "region:instance_type:account" (or "region:instance_type:engine:account" for RDS) so the apply helper can look up per-linked-account coverage. Caller passes the regions to scan; CE returns coverage filtered to that region and grouped by LINKED_ACCOUNT + INSTANCE_TYPE.
func (*RecommendationsClientAdapter) GetRIUtilization ¶
func (r *RecommendationsClientAdapter) GetRIUtilization(ctx context.Context, lookbackDays int, region string) ([]recommendations.RIUtilization, error)
GetRIUtilization gets per-RI utilization from Cost Explorer, scoped to EC2 RIs in region.
func (*RecommendationsClientAdapter) GetRecommendations ¶
func (r *RecommendationsClientAdapter) GetRecommendations(ctx context.Context, params *common.RecommendationParams) ([]common.Recommendation, error)
GetRecommendations gets recommendations with filtering
func (*RecommendationsClientAdapter) GetRecommendationsForService ¶
func (r *RecommendationsClientAdapter) GetRecommendationsForService(ctx context.Context, service common.ServiceType) ([]common.Recommendation, error)
GetRecommendationsForService gets recommendations for a specific service
func (*RecommendationsClientAdapter) SetRecLookbackPeriod ¶
func (r *RecommendationsClientAdapter) SetRecLookbackPeriod(period string)
SetRecLookbackPeriod configures the LookbackPeriodInDays forwarded to GetReservationPurchaseRecommendation. Valid values: "7d", "30d", "60d".
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
purchasecfg
Package purchasecfg provides a tightened AWS SDK config for purchase-path clients.
|
Package purchasecfg provides a tightened AWS SDK config for purchase-path clients. |
|
tagging
Package tagging builds the shared CUDly tag set applied to AWS Reserved Instance-style commitments at purchase time.
|
Package tagging builds the shared CUDly tag set applied to AWS Reserved Instance-style commitments at purchase time. |
|
Package ladder implements ladder.LadderCapability for AWS: the read side (commitment listing, layer states, usage baseline) and the write side (layer purchases, buffer reshaping).
|
Package ladder implements ladder.LadderCapability for AWS: the read side (commitment listing, layer states, usage baseline) and the write side (layer purchases, buffer reshaping). |
|
Package recommendations provides AWS Cost Explorer recommendations client
|
Package recommendations provides AWS Cost Explorer recommendations client |
|
services
|
|
|
ec2
Package ec2 provides AWS EC2 Reserved Instances client
|
Package ec2 provides AWS EC2 Reserved Instances client |
|
elasticache
Package elasticache provides AWS ElastiCache Reserved Cache Nodes client
|
Package elasticache provides AWS ElastiCache Reserved Cache Nodes client |
|
memorydb
Package memorydb provides AWS MemoryDB Reserved Nodes client
|
Package memorydb provides AWS MemoryDB Reserved Nodes client |
|
opensearch
Package opensearch provides AWS OpenSearch Reserved Instances client
|
Package opensearch provides AWS OpenSearch Reserved Instances client |
|
rds
Package rds provides AWS RDS Reserved Instances client
|
Package rds provides AWS RDS Reserved Instances client |
|
redshift
Package redshift provides AWS Redshift Reserved Nodes client
|
Package redshift provides AWS Redshift Reserved Nodes client |
|
savingsplans
Package savingsplans provides AWS Savings Plans purchase client
|
Package savingsplans provides AWS Savings Plans purchase client |