GithubHelp home page GithubHelp logo

oded-b / aws-pricing-typer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jonhadfield/aws-pricing-typer

0.0 1.0 0.0 36 KB

library to translate AWS pricing API output to concrete types

License: GNU General Public License v3.0

Go 95.57% Makefile 4.43%

aws-pricing-typer's Introduction

aws pricing typer

Build Status Coverage Status Go Report Card

about

Using the Go SDK to query the AWS Pricing API for Products (metadata plus pricing detail) returns a slice of type: aws.JSONValue that's defined as: map[string]interface{}. This library takes the output and returns the documents in structs with their concrete types.

note

  • AWS API credentials are required in order to query the pricing API
  • "The Price List Service API provides pricing details for your information only. If there is a discrepancy between the offer file and a service pricing page, AWS charges the prices that are listed on the service pricing page. For more information about AWS service pricing, see Cloud Services Pricing."

usage

package main

import (
	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/session"
	"github.com/aws/aws-sdk-go/service/pricing"
	"github.com/jonhadfield/aws-pricing-typer"
)

func main() {
	pricingAPIRegion := "us-east-1"

	// get pricing client
	sess, _ := session.NewSession(&aws.Config{Region: &pricingAPIRegion})
	svc := pricing.New(sess)

	// create request criteria
	ec2ServiceCode := "AmazonEC2"
	formatVer := "aws_v1"
	typeTerm := pricing.FilterTypeTermMatch

	// create filters
	locationKey := "location"
	locationValue := "EU (Ireland)"
	instanceTypeKey := "instanceType"
	instanceTypeValue := "m4.large"
	var priceFilters []*pricing.Filter
	priceFilters = append(priceFilters, &pricing.Filter{
		Type:  &typeTerm,
		Field: &locationKey,
		Value: &locationValue,
	})
	priceFilters = append(priceFilters, &pricing.Filter{
		Type:  &typeTerm,
		Field: &instanceTypeKey,
		Value: &instanceTypeValue,
	})

	// make request
	productsOutput, _ := svc.GetProducts(&pricing.GetProductsInput{
		ServiceCode:   &ec2ServiceCode,
		FormatVersion: &formatVer,
		Filters:       priceFilters,
	})

	// transform
	priceData, _ := awsPricingTyper.GetTypedPricingData(*productsOutput)
}

aws-pricing-typer's People

Contributors

jonhadfield avatar oded-b avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.