Reputation:
I am working on a boto script that will delete the user after a time period of 20 minutes. I am not able to figure out the approach for the solution.So far I can delete the user without a time period constraint using this script.
import boto3
import sys
import json
import datetime
import dateutil
iam = boto3.client('iam')
response = iam.remove_user_from_group(
GroupName='GoodGroup',
UserName='GoodUser'
)
response = iam.delete_user(
UserName='GoodUser'
)
Upvotes: 1
Views: 169
Reputation: 3963
Look up the user with a get_user()
call, and use the CreateDate
and current time to figure out the delta. Use an if statement to remove the user if the delta is greater than or equal to 20 minutes.
Upvotes: 2