-
Notifications
You must be signed in to change notification settings - Fork 523
/
eks_fargate_profile.go
79 lines (69 loc) 路 2.18 KB
/
eks_fargate_profile.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package aws
import (
"github.com/infracost/infracost/internal/resources"
"github.com/infracost/infracost/internal/schema"
"github.com/shopspring/decimal"
)
type EKSFargateProfile struct {
Address string
Region string
}
func (r *EKSFargateProfile) CoreType() string {
return "EKSFargateProfile"
}
func (r *EKSFargateProfile) UsageSchema() []*schema.UsageItem {
return []*schema.UsageItem{}
}
func (r *EKSFargateProfile) PopulateUsage(u *schema.UsageData) {
resources.PopulateArgsWithUsage(r, u)
}
func (r *EKSFargateProfile) BuildResource() *schema.Resource {
costComponents := make([]*schema.CostComponent, 0)
costComponents = append(costComponents, r.memoryCostComponent())
costComponents = append(costComponents, r.vcpuCostComponent())
return &schema.Resource{
Name: r.Address,
CostComponents: costComponents,
UsageSchema: r.UsageSchema(),
}
}
func (r *EKSFargateProfile) memoryCostComponent() *schema.CostComponent {
return &schema.CostComponent{
Name: "Per GB per hour",
Unit: "GB",
UnitMultiplier: schema.HourToMonthUnitMultiplier,
HourlyQuantity: decimalPtr(decimal.NewFromInt(1)),
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("aws"),
Region: strPtr(r.Region),
Service: strPtr("AmazonEKS"),
ProductFamily: strPtr("Compute"),
AttributeFilters: []*schema.AttributeFilter{
{Key: "usagetype", ValueRegex: strPtr("/Fargate-GB-Hours/")},
},
},
PriceFilter: &schema.PriceFilter{
PurchaseOption: strPtr("on_demand"),
},
}
}
func (r *EKSFargateProfile) vcpuCostComponent() *schema.CostComponent {
return &schema.CostComponent{
Name: "Per vCPU per hour",
Unit: "CPU",
UnitMultiplier: schema.HourToMonthUnitMultiplier,
HourlyQuantity: decimalPtr(decimal.NewFromInt(1)),
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("aws"),
Region: strPtr(r.Region),
Service: strPtr("AmazonEKS"),
ProductFamily: strPtr("Compute"),
AttributeFilters: []*schema.AttributeFilter{
{Key: "usagetype", ValueRegex: strPtr("/Fargate-vCPU-Hours:perCPU/")},
},
},
PriceFilter: &schema.PriceFilter{
PurchaseOption: strPtr("on_demand"),
},
}
}