Advertisement
Guest User

Untitled

a guest
Feb 24th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. import json
  2. import boto3
  3. import uuid
  4.  
  5. def lambda_handler(event, context):
  6.  
  7.     c = boto3.client('iam')
  8.  
  9.     password = str(uuid.uuid4())
  10.     response = c.create_user(
  11.         UserName = event['user_name'],
  12.     )
  13.     c.create_login_profile(
  14.         UserName=event['user_name'],
  15.         Password=password,
  16.         PasswordResetRequired=True
  17.     )
  18.     response = c.add_user_to_group(
  19.         GroupName = event['group_name'],
  20.         UserName = event['user_name'],
  21.     )        
  22.    
  23.     return {
  24.         'statusCode': 200,
  25.         'body': json.dumps('Password added user: ' + password)
  26.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement