AWS Connect - Iterate through Connect User list and Delete Quick Connect if does not match existing user

Viewed 21

I'm trying to create an iterable function using Python/Boto3 where if a user is not listed in the Connect user list they are removed from Quick Connects. I've looked at the list-queue-quick-connects API and the connect list-users API, however it seems like list-users only gives an email field, and the list-queue-quick-connects API gives just Name. I'm trying to figure out a way to setup a comparison and then execute the deletequickconnect api to delete the quick connect since Quick Connects are not automatically deleted when a user is deleted from Connect.

I can list connect users this way - aws connect list-users --instance-id --query 'UserSummaryList[*].Username' --output text

and quick connect users this way - aws connect list-queue-quick-connects --instance-id --queue-id --query 'QuickConnectSummaryList[*].Name' --output text.

Can anyone provide any assistance? I would really appreciate any help!

1 Answers

To do this you need to list the quick connects with ListQuickConnects, setting QuickConnectTypes to USER retrieving the Id. e.g.

aws connect list-quick-connects --instance-id xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx --query 'QuickConnectSummaryList[*].Id' --quick-connect-types 'USER' --output text

Then iterate through the returned QuickConnectSummaryList and call DescribeQuickConnect for each QC Id. DescribeQuickConnect can give you the UserId for the user. e.g.

aws connect describe-quick-connect --instance-id xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx --query 'QuickConnect.QuickConnectConfig.UserConfig.UserId' --quick-connect-id yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy

You can then check that against the list of ids from

aws connect list-users --instance-id --query 'UserSummaryList[*].Id' --output text

If the UserId from DescribeQuickConnect isn't in that list it can be deleted. I'm reasonably sure that deleting the QC removes it from the QCs for any queue it is attached to :)

Related