user14226172
user14226172

Reputation:

Boto Script for user deletion with time constraint

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

Answers (1)

kenlukas
kenlukas

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.

References

Upvotes: 2

Related Questions