PaulR
2 min readDec 15, 2020

Efficient way to create AWS IAM users in bulk using aws cli and python

Occasionally you might come across a situation when you might have to create multiple AWS IAM users in bulk and assign the access and secret key to the user securely. It is a very tedious task when done from the AWS console or the cli, but there is always an efficient and faster way to do things.

I am going to explain to you a more efficient way of creating multiple users in bulk using aws cli and python subprocess.

We assume that we have an existing policy that we will assign to each user and have setup our aws cli with access and secret key.

First, define the list of users we will be creating in a python list and a list to hold the values for access and secret keys.

Next, we create variables for each aws cli commands we need to run.

Let’s create a function that runs whatever commands we pass using python subprocess.

Finally, call the runCommand function.

Putting it all together.

Output:

Done!

PaulR
PaulR

No responses yet