-
Notifications
You must be signed in to change notification settings - Fork 523
/
s3_storage_class_helpers.go
155 lines (144 loc) 路 5.11 KB
/
s3_storage_class_helpers.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
package aws
import (
"fmt"
"github.com/shopspring/decimal"
"github.com/infracost/infracost/internal/schema"
)
func s3StorageCostComponent(name string, service string, region string, usageType string, storageGB *float64) *schema.CostComponent {
return &schema.CostComponent{
Name: name,
Unit: "GB",
UnitMultiplier: decimal.NewFromInt(1),
MonthlyQuantity: floatPtrToDecimalPtr(storageGB),
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("aws"),
Region: strPtr(region),
Service: strPtr(service),
AttributeFilters: []*schema.AttributeFilter{
{Key: "usagetype", ValueRegex: strPtr(fmt.Sprintf("/%s/i", usageType))},
},
},
PriceFilter: &schema.PriceFilter{
StartUsageAmount: strPtr("0"),
},
UsageBased: true,
}
}
func s3StorageVolumeTypeCostComponent(name string, service string, region string, usageType string, volumeType string, storageGB *float64) *schema.CostComponent {
return &schema.CostComponent{
Name: name,
Unit: "GB",
UnitMultiplier: decimal.NewFromInt(1),
MonthlyQuantity: floatPtrToDecimalPtr(storageGB),
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("aws"),
Region: strPtr(region),
Service: strPtr(service),
AttributeFilters: []*schema.AttributeFilter{
{Key: "usagetype", ValueRegex: strPtr(fmt.Sprintf("/%s/i", usageType))},
{Key: "volumeType", ValueRegex: strPtr(fmt.Sprintf("/%s/i", volumeType))},
},
},
PriceFilter: &schema.PriceFilter{
StartUsageAmount: strPtr("0"),
},
UsageBased: true,
}
}
func s3ApiCostComponent(name string, service string, region string, usageType string, requests *int64) *schema.CostComponent {
return s3ApiOperationCostComponent(name, service, region, usageType, "", requests)
}
func s3ApiOperationCostComponent(name string, service string, region string, usageType string, operation string, requests *int64) *schema.CostComponent {
return &schema.CostComponent{
Name: name,
Unit: "1k requests",
UnitMultiplier: decimal.NewFromInt(1000),
MonthlyQuantity: intPtrToDecimalPtr(requests),
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("aws"),
Region: strPtr(region),
Service: strPtr(service),
AttributeFilters: []*schema.AttributeFilter{
{Key: "usagetype", ValueRegex: strPtr(fmt.Sprintf("/%s/i", usageType))},
{Key: "operation", ValueRegex: strPtr(fmt.Sprintf("/%s/i", operation))},
},
},
UsageBased: true,
}
}
func s3DataCostComponent(name string, service string, region string, usageType string, dataGB *float64) *schema.CostComponent {
return &schema.CostComponent{
Name: name,
Unit: "GB",
UnitMultiplier: decimal.NewFromInt(1),
MonthlyQuantity: floatPtrToDecimalPtr(dataGB),
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("aws"),
Region: strPtr(region),
Service: strPtr(service),
AttributeFilters: []*schema.AttributeFilter{
{Key: "usagetype", ValueRegex: strPtr(fmt.Sprintf("/%s/i", usageType))},
},
},
PriceFilter: &schema.PriceFilter{
StartUsageAmount: strPtr("0"),
},
UsageBased: true,
}
}
func s3DataGroupCostComponent(name string, service string, region string, usageType string, group string, dataGB *float64) *schema.CostComponent {
return &schema.CostComponent{
Name: name,
Unit: "GB",
UnitMultiplier: decimal.NewFromInt(1),
MonthlyQuantity: floatPtrToDecimalPtr(dataGB),
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("aws"),
Region: strPtr(region),
Service: strPtr(service),
AttributeFilters: []*schema.AttributeFilter{
{Key: "usagetype", ValueRegex: strPtr(fmt.Sprintf("/%s/i", usageType))},
{Key: "group", ValueRegex: strPtr(fmt.Sprintf("/%s/i", group))},
},
},
PriceFilter: &schema.PriceFilter{
StartUsageAmount: strPtr("0"),
},
UsageBased: true,
}
}
func s3LifecycleTransitionsCostComponent(region string, usageType string, operation string, requests *int64) *schema.CostComponent {
return &schema.CostComponent{
Name: "Lifecycle transition",
Unit: "1k requests",
UnitMultiplier: decimal.NewFromInt(1000),
MonthlyQuantity: intPtrToDecimalPtr(requests),
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("aws"),
Region: strPtr(region),
Service: strPtr("AmazonS3"),
AttributeFilters: []*schema.AttributeFilter{
{Key: "usagetype", ValueRegex: strPtr(fmt.Sprintf("/%s$/i", usageType))},
{Key: "operation", ValueRegex: strPtr(fmt.Sprintf("/^%s$/i", operation))},
},
},
UsageBased: true,
}
}
func s3MonitoringCostComponent(region string, objects *int64) *schema.CostComponent {
return &schema.CostComponent{
Name: "Monitoring and automation",
Unit: "1k objects",
UnitMultiplier: decimal.NewFromInt(1000),
MonthlyQuantity: intPtrToDecimalPtr(objects),
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("aws"),
Region: strPtr(region),
Service: strPtr("AmazonS3"),
AttributeFilters: []*schema.AttributeFilter{
{Key: "usagetype", ValueRegex: strPtr("/Monitoring-Automation-INT/")},
},
},
UsageBased: true,
}
}