aws

package
v0.0.0-...-8b28c38 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: Apache-2.0 Imports: 42 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SpotInfoUpdateType   = "spotinfo"
	AthenaInfoUpdateType = "athenainfo"
	PreemptibleType      = "preemptible"

	APIPricingSource              = "Public API"
	SpotPricingSource             = "Spot Data Feed"
	ReservedInstancePricingSource = "Savings Plan, Reserved Instance, and Out-Of-Cluster"

	InUseState    = "in-use"
	AttachedState = "attached"

	AWSHourlyPublicIPCost    = 0.005
	EKSCapacityTypeLabel     = "eks.amazonaws.com/capacityType"
	EKSCapacitySpotTypeValue = "SPOT"
)
View Source
const AccessKeyAuthorizerType = "AWSAccessKey"
View Source
const AssumeRoleAuthorizerType = "AWSAssumeRole"
View Source
const AthenaDateColumn = "line_item_usage_start_date"

athenaDateTruncColumn Aggregates line items from the hourly level to daily. "line_item_usage_start_date" is used because at all time values 00:00-23:00 it will truncate to the correct date.

View Source
const AthenaDateLayout = "2006-01-02 15:04:05.000"

athenaDateLayout is the default AWS date format

View Source
const AthenaDateTruncColumn = "DATE_TRUNC('day'," + AthenaDateColumn + ") as usage_date"
View Source
const AthenaNetPricingColumn = "line_item_net_unblended_cost"

Net Cost Columns

View Source
const AthenaNetRIPricingColumn = "reservation_net_effective_cost"

Amortized Net Cost Columns

View Source
const AthenaNetSPPricingColumn = "savings_plan_net_savings_plan_effective_cost"
View Source
const AthenaPricingColumn = "line_item_unblended_cost"

Cost Columns

View Source
const AthenaRIPricingColumn = "reservation_effective_cost"

Amortized Cost Columns

View Source
const AthenaSPPricingColumn = "savings_plan_savings_plan_effective_cost"
View Source
const AthenaWhereDateFmt = `line_item_usage_start_date >= date '%s' AND line_item_usage_start_date < date '%s'`
View Source
const AthenaWhereUsage = "" /* 236-byte string literal not displayed */
View Source
const ClusterIdEnvVar = "AWS_CLUSTER_ID"

ClusterIdEnvVar is the environment variable in which one can manually set the ClusterId

View Source
const HourlyRateCode = "6YS6EN2CT7"

HourlyRateCode is appended to a node sku

View Source
const HourlyRateCodeCn = "Q7UJUT2CE6"
View Source
const LabelColumnPrefix = "resource_tags_user_"
View Source
const S3SelectAccountID = `s."bill/PayerAccountId"`

S3Object is aliased as "s" in queries

View Source
const S3SelectDateLayout = "2006-01-02T15:04:05Z"
View Source
const S3SelectItemType = `s."lineItem/LineItemType"`
View Source
const S3SelectListCost = `s."lineItem/UnblendedCost"`
View Source
const S3SelectNetCost = `s."lineItem/NetUnblendedCost"`
View Source
const S3SelectProductCode = `s."lineItem/ProductCode"`
View Source
const S3SelectRICost = `s."reservation/EffectiveCost"`

These two may be used for Amortized<Net>Cost

View Source
const S3SelectResourceID = `s."lineItem/ResourceId"`
View Source
const S3SelectSPCost = `s."savingsPlan/SavingsPlanEffectiveCost"`
View Source
const S3SelectStartDate = `s."lineItem/UsageStartDate"`
View Source
const S3SelectUsageType = `s."lineItem/UsageType"`
View Source
const ServiceAccountAuthorizerType = "AWSServiceAccount"
View Source
const SpotRefreshDuration = 15 * time.Minute

SpotRefreshDuration represents how much time must pass before we refresh

Variables

View Source
var AthenaNetPricingCoalesce = fmt.Sprintf("COALESCE(%s, %s, 0)", AthenaNetPricingColumn, AthenaPricingColumn)
View Source
var AthenaNetRIPricingCoalesce = fmt.Sprintf("COALESCE(%s, %s, 0)", AthenaNetRIPricingColumn, AthenaRIPricingColumn)
View Source
var AthenaNetSPPricingCoalesce = fmt.Sprintf("COALESCE(%s, %s, 0)", AthenaNetSPPricingColumn, AthenaSPPricingColumn)
View Source
var OnDemandRateCodes = map[string]struct{}{
	"JRTCKXETXF": {},
}

OnDemandRateCodes is are sets of identifiers for offerTermCodes matching 'On Demand' rates

View Source
var OnDemandRateCodesCn = map[string]struct{}{
	"99YE2YK9UR": {},
	"5Y9WH78GDR": {},
	"KW44MY7SZN": {},
}
View Source
var (

	// StorageClassProvisionerDefaults specifies the default storage class types depending upon the provisioner
	StorageClassProvisionerDefaults = map[string]string{
		"kubernetes.io/aws-ebs": "gp2",
		"ebs.csi.aws.com":       "gp3",
	}
)

Functions

func ConvertAwsAthenaInfoToConfig

func ConvertAwsAthenaInfoToConfig(aai AwsAthenaInfo) config.KeyedConfig

ConvertAwsAthenaInfoToConfig takes a legacy config and generates a Config based on the presence of properties to match legacy behavior

func GetAthenaQueryFunc

func GetAthenaQueryFunc(fn func(types.Row)) func(*athena.GetQueryResultsOutput) bool

func GetAthenaRowValue

func GetAthenaRowValue(row types.Row, queryColumnIndexes map[string]int, columnName string) string

GetAthenaRowValue retrieve value from athena row based on column names and used stringutil.Bank() to prevent duplicate allocation of strings

func GetAthenaRowValueFloat

func GetAthenaRowValueFloat(row types.Row, queryColumnIndexes map[string]int, columnName string) (float64, error)

getAthenaRowValueFloat retrieve value from athena row based on column names and convert to float if possible

func GetCSVRowValue

func GetCSVRowValue(row []string, queryColumnIndexes map[string]int, columnName string) string

GetCSVRowValue retrieve value from athena row based on column names and used stringutil.Bank() to prevent duplicate allocation of strings

func GetCSVRowValueFloat

func GetCSVRowValueFloat(row []string, queryColumnIndexes map[string]int, columnName string) (float64, error)

GetCSVRowValueFloat retrieve value from athena row based on column names and convert to float if possible.

func ParseARN

func ParseARN(id string) string

func SelectAWSCategory

func SelectAWSCategory(providerID, usageType, service string) string

Types

type AWS

type AWS struct {
	Pricing                     map[string]*AWSProductTerms
	SpotPricingByInstanceID     map[string]*spotInfo
	SpotPricingUpdatedAt        *time.Time
	SpotRefreshRunning          bool
	SpotPricingLock             sync.RWMutex
	SpotPricingError            error
	RIPricingByInstanceID       map[string]*RIData
	RIPricingError              error
	RIDataRunning               bool
	RIDataLock                  sync.RWMutex
	SavingsPlanDataByInstanceID map[string]*SavingsPlanData
	SavingsPlanDataRunning      bool
	SavingsPlanDataLock         sync.RWMutex
	ValidPricingKeys            map[string]bool
	Clientset                   clustercache.ClusterCache
	BaseCPUPrice                string
	BaseRAMPrice                string
	BaseGPUPrice                string
	BaseSpotCPUPrice            string
	BaseSpotRAMPrice            string
	BaseSpotGPUPrice            string
	SpotLabelName               string
	SpotLabelValue              string
	SpotDataRegion              string
	SpotDataBucket              string
	SpotDataPrefix              string
	ProjectID                   string
	DownloadPricingDataLock     sync.RWMutex
	Config                      models.ProviderConfig
	ServiceAccountChecks        *models.ServiceAccountChecks

	ClusterRegion    string
	ClusterAccountID string
	// contains filtered or unexported fields
}

AWS represents an Amazon Provider

func (*AWS) AllNodePricing

func (aws *AWS) AllNodePricing() (interface{}, error)

AllNodePricing returns all the billing data fetched.

func (*AWS) ApplyReservedInstancePricing

func (aws *AWS) ApplyReservedInstancePricing(nodes map[string]*models.Node)

ApplyReservedInstancePricing TODO

func (*AWS) ClusterInfo

func (awsProvider *AWS) ClusterInfo() (map[string]string, error)

ClusterInfo returns an object that represents the cluster. TODO: actually return the name of the cluster. Blocked on cluster federation.

func (*AWS) ClusterManagementPricing

func (aws *AWS) ClusterManagementPricing() (string, float64, error)

func (*AWS) CombinedDiscountForNode

func (aws *AWS) CombinedDiscountForNode(instanceType string, isPreemptible bool, defaultDiscount, negotiatedDiscount float64) float64

func (*AWS) ConfigureAuth

func (aws *AWS) ConfigureAuth() error

updates the authentication to the latest values (via config or secret)

func (*AWS) ConfigureAuthWith

func (aws *AWS) ConfigureAuthWith(config *models.CustomPricing) error

updates the authentication to the latest values (via config or secret)

func (*AWS) DownloadPricingData

func (aws *AWS) DownloadPricingData() error

DownloadPricingData fetches data from the AWS Pricing API

func (*AWS) GetAWSAccessKey

func (aws *AWS) GetAWSAccessKey() (*AWSAccessKey, error)

GetAWSAccessKey generate an AWSAccessKey object from the config

func (*AWS) GetAWSAthenaInfo

func (aws *AWS) GetAWSAthenaInfo() (*AwsAthenaInfo, error)

GetAWSAthenaInfo generate an AWSAthenaInfo object from the config

func (*AWS) GetAddresses

func (aws *AWS) GetAddresses() ([]byte, error)

GetAddresses retrieves EC2 addresses

func (*AWS) GetConfig

func (aws *AWS) GetConfig() (*models.CustomPricing, error)

func (*AWS) GetDisks

func (aws *AWS) GetDisks() ([]byte, error)

GetDisks returns the AWS disks backing PVs. Useful because sometimes k8s will not clean up PVs correctly. Requires a json config in /var/configs with key region.

func (*AWS) GetKey

func (aws *AWS) GetKey(labels map[string]string, n *v1.Node) models.Key

GetKey maps node labels to information needed to retrieve pricing data

func (*AWS) GetLocalStorageQuery

func (aws *AWS) GetLocalStorageQuery(window, offset time.Duration, rate bool, used bool) string

func (*AWS) GetManagementPlatform

func (aws *AWS) GetManagementPlatform() (string, error)

func (*AWS) GetOrphanedResources

func (aws *AWS) GetOrphanedResources() ([]models.OrphanedResource, error)

func (*AWS) GetPVKey

func (aws *AWS) GetPVKey(pv *v1.PersistentVolume, parameters map[string]string, defaultRegion string) models.PVKey

func (*AWS) GetReservationDataFromAthena

func (aws *AWS) GetReservationDataFromAthena() error

func (*AWS) GetSavingsPlanDataFromAthena

func (aws *AWS) GetSavingsPlanDataFromAthena() error

func (*AWS) KubeAttrConversion

func (aws *AWS) KubeAttrConversion(location, instanceType, operatingSystem string) string

KubeAttrConversion maps the k8s labels for region to an aws region

func (*AWS) LoadBalancerPricing

func (aws *AWS) LoadBalancerPricing() (*models.LoadBalancer, error)

func (*AWS) NetworkPricing

func (aws *AWS) NetworkPricing() (*models.Network, error)

Stubbed NetworkPricing for AWS. Pull directly from aws.json for now

func (*AWS) NodePricing

func (aws *AWS) NodePricing(k models.Key) (*models.Node, models.PricingMetadata, error)

NodePricing takes in a key from GetKey and returns a Node object for use in building the cost model.

func (*AWS) PVPricing

func (aws *AWS) PVPricing(pvk models.PVKey) (*models.PV, error)

func (*AWS) PricingSourceStatus

func (aws *AWS) PricingSourceStatus() map[string]*models.PricingSource

func (*AWS) PricingSourceSummary

func (aws *AWS) PricingSourceSummary() interface{}

PricingSourceSummary returns the pricing source summary for the provider. The summary represents what was _parsed_ from the pricing source, not everything that was _available_ in the pricing source.

func (*AWS) QueryAthenaPaginated

func (aws *AWS) QueryAthenaPaginated(ctx context.Context, query string, fn func(*athena.GetQueryResultsOutput) bool) error

QueryAthenaPaginated executes athena query and processes results.

func (*AWS) Regions

func (aws *AWS) Regions() []string

Regions returns a predefined list of AWS regions

func (*AWS) ServiceAccountStatus

func (aws *AWS) ServiceAccountStatus() *models.ServiceAccountStatus

func (*AWS) SpotRefreshEnabled

func (aws *AWS) SpotRefreshEnabled() bool

SpotRefreshEnabled determines whether the required configs to run the spot feed query have been set up

func (*AWS) UpdateConfig

func (aws *AWS) UpdateConfig(r io.Reader, updateType string) (*models.CustomPricing, error)

func (*AWS) UpdateConfigFromConfigMap

func (aws *AWS) UpdateConfigFromConfigMap(cm map[string]string) (*models.CustomPricing, error)

type AWSAccessKey

type AWSAccessKey struct {
	AccessKeyID     string `json:"aws_access_key_id"`
	SecretAccessKey string `json:"aws_secret_access_key"`
}

AWSAccessKey holds AWS credentials and fulfils the awsV2.CredentialsProvider interface Deprecated: v1.104 Use AccessKey instead

func (AWSAccessKey) CreateConfig

func (accessKey AWSAccessKey) CreateConfig(region string) (awsSDK.Config, error)

CreateConfig creates an AWS SDK V2 Config for the credentials that it contains for the provided region

func (AWSAccessKey) Retrieve

func (accessKey AWSAccessKey) Retrieve(ctx context.Context) (awsSDK.Credentials, error)

Retrieve returns a set of awsV2 credentials using the AWSAccessKey's key and secret. This fulfils the awsV2.CredentialsProvider interface contract.

type AWSCurrencyCode

type AWSCurrencyCode struct {
	USD string `json:"USD,omitempty"`
	CNY string `json:"CNY,omitempty"`
}

AWSCurrencyCode is the localized currency. (TODO: support non-USD)

type AWSOfferTerm

type AWSOfferTerm struct {
	Sku             string                  `json:"sku"`
	OfferTermCode   string                  `json:"offerTermCode"`
	PriceDimensions map[string]*AWSRateCode `json:"priceDimensions"`
}

AWSOfferTerm is a sku extension used to pay for the node.

func (*AWSOfferTerm) String

func (ot *AWSOfferTerm) String() string

type AWSPricing

type AWSPricing struct {
	Products map[string]*AWSProduct `json:"products"`
	Terms    AWSPricingTerms        `json:"terms"`
}

AWSPricing maps a k8s node to an AWS Pricing "product"

type AWSPricingTerms

type AWSPricingTerms struct {
	OnDemand map[string]map[string]*AWSOfferTerm `json:"OnDemand"`
	Reserved map[string]map[string]*AWSOfferTerm `json:"Reserved"`
}

AWSPricingTerms are how you pay for the node: OnDemand, Reserved, or (TODO) Spot

type AWSProduct

type AWSProduct struct {
	Sku        string               `json:"sku"`
	Attributes AWSProductAttributes `json:"attributes"`
}

AWSProduct represents a purchased SKU

type AWSProductAttributes

type AWSProductAttributes struct {
	Location        string `json:"location"`
	InstanceType    string `json:"instanceType"`
	Memory          string `json:"memory"`
	Storage         string `json:"storage"`
	VCpu            string `json:"vcpu"`
	UsageType       string `json:"usagetype"`
	OperatingSystem string `json:"operatingSystem"`
	PreInstalledSw  string `json:"preInstalledSw"`
	InstanceFamily  string `json:"instanceFamily"`
	CapacityStatus  string `json:"capacitystatus"`
	GPU             string `json:"gpu"` // GPU represents the number of GPU on the instance
}

AWSProductAttributes represents metadata about the product used to map to a node.

type AWSProductTerms

type AWSProductTerms struct {
	Sku      string        `json:"sku"`
	OnDemand *AWSOfferTerm `json:"OnDemand"`
	Reserved *AWSOfferTerm `json:"Reserved"`
	Memory   string        `json:"memory"`
	Storage  string        `json:"storage"`
	VCpu     string        `json:"vcpu"`
	GPU      string        `json:"gpu"` // GPU represents the number of GPU on the instance
	PV       *models.PV    `json:"pv"`
}

AWSProductTerms represents the full terms of the product

type AWSRateCode

type AWSRateCode struct {
	Unit         string          `json:"unit"`
	PricePerUnit AWSCurrencyCode `json:"pricePerUnit"`
}

AWSRateCode encodes data about the price of a product

func (*AWSRateCode) String

func (rc *AWSRateCode) String() string

type AccessKey

type AccessKey struct {
	ID     string `json:"id"`
	Secret string `json:"secret"`
}

AccessKey holds AWS credentials and fulfils the awsV2.CredentialsProvider interface

func (*AccessKey) CreateAWSConfig

func (ak *AccessKey) CreateAWSConfig(region string) (cfg aws.Config, err error)

CreateAWSConfig creates an AWS SDK V2 Config for the credentials that it contains for the provided region

func (*AccessKey) Equals

func (ak *AccessKey) Equals(config config.Config) bool

func (*AccessKey) MarshalJSON

func (ak *AccessKey) MarshalJSON() ([]byte, error)

MarshalJSON custom json marshalling functions, sets properties as tagged in struct and sets the authorizer type property

func (*AccessKey) Retrieve

func (ak *AccessKey) Retrieve(ctx context.Context) (aws.Credentials, error)

Retrieve returns a set of awsV2 credentials using the AccessKey's key and secret. This fulfils the awsV2.CredentialsProvider interface contract.

func (*AccessKey) Sanitize

func (ak *AccessKey) Sanitize() config.Config

func (*AccessKey) Validate

func (ak *AccessKey) Validate() error

type AssumeRole

type AssumeRole struct {
	Authorizer Authorizer `json:"authorizer"`
	RoleARN    string     `json:"roleARN"`
}

AssumeRole is a wrapper for another Authorizer which adds an assumed role to the configuration

func (*AssumeRole) CreateAWSConfig

func (ara *AssumeRole) CreateAWSConfig(region string) (aws.Config, error)

func (*AssumeRole) Equals

func (ara *AssumeRole) Equals(config config.Config) bool

func (*AssumeRole) MarshalJSON

func (ara *AssumeRole) MarshalJSON() ([]byte, error)

MarshalJSON custom json marshalling functions, sets properties as tagged in struct and sets the authorizer type property

func (*AssumeRole) Sanitize

func (ara *AssumeRole) Sanitize() config.Config

func (*AssumeRole) UnmarshalJSON

func (ara *AssumeRole) UnmarshalJSON(b []byte) error

UnmarshalJSON is required for AssumeRole because it needs to unmarshal an Authorizer interface

func (*AssumeRole) Validate

func (ara *AssumeRole) Validate() error

type AthenaConfiguration

type AthenaConfiguration struct {
	Bucket     string     `json:"bucket"`
	Region     string     `json:"region"`
	Database   string     `json:"database"`
	Catalog    string     `json:"catalog""`
	Table      string     `json:"table"`
	Workgroup  string     `json:"workgroup"`
	Account    string     `json:"account"`
	Authorizer Authorizer `json:"authorizer"`
}

AthenaConfiguration

func (*AthenaConfiguration) Equals

func (ac *AthenaConfiguration) Equals(config config.Config) bool

func (*AthenaConfiguration) Key

func (ac *AthenaConfiguration) Key() string

func (*AthenaConfiguration) Sanitize

func (ac *AthenaConfiguration) Sanitize() config.Config

func (*AthenaConfiguration) UnmarshalJSON

func (ac *AthenaConfiguration) UnmarshalJSON(b []byte) error

func (*AthenaConfiguration) Validate

func (ac *AthenaConfiguration) Validate() error

type AthenaIntegration

type AthenaIntegration struct {
	AthenaQuerier
}

func (*AthenaIntegration) ConvertLabelToAWSTag

func (ai *AthenaIntegration) ConvertLabelToAWSTag(label string) string

func (*AthenaIntegration) GetAmortizedCostCase

func (ai *AthenaIntegration) GetAmortizedCostCase(allColumns map[string]bool) string

func (*AthenaIntegration) GetAmortizedCostColumn

func (ai *AthenaIntegration) GetAmortizedCostColumn(allColumns map[string]bool) string

func (*AthenaIntegration) GetAmortizedNetCostCase

func (ai *AthenaIntegration) GetAmortizedNetCostCase(allColumns map[string]bool) string

func (*AthenaIntegration) GetAmortizedNetCostColumn

func (ai *AthenaIntegration) GetAmortizedNetCostColumn(allColumns map[string]bool) string

func (*AthenaIntegration) GetCloudCost

func (ai *AthenaIntegration) GetCloudCost(start, end time.Time) (*kubecost.CloudCostSetRange, error)

Query Athena for CUR data and build a new CloudCostSetRange containing the info

func (*AthenaIntegration) GetConnectionStatus

func (ai *AthenaIntegration) GetConnectionStatus() string

func (*AthenaIntegration) GetConnectionStatusFromResult

func (ai *AthenaIntegration) GetConnectionStatusFromResult(result cloud.EmptyChecker, currentStatus cloud.ConnectionStatus) cloud.ConnectionStatus

func (*AthenaIntegration) GetIsKubernetesColumn

func (ai *AthenaIntegration) GetIsKubernetesColumn(allColumns map[string]bool) string

GetIsKubernetesColumn builds a column that determines if a row represents kubernetes spend

func (*AthenaIntegration) GetListCostColumn

func (ai *AthenaIntegration) GetListCostColumn() string

func (*AthenaIntegration) GetNetCostColumn

func (ai *AthenaIntegration) GetNetCostColumn(allColumns map[string]bool) string

func (*AthenaIntegration) GetPartitionWhere

func (ai *AthenaIntegration) GetPartitionWhere(start, end time.Time) string

func (*AthenaIntegration) RemoveColumnAliases

func (ai *AthenaIntegration) RemoveColumnAliases(columns []string)

func (*AthenaIntegration) RowToCloudCost

func (ai *AthenaIntegration) RowToCloudCost(row types.Row, aqi AthenaQueryIndexes, ccsr *kubecost.CloudCostSetRange) error

type AthenaQuerier

type AthenaQuerier struct {
	AthenaConfiguration
	ConnectionStatus cloud.ConnectionStatus
}

func (*AthenaQuerier) Equals

func (aq *AthenaQuerier) Equals(config cloudconfig.Config) bool

func (*AthenaQuerier) GetAthenaClient

func (aq *AthenaQuerier) GetAthenaClient() (*athena.Client, error)

func (*AthenaQuerier) GetColumns

func (aq *AthenaQuerier) GetColumns() (map[string]bool, error)

GetColumns returns a list of the names of all columns in the configured Athena table

func (*AthenaQuerier) GetStatus

func (aq *AthenaQuerier) GetStatus() cloud.ConnectionStatus

func (*AthenaQuerier) Query

func (aq *AthenaQuerier) Query(ctx context.Context, query string, fn func(*athena.GetQueryResultsOutput) bool) error

type AthenaQueryIndexes

type AthenaQueryIndexes struct {
	Query                  string
	ColumnIndexes          map[string]int
	TagColumns             []string
	ListCostColumn         string
	NetCostColumn          string
	AmortizedNetCostColumn string
	AmortizedCostColumn    string
	IsK8sColumn            string
}

AthenaQueryIndexes is a struct for holding the context of a query

type Authorizer

type Authorizer interface {
	config.Authorizer
	CreateAWSConfig(string) (aws.Config, error)
}

Authorizer implementations provide aws.Config for AWS SDK calls

func SelectAuthorizerByType

func SelectAuthorizerByType(typeStr string) (Authorizer, error)

SelectAuthorizerByType is an implementation of AuthorizerSelectorFn and acts as a register for Authorizer types

type AwsAthenaInfo

type AwsAthenaInfo struct {
	AthenaBucketName string `json:"athenaBucketName"`
	AthenaRegion     string `json:"athenaRegion"`
	AthenaDatabase   string `json:"athenaDatabase"`
	AthenaCatalog    string `json:"athenaCatalog"`
	AthenaTable      string `json:"athenaTable"`
	AthenaWorkgroup  string `json:"athenaWorkgroup"`
	ServiceKeyName   string `json:"serviceKeyName"`
	ServiceKeySecret string `json:"serviceKeySecret"`
	AccountID        string `json:"projectID"`
	MasterPayerARN   string `json:"masterPayerARN"`
}

AwsAthenaInfo contains configuration for CUR integration Deprecated: v1.104 Use AthenaConfiguration instead

func (*AwsAthenaInfo) CreateConfig

func (aai *AwsAthenaInfo) CreateConfig() (awsSDK.Config, error)

CreateConfig creates an AWS SDK V2 Config for the credentials that it contains

func (*AwsAthenaInfo) IsEmpty

func (aai *AwsAthenaInfo) IsEmpty() bool

IsEmpty returns true if all fields in config are empty, false if not.

type AwsSpotFeedInfo

type AwsSpotFeedInfo struct {
	BucketName       string `json:"bucketName"`
	Prefix           string `json:"prefix"`
	Region           string `json:"region"`
	AccountID        string `json:"projectID"`
	ServiceKeyName   string `json:"serviceKeyName"`
	ServiceKeySecret string `json:"serviceKeySecret"`
	SpotLabel        string `json:"spotLabel"`
	SpotLabelValue   string `json:"spotLabelValue"`
}

AwsSpotFeedInfo contains configuration for spot feed integration

type RIData

type RIData struct {
	ResourceID     string
	EffectiveCost  float64
	ReservationARN string
	MostRecentDate string
}

type S3Configuration

type S3Configuration struct {
	Bucket     string     `json:"bucket"`
	Region     string     `json:"region"`
	Account    string     `json:"account"`
	Authorizer Authorizer `json:"authorizer"`
}

func (*S3Configuration) CreateAWSConfig

func (s3c *S3Configuration) CreateAWSConfig() (aws.Config, error)

func (*S3Configuration) Equals

func (s3c *S3Configuration) Equals(config config.Config) bool

func (*S3Configuration) Key

func (s3c *S3Configuration) Key() string

func (*S3Configuration) Sanitize

func (s3c *S3Configuration) Sanitize() config.Config

func (*S3Configuration) UnmarshalJSON

func (s3c *S3Configuration) UnmarshalJSON(b []byte) error

func (*S3Configuration) Validate

func (s3c *S3Configuration) Validate() error

type S3Connection

type S3Connection struct {
	S3Configuration
	ConnectionStatus cloud.ConnectionStatus
}

func (*S3Connection) Equals

func (s3c *S3Connection) Equals(config config.Config) bool

func (*S3Connection) GetS3Client

func (s3c *S3Connection) GetS3Client() (*s3.Client, error)

func (*S3Connection) GetStatus

func (s3c *S3Connection) GetStatus() cloud.ConnectionStatus

func (*S3Connection) ListObjects

func (s3c *S3Connection) ListObjects(cli *s3.Client) (*s3.ListObjectsOutput, error)

type S3SelectIntegration

type S3SelectIntegration struct {
	S3SelectQuerier
}

func (*S3SelectIntegration) GetCloudCost

func (s3si *S3SelectIntegration) GetCloudCost(
	start,
	end time.Time,
) (*kubecost.CloudCostSetRange, error)

func (*S3SelectIntegration) GetHeaders

func (s3si *S3SelectIntegration) GetHeaders(queryKeys []string, client *s3.Client) ([]string, error)

type S3SelectQuerier

type S3SelectQuerier struct {
	S3Connection
	// contains filtered or unexported fields
}

func (*S3SelectQuerier) Equals

func (s3sq *S3SelectQuerier) Equals(config config.Config) bool

func (*S3SelectQuerier) GetQueryKeys

func (s3sq *S3SelectQuerier) GetQueryKeys(start, end time.Time, client *s3.Client) ([]string, error)

GetQueryKeys returns a list of s3 object names, where the there are 1 object for each month within the range between start and end

func (*S3SelectQuerier) Query

func (s3sq *S3SelectQuerier) Query(query string, queryKeys []string, cli *s3.Client, fn func(*csv.Reader) error) error

type SavingsPlanData

type SavingsPlanData struct {
	ResourceID     string
	EffectiveCost  float64
	SavingsPlanARN string
	MostRecentDate string
}

type ServiceAccount

type ServiceAccount struct{}

ServiceAccount uses pod annotations along with a service account to authenticate integrations

func (*ServiceAccount) CreateAWSConfig

func (sa *ServiceAccount) CreateAWSConfig(region string) (aws.Config, error)

func (*ServiceAccount) Equals

func (sa *ServiceAccount) Equals(config config.Config) bool

func (*ServiceAccount) MarshalJSON

func (sa *ServiceAccount) MarshalJSON() ([]byte, error)

MarshalJSON custom json marshalling functions, sets properties as tagged in struct and sets the authorizer type property

func (*ServiceAccount) Sanitize

func (sa *ServiceAccount) Sanitize() config.Config

func (*ServiceAccount) Validate

func (sa *ServiceAccount) Validate() error

Check has nothing to check at this level, connection will fail if Pod Annotation and Service Account are not configured correctly

Jump to

Keyboard shortcuts

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