Skip to content

made pricing api calls region specific + initDB #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vg-leanix
Copy link
Collaborator

No description provided.

@vg-leanix
Copy link
Collaborator Author

@mohamedlajmileanix please review changes and merge after finishing

@@ -19,6 +19,26 @@
pricing_dict = {}
region_table = {}
container_instance_ec2_mapping = {}
aws_regions = {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need this to map region to region name to use it as param for Pricing API calls

"""
svc_code = 'AmazonEC2'
region_name = str(aws_regions[region])
client = boto3.client('pricing', region_name="us-east-1")
Copy link
Collaborator Author

@vg-leanix vg-leanix Jul 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to hard code the pricing api endpoint but make the region specific in the location param in the query

@@ -93,7 +122,9 @@ def ec2_pricing(region, instance_type, tenancy, ostype):
ret_dict['pricePerUnit'] = mydict_terms['priceDimensions'][list(
mydict_terms['priceDimensions'].keys())[0]]['pricePerUnit']
ret_list.append(ret_dict)

else:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added improved logging for cases where we do not get pricing info - can still happen

table = db_res.Table("initDB")

#db_client = boto3.client('dynamodb')
initialised = table.scan(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls check if this query works properly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant