Created
April 20, 2021 03:14
-
-
Save ollytheninja/8209c3a407947ec07c2085c06ee2e2f0 to your computer and use it in GitHub Desktop.
Invalidate AWS access keys
This file contains hidden or 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 | |
| from botocore.exceptions import ClientError | |
| def invalidate_key(id, secret): | |
| iam = boto3.client('iam', aws_access_key_id=id, aws_secret_access_key=secret) | |
| try: | |
| iam.update_access_key( | |
| AccessKeyId=id, | |
| Status='Inactive' | |
| ) | |
| print('Access key invalidated') | |
| except ClientError as e: | |
| print("Something went wrong...") | |
| print(e) | |
| if __name__ == "__main__": | |
| access_key = input("AWS KEY: ") | |
| access_secret = input("AWS SECRET: ") | |
| invalidate_key(access_key, access_secret) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment