Best Python code snippet using localstack_python
scp-03-Permission.py
Source:scp-03-Permission.py
...61 aws_access_key_id=Credentials['Credentials']['AccessKeyId'],62 aws_secret_access_key=Credentials['Credentials']['SecretAccessKey'],63 aws_session_token=Credentials['Credentials']['SessionToken'])64 65 iam_client.put_role_permissions_boundary(66 RoleName=Role_Name,67 PermissionsBoundary=boundaryArn68 )69 70 Role_Info = iam_client.get_role(RoleName=Role_Name)['Role']['AssumeRolePolicyDocument']['Statement'][0]['Principal']71 if "Federated" in Role_Info:72 trustedIdt = "Federated"73 elif "Service" in Role_Info:74 trustedIdt = Role_Info['Service'].split('.')[-3]75 else:76 trustedIdt = Role_Info['AWS'].split(':')[4]77 iam_client.tag_role(78 RoleName=Role_Name,79 Tags=[...
lambda_function.py
Source:lambda_function.py
...39 # AWS principal is typically in the format of arn:aws:iam::${Account_Id}:user/*40 # so we will take the first occurrence of the account id in the AWS principal string41 account_id = re.search(r'[0-9]{12}', principal).group()42 if account_id not in expected_awsPrincipals:43 iam_client.put_role_permissions_boundary(RoleName=role_name, PermissionsBoundary=Pb_policy)44 else:45 # Define the regex pattern to find. Service principals are usually in the format of46 # <service-name>.amazonaws.com. We don't want .amazonaws.com so we are looking for 47 # everything before the first period. 48 find = re.compile(r"^[^.]*")49 if type(assume_role_principal['Service']) is list:50 servicePrincipals = assume_role_principal['Service']51 else:52 servicePrincipals = [assume_role_principal['Service']]53 54 for principal in servicePrincipals:55 # group() returns the whole match pattern56 service = re.search(find, principal).group()57 if service not in expected_servicePrincipals:...
main.py
Source:main.py
...13 )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"25 output = {26 "Identity ARN": identityArn,27 "Respond Action": rspAction}28 ...
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!!