UPD: updated iam-last-activity.py and removed hard-coded account id
This commit is contained in:
parent
68761f216a
commit
b1af2b9d1b
@ -10,7 +10,7 @@ from jmespath.exceptions import JMESPathTypeError
|
|||||||
|
|
||||||
# dump user/group/role last activity
|
# dump user/group/role last activity
|
||||||
|
|
||||||
def generateLastAccessed(myclient, arn, myAccountId: str):
|
def generateLastAccessed(myclient, arn, myAccountId):
|
||||||
response = myclient.generate_service_last_accessed_details(
|
response = myclient.generate_service_last_accessed_details(
|
||||||
Arn=arn,
|
Arn=arn,
|
||||||
Granularity='SERVICE_LEVEL')
|
Granularity='SERVICE_LEVEL')
|
||||||
@ -28,13 +28,15 @@ def generateLastAccessed(myclient, arn, myAccountId: str):
|
|||||||
ServiceNamespaces=jmespath.search("ServicesLastAccessed[*].ServiceNamespace", accessDetails)
|
ServiceNamespaces=jmespath.search("ServicesLastAccessed[*].ServiceNamespace", accessDetails)
|
||||||
)
|
)
|
||||||
returnString = []
|
returnString = []
|
||||||
try:
|
# try:
|
||||||
for p in jmespath.search(
|
for p in jmespath.search("PoliciesGrantingServiceAccess[*].Policies[]", r2):
|
||||||
f"PoliciesGrantingServiceAccess[*].Policies[?contains(PolicyArn,'${myAccountId}')].PolicyArn", r2):
|
if p.get("PolicyType") == "INLINE":
|
||||||
if len(p) > 0:
|
returnString.append("INLINE:" + p.get("PolicyName"))
|
||||||
returnString.append(p[0])
|
else:
|
||||||
except JMESPathTypeError:
|
if myAccountId in p.get("PolicyArn"):
|
||||||
pass
|
returnString.append(p.get("PolicyArn"))
|
||||||
|
# except JMESPathTypeError:
|
||||||
|
# pass
|
||||||
return list(dict.fromkeys(returnString))
|
return list(dict.fromkeys(returnString))
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user