Best Python code snippet using localstack_python
iam_test_admin.py
Source:iam_test_admin.py  
...131    try:132        Title  = 'No3.Validate that changing the general PB of the General user to another policy fails.'133        result = ret_failed134        ret = None135        ret = session.client('iam').put_user_permissions_boundary(136            UserName = Tenant_GeneralUserName,137            PermissionsBoundary = 'arn:aws:iam::aws:policy/AdministratorAccess'138        )139    except botocore.exceptions.ClientError as e:140        message = e.response141        if e.response['Error']['Code'] == 'AccessDenied':142            result = ret_OK143        else:144            result = ret_failed145    else:146        #ãã®ãã¹ãã¯AccessDeniedã«ãªããªãã¨ãããªã147        message = ret148        result = ret_NG149    finally:...scp-03-Permission.py
Source:scp-03-Permission.py  
...102        'iam',103        aws_access_key_id=Credentials['Credentials']['AccessKeyId'],104        aws_secret_access_key=Credentials['Credentials']['SecretAccessKey'],105        aws_session_token=Credentials['Credentials']['SessionToken'])106    iam_client.put_user_permissions_boundary(107        UserName=User_Name,108        PermissionsBoundary=boundaryArn109    )110    111    iam_client.tag_user(112        UserName=User_Name,113        Tags=[114            {115                'Key': 'Creator Name',116                'Value': creatorName117            },118            {119                'Key': 'Creator Type',120                'Value': creatorType...main.py
Source:main.py  
...6def lambda_handler(event, context):7    if event['detail']['eventName'] == "CreateUser":8        User_Name = event['detail']['responseElements']['user']['userName']9        identityArn = event['detail']['responseElements']['user']['arn']10        iam_client.put_user_permissions_boundary(11            UserName=User_Name,12            PermissionsBoundary=boundaryArn13        )14    elif event['detail']['eventName'] == "CreateRole":15        identityArn = event['detail']['responseElements']['role']['arn']16        Role_Name = identityArn.split('/')[-1]17        iam_client.put_role_permissions_boundary(18            RoleName=Role_Name,19            PermissionsBoundary=boundaryArn20        )21    else:22        print(event['detail']['eventName'])23        return event['detail']['eventName']24    rspAction="Permissions boundary policy has been attached"...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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
