-
Notifications
You must be signed in to change notification settings - Fork 523
/
api_gateway_stage.go
64 lines (54 loc) 路 1.55 KB
/
api_gateway_stage.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package aws
import (
"github.com/infracost/infracost/internal/resources"
"github.com/infracost/infracost/internal/schema"
"fmt"
"github.com/shopspring/decimal"
)
type APIGatewayStage struct {
Address string
Region string
CacheClusterSize float64
CacheEnabled bool
}
func (r *APIGatewayStage) CoreType() string {
return "APIGatewayStage"
}
func (r *APIGatewayStage) UsageSchema() []*schema.UsageItem {
return []*schema.UsageItem{}
}
func (r *APIGatewayStage) PopulateUsage(u *schema.UsageData) {
resources.PopulateArgsWithUsage(r, u)
}
func (r *APIGatewayStage) BuildResource() *schema.Resource {
if !r.CacheEnabled {
return &schema.Resource{
Name: r.Address,
NoPrice: true,
IsSkipped: true,
UsageSchema: r.UsageSchema(),
}
}
region := r.Region
return &schema.Resource{
Name: r.Address,
CostComponents: []*schema.CostComponent{
{
Name: fmt.Sprintf("Cache memory (%s GB)", decimal.NewFromFloat(r.CacheClusterSize)),
Unit: "hours",
UnitMultiplier: decimal.NewFromInt(1),
HourlyQuantity: decimalPtr(decimal.NewFromInt(1)),
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("aws"),
Region: strPtr(region),
Service: strPtr("AmazonApiGateway"),
ProductFamily: strPtr("Amazon API Gateway Cache"),
AttributeFilters: []*schema.AttributeFilter{
{Key: "cacheMemorySizeGb", ValueRegex: strPtr(fmt.Sprintf("/%s/", decimal.NewFromFloat(r.CacheClusterSize)))},
},
},
},
},
UsageSchema: r.UsageSchema(),
}
}