-
Notifications
You must be signed in to change notification settings - Fork 523
/
cloudwatch_event_bus.go
149 lines (141 loc) 路 5.17 KB
/
cloudwatch_event_bus.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
package aws
import (
"github.com/infracost/infracost/internal/resources"
"github.com/infracost/infracost/internal/schema"
"github.com/shopspring/decimal"
)
type CloudwatchEventBus struct {
Address string
Region string
MonthlySchemaDiscoveryEvents *int64 `infracost_usage:"monthly_schema_discovery_events"`
MonthlyCustomEvents *int64 `infracost_usage:"monthly_custom_events"`
MonthlyThirdPartyEvents *int64 `infracost_usage:"monthly_third_party_events"`
MonthlyArchiveProcessingGB *float64 `infracost_usage:"monthly_archive_processing_gb"`
ArchiveStorageGB *float64 `infracost_usage:"archive_storage_gb"`
}
func (r *CloudwatchEventBus) CoreType() string {
return "CloudwatchEventBus"
}
func (r *CloudwatchEventBus) UsageSchema() []*schema.UsageItem {
return []*schema.UsageItem{
{Key: "monthly_schema_discovery_events", ValueType: schema.Int64, DefaultValue: 0},
{Key: "monthly_custom_events", ValueType: schema.Int64, DefaultValue: 0},
{Key: "monthly_third_party_events", ValueType: schema.Int64, DefaultValue: 0},
{Key: "monthly_archive_processing_gb", ValueType: schema.Float64, DefaultValue: 0},
{Key: "archive_storage_gb", ValueType: schema.Float64, DefaultValue: 0},
}
}
func (r *CloudwatchEventBus) PopulateUsage(u *schema.UsageData) {
resources.PopulateArgsWithUsage(r, u)
}
func (r *CloudwatchEventBus) BuildResource() *schema.Resource {
var monthlyCustomEvents *decimal.Decimal
if r.MonthlyCustomEvents != nil {
monthlyCustomEvents = decimalPtr(decimal.NewFromInt(*r.MonthlyCustomEvents))
}
var monthlyPartnerEvents *decimal.Decimal
if r.MonthlyThirdPartyEvents != nil {
monthlyPartnerEvents = decimalPtr(decimal.NewFromInt(*r.MonthlyThirdPartyEvents))
}
var monthlyArchiveProcessing *decimal.Decimal
if r.MonthlyArchiveProcessingGB != nil {
monthlyArchiveProcessing = decimalPtr(decimal.NewFromFloat(*r.MonthlyArchiveProcessingGB))
}
var monthlyArchivedEvents *decimal.Decimal
if r.ArchiveStorageGB != nil {
monthlyArchivedEvents = decimalPtr(decimal.NewFromFloat(*r.ArchiveStorageGB))
}
var monthlyIngestedEvents *decimal.Decimal
if r.MonthlySchemaDiscoveryEvents != nil {
monthlyIngestedEvents = decimalPtr(decimal.NewFromInt(*r.MonthlySchemaDiscoveryEvents))
}
return &schema.Resource{
Name: r.Address,
CostComponents: []*schema.CostComponent{
{
Name: "Custom events published",
Unit: "1M events",
UnitMultiplier: decimal.NewFromInt(1000000),
MonthlyQuantity: monthlyCustomEvents,
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("aws"),
Region: strPtr(r.Region),
Service: strPtr("AWSEvents"),
ProductFamily: strPtr("EventBridge"),
AttributeFilters: []*schema.AttributeFilter{
{Key: "eventType", Value: strPtr("Custom Event")},
{Key: "usagetype", ValueRegex: strPtr("/Event-64K-Chunks/")},
},
},
UsageBased: true,
},
{
Name: "Third-party events published",
Unit: "1M events",
UnitMultiplier: decimal.NewFromInt(1000000),
MonthlyQuantity: monthlyPartnerEvents,
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("aws"),
Region: strPtr(r.Region),
Service: strPtr("AWSEvents"),
ProductFamily: strPtr("EventBridge"),
AttributeFilters: []*schema.AttributeFilter{
{Key: "eventType", Value: strPtr("Partner Event")},
{Key: "usagetype", ValueRegex: strPtr("/Event-64K-Chunks/")},
},
},
UsageBased: true,
},
{
Name: "Archive processing",
Unit: "GB",
UnitMultiplier: decimal.NewFromInt(1),
MonthlyQuantity: monthlyArchiveProcessing,
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("aws"),
Region: strPtr(r.Region),
Service: strPtr("AWSEvents"),
ProductFamily: strPtr("CloudWatch Events"),
AttributeFilters: []*schema.AttributeFilter{
{Key: "usagetype", ValueRegex: strPtr("/ArchivedEvents-Bytes/")},
},
},
UsageBased: true,
},
{
Name: "Archive storage",
Unit: "GB",
UnitMultiplier: decimal.NewFromInt(1),
MonthlyQuantity: monthlyArchivedEvents,
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("aws"),
Region: strPtr(r.Region),
Service: strPtr("AWSEvents"),
ProductFamily: strPtr("CloudWatch Events"),
AttributeFilters: []*schema.AttributeFilter{
{Key: "usagetype", ValueRegex: strPtr("/TimedStorage-ByteHrs/")},
},
},
UsageBased: true,
},
{
Name: "Schema discovery",
Unit: "1M events",
UnitMultiplier: decimal.NewFromInt(1000000),
MonthlyQuantity: monthlyIngestedEvents,
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("aws"),
Region: strPtr(r.Region),
Service: strPtr("AWSEvents"),
ProductFamily: strPtr("EventBridge"),
AttributeFilters: []*schema.AttributeFilter{
{Key: "eventType", Value: strPtr("Discovery Event")},
{Key: "usagetype", ValueRegex: strPtr("/Event-8K-Chunks/")},
},
},
UsageBased: true,
},
},
UsageSchema: r.UsageSchema(),
}
}