Make sure you are using Python3 and Boto3. If you dont have the entire code samples, you can get them here:
I build addusers.py to read from a file.
This code won’t Likely work if you are running it a browser because there will be no authentication credentials. Boto3 uses the same credential structure as the AWS CLI. Hope that helps.