Package: trustyroles
TrustyrolesAn AWS Roles ToolkitTrusty Roles is intended to alleviate some of the painpoints I have dealt with in AWS automation leveraging boto3.
The first version of this focuses on easily editing the assume role policy document of a role.Installpip install trustyrolesAssume Role Policy Update ModuleCommand Line Toolarpd_updateusage: arpd_update.py [-h] [-a ARN [ARN ...]] -u UPDATE_ROLE
                      [-m {get,update,remove}] [-e ADD_EXTERNAL_ID] [-r] [-j]
                      [-p] [-s SID]

optional arguments:
  -h, --help            show this help message and exit
  -a ARN [ARN ...], --arn ARN [ARN ...]
                        Add new ARNs to trust policy. Takes a comma-seperated
                        list of ARNS.
  -u UPDATE_ROLE, --update_role UPDATE_ROLE
                        Role for updating trust policy. Takes an role friendly
                        name as string.
  -m {get,update,remove}, --method {get,update,remove}
                        Takes choice of method to get, update, or remove.
  -e ADD_EXTERNAL_ID, --add_external_id ADD_EXTERNAL_ID
                        Takes an externalId as a string.
  -r, --remove_external_id
                        Method for removing externalId condition. Takes no
                        arguments
  -j, --json            Add to print json in get method.
  --backup_policy       Creates a backup of previous policy in current directory
                        as <ISO-time>.policy.bk
  --add_sid ADD_SID     Add a Sid to trust policy. Takes a string.
  --remove_sid          Remove a Sid from a trust policy. Takes no arguments.Example usage:Get Policyarpd_update -m get -u 'test-role' --jsonReturns:{
 "Action": "sts:AssumeRole",  
 "Condition": {},
 "Effect": "Allow",
 "Principal": {
  "AWS": ["arn:aws:iam:::user/test-role"]
 }
}Using Python Modulesarpd_updateGet Policyfromtrustyroles.arpd_updateimportarpd_updatearpd_update.get_arpd(role_name='test-role')Returns:{  
 "Action": "sts:AssumeRole",  
 "Condition": {},
 "Effect": "Allow",
 "Principal": {
  "AWS": ["arn:aws:iam:::user/test-role"]
 }
}Update Policy ARNSThe update_arn method takes a list of ARNS(arn_list) and a role_name to add to trust policy of suppplied role.fromtrustyroles.arpd_updateimportarpd_updatearpd_update.update_arn(arn_list=["arn:aws:iam:::user/test-role2"],role_name='test-role')Remove Policy ARNSThe remove_arn method takes a list of ARNS(arn_list) and a role_name to add to trust policy of suppplied role.fromtrustyroles.arpd_updateimportarpd_updatearpd_update.remove_arn(arn_list=["arn:aws:iam:::user/test-role2"],role_name='test-role')Add ExternalIdThe add_external_id method takes an external_id and role_name as strings to allow the addition of an externalId condition.fromtrustyroles.arpd_updateimportarpd_updatearpd_update.add_external_id(external_id='<external_id>',role_name='test-role')Remove ExternalIdThe remove_external_id method takes a role_name as a string to allow the removal of an externalId condition.fromtrustyroles.arpd_updateimportarpd_updatearpd_update.remove_external_id(role_name='test-role')Add SidAdd a Sid to trust policy. Takes a string.fromtrustyroles.arpd_updateimportarpd_updatearpd_update.add_sid(role_name='test-role',sid='testRoleId')Remove SidRemove a Sid from a trust policy. Takes no arguments.fromtrustyroles.arpd_updateimportarpd_updatearpd_update.remove_sid(role_name='test-role')