How to use deactivate_mfa_device method in localstack

Best Python code snippet using localstack_python

aws_utils.py

Source:aws_utils.py Github

copy

Full Screen

...100 iam = self.iam101 devices = []102 response = iam.list_mfa_devices(UserName=user)103 return response['MFADevices']104 def deactivate_mfa_device(self, user, serial):105 iam = self.iam106 response = iam.deactivate_mfa_device(UserName=user,SerialNumber=serial)107 108 def delete_virtual_mfa_device(self, user, serial):109 iam = self.iam110 self.deactivate_mfa_device(user, serial)111 response = iam.delete_virtual_mfa_device(SerialNumber=serial)112 def create_iam_users(self, user_list):113 iam = self.iam114 created_users = []115 create_failed = []116 create_error_dict = {}117 for user in user_list:118 user_exist = self.check_if_user_exists(user)119 if not user_exist:120 try:121 iam.create_user(UserName=user)122 created_users.append(user)123 except Exception as error:124 create_failed.append(user)...

Full Screen

Full Screen

aws-delete-users.py

Source:aws-delete-users.py Github

copy

Full Screen

...59 list_mfa_devices = client.list_mfa_devices(60 UserName=row[1]61 ) # Listing MFA devices62 if list_mfa_devices['MFADevices']: # Deleting if any63 deactivate_mfa_device = [client.deactivate_mfa_device( UserName=row[1],64 SerialNumber= Id['SerialNumber']65 ) for Id in list_mfa_devices['MFADevices'] ]66 delete_virtual_mfa_device = [client.delete_virtual_mfa_device(67 SerialNumber= Id['SerialNumber']68 ) for Id in list_mfa_devices['MFADevices'] ]69 list_user_policies = client.list_user_policies(UserName=row[1]) # Listing user policies70 if list_user_policies['PolicyNames']: # Deleting if any71 delete_user_policy = [client.delete_user_policy(72 UserName=row[1],73 PolicyName= names74 ) for names in list_user_policies['PolicyNames']] 75 list_attached_user_policies = client.list_attached_user_policies(76 UserName=row[1]) # Listing user policies77 if list_attached_user_policies['AttachedPolicies']: # Deleting if any...

Full Screen

Full Screen

mfa_disassociate.py

Source:mfa_disassociate.py Github

copy

Full Screen

2client=boto3.client('iam')3iam = boto3.resource('iam')4user_name=''5serial_number=''6def deactivate_mfa_device(user_name,serial_number):7 response = client.deactivate_mfa_device(UserName=user_name,SerialNumber=serial_number)8 print "done"9def get_mfa_serial_number(user_name):10 paginator = client.get_paginator('list_virtual_mfa_devices')11 response = client.list_virtual_mfa_devices(AssignmentStatus='Any')12 sno=''13 for key, value in response.items():14 if key=='VirtualMFADevices':15 for i in value:16 for k,v in i.items():17 if k=='SerialNumber':18 sno=v19 if k == 'User':20 for u,uv in v.items():21 if u =='UserName' and uv == user_name:22 serial_number=sno23 return sno...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful