Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Diego Lima
/
aws-price-parser
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 187c8958
authored
7 years ago
by
diegolima
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adicionar parser EC2 Aws
0 parents
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
aws.py
aws.py
0 → 100644
View file @
187c895
import
urllib.request
import
json
from
pprint
import
pprint
TERM_ONDEMAND
=
'JRTCKXETXF'
#TODO: Find out where to get this from
HOURLY_DIMENSION
=
'6YS6EN2CT7'
#TODO: Find out where to get this from
with
urllib
.
request
.
urlopen
(
"https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonEC2/current/index.json"
)
as
url
:
DATA
=
json
.
load
(
url
)
for
product
in
DATA
[
"products"
]:
if
DATA
[
'products'
][
product
][
'productFamily'
]
==
'Compute Instance'
:
sku
=
DATA
[
'products'
][
product
][
'sku'
]
key
=
DATA
[
'terms'
][
'OnDemand'
]
.
get
(
sku
)
if
key
:
cost
=
key
[
sku
+
'.'
+
TERM_ONDEMAND
][
'priceDimensions'
][
sku
+
'.'
+
TERM_ONDEMAND
+
'.'
+
HOURLY_DIMENSION
][
'pricePerUnit'
][
'USD'
]
if
cost
!=
'0.0000000000'
:
print
(
'aws'
,
end
=
','
)
print
(
DATA
[
'products'
][
product
][
'attributes'
][
'instanceType'
],
end
=
','
)
print
(
DATA
[
'products'
][
product
][
'attributes'
][
'vcpu'
],
end
=
','
)
print
(
DATA
[
'products'
][
product
][
'attributes'
][
'memory'
],
end
=
','
)
print
(
cost
,
end
=
','
)
print
(
DATA
[
'products'
][
product
][
'attributes'
][
'location'
],
end
=
','
)
print
(
DATA
[
'products'
][
product
][
'attributes'
][
'operatingSystem'
])
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment