Skip to content

Commit

Permalink
Merge pull request #170 from kuettai/main
Browse files Browse the repository at this point in the history
Fix RDS Charts causing empty report in RDS.html
  • Loading branch information
kuettai authored Dec 4, 2024
2 parents 3974562 + 4c15811 commit 07fe53a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
5 changes: 3 additions & 2 deletions Screener.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ def scanByService(service, regions, filters):
except botocore.exceptions.ClientError as e:
contexts[service[0]][region] = {}
eCode = e.response['Error']['Code']
print(eCode)
print(_cli_options['crossAccounts'])
eMsg = e.response['Error']['Message']
print("Screener.py error: {}, {}".format(eCode, eMsg))
print("Screener.py isCrossAccounts: {}".format(_cli_options['crossAccounts']))
if eCode == 'InvalidClientTokenId' and _cli_options['crossAccounts'] == True:
_warn('Impacted Region: [{}], Services: {}... Cross Account limitation, encounted errors: {}'.format(reg, service[0], e))

Expand Down
27 changes: 20 additions & 7 deletions services/rds/Rds.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def __init__(self, region):
self.setChartsType(self.CHARTSTYPE)

self.secrets = []
self.hasCEPermission = True

engineDriver = {
'mariadb': 'Mariadb',
Expand Down Expand Up @@ -124,14 +125,24 @@ def getCEResults(self, groupBy, filter):
## Fix for 30 days data
endDate = datetime.now().date()
startDate = endDate - timedelta(days=30)
response = {}

if self.hasCEPermission == True:
try:
response = self.ceClient.get_cost_and_usage(
TimePeriod={"Start": str(startDate), "End": str(endDate)},
Granularity="MONTHLY",
Metrics=["UnblendedCost"],
GroupBy=[{"Type": "DIMENSION", "Key": groupBy}],
Filter=filter,
)
except botocore.exceptions.ClientError as e:
self.hasCEPermission = False
eCode = e.response['Error']['Code']
eMsg = e.response['Error']['Message']
print("Rds.py error: {}, {}".format(eCode, eMsg))
print("[Skipped] RDS Cost Breakdown Charts")

response = self.ceClient.get_cost_and_usage(
TimePeriod={"Start": str(startDate), "End": str(endDate)},
Granularity="MONTHLY",
Metrics=["UnblendedCost"],
GroupBy=[{"Type": "DIMENSION", "Key": groupBy}],
Filter=filter,
)
return response


Expand All @@ -144,6 +155,8 @@ def getRDSCost(self, dimension, unuse_group=[]):
]
}
response = self.getCEResults(dimension, filter)
if response == {}:
return results

for item in response.get('ResultsByTime'):
for group in item.get("Groups"):
Expand Down
1 change: 1 addition & 0 deletions services/rds/drivers/RdsSecurityGroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def _checkSGHasPublicRules(self):

infoMsg = []
hasNonPrivateIp = False

for sg in settings:
if not 'IpPermissions' in sg:
continue
Expand Down

0 comments on commit 07fe53a

Please sign in to comment.