Documentation ¶
Overview ¶
Package aws enables cost estimation of AWS resources and ingestion of pricing data from AWS.
It should not be used directly by consumers, instead, please use the costestimation package. This package contains implementations of Ingester and TerraformProviderInitializer that are used internally by other packages.
Index ¶
Constants ¶
const ( // RegistryName is the fully qualified name under which this provider is stored in the registry. RegistryName = "registry.terraform.io/hashicorp/aws" // DefaultRegion is the region used by default when none is defined on the provider DefaultRegion = "us-east-1" )
const ProviderName = "aws"
ProviderName uniquely identifies this provider implementation.
Variables ¶
var TerraformProviderInitializer = terraform.ProviderInitializer{ MatchNames: []string{ProviderName, RegistryName}, Provider: func(values map[string]interface{}) (terraform.Provider, error) { r, ok := values["region"] if !ok { r = DefaultRegion } regCode := region.Code(r.(string)) return awstf.NewProvider(ProviderName, regCode) }, }
TerraformProviderInitializer is a terraform.ProviderInitializer that initializes the default AWS provider.
Functions ¶
func DefaultFilter ¶
func DefaultFilter(_ *price.WithProduct) bool
DefaultFilter ingests all the records without filtering.
func GetSupportedServices ¶
func GetSupportedServices() []string
GetSupportedServices returns all the AWS service names that Terracost supports.
func IsServiceSupported ¶
IsServiceSupported returns true if the AWS service is valid and supported by Terracost (e.g. for ingestion.)
func MinimalFilter ¶
func MinimalFilter(pp *price.WithProduct) bool
MinimalFilter only ingests the supported records, skipping those that would never be used.
Types ¶
type HTTPClient ¶
HTTPClient is an interface of a client that is able to Do HTTP requests
type Ingester ¶
type Ingester struct {
// contains filtered or unexported fields
}
Ingester is used to load the pricing data from AWS offer files into a database. It is one-use only and should be discarded after the ingestion is complete.
func NewIngester ¶
NewIngester returns a new Ingester using the given options. Only the repositories must be provided using the WithRepositories function, other configuration options will use their default values. The service must be a valid AWS service name that is supported by Terracost, otherwise this function will return an error.
type IngestionFilter ¶
type IngestionFilter func(pp *price.WithProduct) bool
IngestionFilter allows control over what pricing data is ingested. Given a price.WithProduct the function returns true if the record should be ingested, false if it should be skipped.
type Option ¶
type Option func(ing *Ingester)
Option is used to configure the Ingester.
func WithBufferSize ¶
WithBufferSize sets the I/O buffer size for the downloaded file, 100 MiB by default.
func WithHTTPClient ¶
func WithHTTPClient(client HTTPClient) Option
WithHTTPClient sets a custom HTTP client to be used for offer file downloads.
func WithIngestionFilter ¶
func WithIngestionFilter(filter IngestionFilter) Option
WithIngestionFilter sets a custom IngestionFilter to control which pricing data records should be ingested.
func WithPricingURL ¶
WithPricingURL sets the base AWS pricing URL, "https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws" by default.