Created
September 7, 2019 12:20
-
-
Save takakabe/3b188ce23da13a552c0a55d883c8592e to your computer and use it in GitHub Desktop.
Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
iam = boto3.client('iam') | |
sts = boto3.client('sts') | |
access_key_id = iam.list_access_keys()['AccessKeyMetadata'][0]['AccessKeyId'] | |
response = sts.get_caller_identity() | |
user_name = response['Arn'].split('/')[1] | |
iam.delete_access_key( | |
AccessKeyId=access_key_id, | |
UserName=user_name | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment