Skip to content

Commit

Permalink
infracost triggers fixes when there is no token
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelzag committed Aug 14, 2023
1 parent 6208c95 commit 1c13908
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
11 changes: 7 additions & 4 deletions web/scripts/aws_caching_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,13 @@ def main(aws_access_key_id, aws_secret_access_key):
machines_for_zone_dict_clean = {}
for region in machines_for_zone_dict:
for machine in machines_for_zone_dict[region]:
postgres_object = Postgresql(postgres_dbname=POSTGRES_DBNAME, postgres_host=POSTGRES_HOST,
postgres_user=POSTGRES_USER, postgres_password=POSTGRES_PASSWORD,
provider_name=AWS, region_name=region)
eks_price = postgres_object.fetch_kubernetes_pricing()
if POSTGRES_USER:
postgres_object = Postgresql(postgres_dbname=POSTGRES_DBNAME, postgres_host=POSTGRES_HOST,
postgres_user=POSTGRES_USER, postgres_password=POSTGRES_PASSWORD,
provider_name=AWS, region_name=region)
eks_price = postgres_object.fetch_kubernetes_pricing()
else:
eks_price = 0
machine['eks_price'] = eks_price
if INFRACOST_TOKEN:
try:
Expand Down
11 changes: 7 additions & 4 deletions web/scripts/az_caching_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,13 @@ def main():
for location in machine_types_all_locations:
for machine in machine_types_all_locations[location]:
machine_type = machine['machine_type']
postgres_object = Postgresql(postgres_dbname=POSTGRES_DBNAME, postgres_host=POSTGRES_HOST,
postgres_user=POSTGRES_USER, postgres_password=POSTGRES_PASSWORD,
provider_name=AZ, region_name=location)
aks_price = postgres_object.fetch_kubernetes_pricing()
if POSTGRES_USER:
postgres_object = Postgresql(postgres_dbname=POSTGRES_DBNAME, postgres_host=POSTGRES_HOST,
postgres_user=POSTGRES_USER, postgres_password=POSTGRES_PASSWORD,
provider_name=AZ, region_name=location)
aks_price = postgres_object.fetch_kubernetes_pricing()
else:
aks_price = 0
machine['aks_price'] = aks_price
unit_price = fetch_pricing_for_az_vm(machine_type, location)
if unit_price != 0:
Expand Down
11 changes: 7 additions & 4 deletions web/scripts/gcp_caching_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,13 @@ def main(gcp_credentials: str):
for machine in machine_types_all_zones[zone]:
machine_type = machine['machine_type']
region = zone.split('-')[0] + '-' + zone.split('-')[1]
postgres_object = Postgresql(postgres_dbname=POSTGRES_DBNAME, postgres_host=POSTGRES_HOST,
postgres_user=POSTGRES_USER, postgres_password=POSTGRES_PASSWORD,
provider_name=GCP, region_name=region)
gke_price = postgres_object.fetch_kubernetes_pricing()
if POSTGRES_USER:
postgres_object = Postgresql(postgres_dbname=POSTGRES_DBNAME, postgres_host=POSTGRES_HOST,
postgres_user=POSTGRES_USER, postgres_password=POSTGRES_PASSWORD,
provider_name=GCP, region_name=region)
gke_price = postgres_object.fetch_kubernetes_pricing()
else:
gke_price = 0
machine['gke_price'] = gke_price
if INFRACOST_TOKEN:
unit_price = fetch_pricing_for_gcp_vm(machine_type, region)
Expand Down

0 comments on commit 1c13908

Please sign in to comment.