Hey there,
I am trying to remove about 900+ users at the same time from our QS Account. I would like to do it through API. I was able to call a file file in my command csv and tsv and use it to remove a single user but not multiple. API Call below. Has anyone been able to remove multiple users in one call?
aws quicksight delete-user --user-name file://delete-file.csv --namespace default --aws-account-id XXXX --region us-east-1
@pagekevi ,
The API call is for deleting a single user, you probably have to script automation to loop through each user from the file and make an API call.
Kind regards,
Koushik
Thanks Koushik. I will try to work on a solution with a loop.
Solution below. I uploaded a list to S3. Then ran a script in Glue.
import collections
import sys
import boto3
import csv
Create QuickSight client
quicksight = boto3.client(‘quicksight’)
s3 = boto3.resource(‘s3’)
s3.Bucket(‘XXX’).download_file(‘remove_qs_users.csv’, ‘/tmp/remove_qs_users.csv’)
with open(‘remove_qs_users.csv’, ‘r’) as f:
reader = csv.reader(f)
next(reader) # Skip the header row
for row in reader:
username = row[0] # Assuming username is the first field in each row
email = f’{username}@amazon.com’
session_name = email
try:
response = quicksight.delete_user(
AwsAccountId='XXXX',
Namespace='default',
UserName=email
)
print(f"User {email} deleted successfully.")
except Exception as e:
print(f"Failed to delete user {email}: {e}")
job.commit()
1 Like