Skip to content

Instantly share code, notes, and snippets.

@ollytheninja
Created April 20, 2021 03:14
Show Gist options
  • Select an option

  • Save ollytheninja/8209c3a407947ec07c2085c06ee2e2f0 to your computer and use it in GitHub Desktop.

Select an option

Save ollytheninja/8209c3a407947ec07c2085c06ee2e2f0 to your computer and use it in GitHub Desktop.
Invalidate AWS access keys
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