forked from infracost/infracost
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnat_gateway.go
59 lines (53 loc) · 1.59 KB
/
nat_gateway.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
package aws
import (
"github.com/infracost/infracost/internal/schema"
"github.com/shopspring/decimal"
)
func GetNATGatewayRegistryItem() *schema.RegistryItem {
return &schema.RegistryItem{
Name: "aws_nat_gateway",
RFunc: NewNATGateway,
}
}
func NewNATGateway(d *schema.ResourceData, u *schema.UsageData) *schema.Resource {
region := d.Get("region").String()
var gbDataProcessed *decimal.Decimal
if u != nil && u.Get("monthly_data_processed_gb").Exists() {
gbDataProcessed = decimalPtr(decimal.NewFromFloat(u.Get("monthly_data_processed_gb").Float()))
}
return &schema.Resource{
Name: d.Address,
CostComponents: []*schema.CostComponent{
{
Name: "NAT gateway",
Unit: "hours",
UnitMultiplier: 1,
HourlyQuantity: decimalPtr(decimal.NewFromInt(1)),
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("aws"),
Region: strPtr(region),
Service: strPtr("AmazonEC2"),
ProductFamily: strPtr("NAT Gateway"),
AttributeFilters: []*schema.AttributeFilter{
{Key: "usagetype", ValueRegex: strPtr("/NatGateway-Hours/")},
},
},
},
{
Name: "Data processed",
Unit: "GB",
UnitMultiplier: 1,
MonthlyQuantity: gbDataProcessed,
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("aws"),
Region: strPtr(region),
Service: strPtr("AmazonEC2"),
ProductFamily: strPtr("NAT Gateway"),
AttributeFilters: []*schema.AttributeFilter{
{Key: "usagetype", ValueRegex: strPtr("/NatGateway-Bytes/")},
},
},
},
},
}
}