import boto3
# Assuming you have the necessary AWS credentials configured
# Create an IAM client
iam_client = boto3.client('iam')
# Provide the username of the user whose password needs to be reset
username = 'your_username'
# Reset the password
response = iam_client.update_login_profile(
UserName=username,
PasswordResetRequired=True
)
# Check if the password reset was successful and print the response
if response['ResponseMetadata']['HTTPStatusCode'] == 200:
print("Password reset successful!")
else:
print("Password reset failed.")