Skip to content
This repository has been archived by the owner on Sep 17, 2021. It is now read-only.

Bump cloudaux and move IAM User and Role to new CloudAux orchestration #1099

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
six>=1.11.0
cloudaux==1.5.0
cloudaux>=1.5.0
celery==4.2.0
celery[redis]==4.2.0
redis==2.10.6
Expand Down
20 changes: 5 additions & 15 deletions security_monkey/watchers/iam/iam_role.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from security_monkey.cloudaux_batched_watcher import CloudAuxBatchedWatcher
from cloudaux.aws.iam import list_roles
from cloudaux.orchestration.aws.iam.role import get_role
from cloudaux.orchestration.aws.iam.role import get_all_roles
from security_monkey import AWS_DEFAULT_REGION


class IAMRole(CloudAuxBatchedWatcher):
class IAMRole(CloudAuxWatcher):
index = 'iamrole'
i_am_singular = 'IAM Role'
i_am_plural = 'IAM Roles'
Expand All @@ -17,22 +17,12 @@ def __init__(self, **kwargs):

def _get_regions(self):
return [AWS_DEFAULT_REGION]

def get_name_from_list_output(self, item):
return item['RoleName']

def list_method(self, **kwargs):
all_roles = list_roles(**kwargs)
items = []

for role in all_roles:
role["Region"] = "us-east-1" # IAM is global
items.append(role)

return items
return get_all_roles(**kwargs)

def get_method(self, item, **kwargs):
# This is not needed for IAM Role:
item.pop("Region")

return get_role(dict(item), **kwargs)
return item
6 changes: 3 additions & 3 deletions security_monkey/watchers/iam/iam_user.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from security_monkey.cloudaux_watcher import CloudAuxWatcher
from security_monkey import AWS_DEFAULT_REGION
from cloudaux.aws.iam import list_users
from cloudaux.orchestration.aws.iam.user import get_user
from cloudaux.orchestration.aws.iam.user import get_all_users


class IAMUser(CloudAuxWatcher):
Expand All @@ -27,7 +27,7 @@ def _get_regions(self):
return [AWS_DEFAULT_REGION]

def list_method(self, **kwargs):
return list_users(**kwargs)
return get_all_users(**kwargs)

def get_method(self, item, **kwargs):
return get_user(item, **kwargs)
return item