#NEWLINE# def run( self ) : #NEWLINE# #INDENT# grants = keymanager . get_grants ( ) #NEWLINE# try : #NEWLINE# #INDENT# roles = [ x for x in iam . roles . all ( ) ] #NEWLINE# #UNINDENT# except ClientError : #NEWLINE# #INDENT# logging . error ( 'Failed to fetch IAM roles.' ) #NEWLINE# return #NEWLINE# #UNINDENT# services = [ ] #NEWLINE# for service in Service . data_type_date_index . query ( 'service' ) : #NEWLINE# #INDENT# services . append ( service . id ) #NEWLINE# #UNINDENT# for role in roles : #NEWLINE# #INDENT# if ( role . name in services ) : #NEWLINE# #INDENT# logging . info ( 'Managing grants for {0}.' . format ( role . name ) ) #NEWLINE# keymanager . _ensure_grants ( role , grants ) #NEWLINE# #UNINDENT# #UNINDENT# logging . info ( 'Finished managing grants.' )