I am printing out a list of users in AWS. The data prints out to the screen in an uneven way, based on the variability in length of the first column:
us-svc-cloudops-aws AIDAIDNRJABLEK6Z2MSME arn:aws:iam::123456789101:user/us-svc-cloudops-aws 2019-02-13 19:05:10
us-svc-kadi-aws-jenkins AIDAJHPWXCPNWRU6UCRPO arn:aws:iam::123456789101:user/us-svc-kadi-aws-jenkins 2017-05-16 18:35:11
us-svc-ksr AIDAIPXXXD3JW3A75QNR2 arn:aws:iam::123456789101:user/us-svc-ksr 2018-05-15 20:25:17
us-svc-splunk-aws AIDAINU7WJB4O3DHQXCLU arn:aws:iam::123456789101:user/us-svc-splunk-aws 2017-10-03 15:40:59
us-svc-turbomonic-aws AIDAIRNXWR5BZOKJZ6TMU arn:aws:iam::123456789101:user/us-svc-turbomonic-aws 2017-10-03 15:53:04
Here is my code so far:
user_list = client.list_users()
for user in user_list['Users']:
user_name = user['UserName']
user_id = user['UserId']
user_arn = user['Arn']
create_date = user['CreateDate']
time_format = "%Y-%m-%d %H:%M:%S"
create_date = str(create_date.strftime(time_format))
print_string = user_name + ' ' + user_id + ' ' + user_arn + ' ' + create_date
print(print_string)
Here is an example of what a user_list looks like:
{'Users': [{'Path': '/', 'UserName': 'bluethundr', 'UserId': 'AIDAVMGUQ5SMEMELAT4YR', 'Arn': 'arn:aws:iam::123456789101:user/bluethundr', 'CreateDate': datetime.datetime(2019, 4, 5, 16, 39, 1, tzinfo=tzutc())}], 'IsTruncated': False, 'ResponseMetadata': {'RequestId': '1ccacd69-5749-4284-a690-4a6de43f22f4', 'HTTPStatusCode': 200, 'HTTPHeaders': {'x-amzn-requestid': '1ccacd69-5749-4284-a690-4a6de43f22f4, 1ccacd69-5749-4284-a690-4a6de43f22f4', 'date': 'Thu, 25 Apr 2019 15:33:41 GMT', 'content-type': 'text/xml', 'content-length': '557'}, 'RetryAttempts': 0}}
I want the output on the screen to be spaced evenly. Is there any way I can achieve this using python?