-
Notifications
You must be signed in to change notification settings - Fork 9
/
cost.go
77 lines (67 loc) · 1.88 KB
/
cost.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
package helpers
import (
"fmt"
"log"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/pricing"
)
// type rawAmazonCloudWatch struct {
// FormatVersion string
// Disclaimer string
// OfferCode string
// Version string
// PublicationDate string
// Products map[string]string
// Terms map[string]map[string]map[string]rawAmazonCloudWatchTerm
// }
// type rawAmazonCloudWatchTerm struct {
// OfferTermCode string
// Sku string
// EffectiveDate string
// PriceDimensions map[string]string
// TermAttributes map[string]string
// }
// GetAwsServiceCost use to get a product code for getting price
//
func GetAwsServiceCost() *pricing.GetProductsOutput {
log.Println("Cost")
region := "us-east-1"
awsSession, _ := InitAwsSession(region)
svc := pricing.New(awsSession)
pinput := &pricing.GetProductsInput{
// Filters: []*pricing.Filter{
// {
// Field: aws.String("location"),
// Type: aws.String("TERM_MATCH"),
// Value: aws.String("EU (Ireland)"),
// },
// },
FormatVersion: aws.String("aws_v1"),
ServiceCode: aws.String("AmazonCloudwatch"),
// ServiceCode: aws.String("AmazonEc2"),
MaxResults: aws.Int64(1),
}
result, _ := svc.GetProducts(pinput)
// fmt.Println(result.PriceList[0]["serviceCode"])
// fmt.Println(result.PriceList[0]["terms"])
for _, r := range result.PriceList {
ts := make(map[string]map[string]map[string]string)
fmt.Println(ts, r)
}
// fmt.Println("pricelist")
// fmt.Println(r.PriceList)
// input := &pricing.DescribeServicesInput{
// FormatVersion: aws.String("aws_v1"),
// MaxResults: aws.Int64(1),
// ServiceCode: aws.String("AmazonCloudWatch"),
// }
// result, err := svc.DescribeServices(input)
// if err != nil {
// log.Println(err)
// return true
// }
// for _, s := range result.Services {
// fmt.Println(s)
// }
return result
}