Member-only story
How to rotate your IAM user Access Keys very effectively?
6 min readMay 30, 2022
OBJECTIVE: In this blog, I am going to explain how to rotate the IAM user access keys very effectively in a simple manner. all the organizations can use this set-up to overcome security issues and improve security scores.
I have used the below AWS services to achieve this,
- IAM users with tag(email:useremail@domain.com)
- SES with domain configured
- Lambda function(x3) with Python 3.x
- EventBridge rule(x3)
- Secret Manager (create secrets exactly with user names for all the IAM users)
Create 1st lambda function with the name create_access_keys and paste the below code. Create the 1st Eventbridge rule with the name invoke_create_access_keys, add the target of the lambda function and schedule it for every 1 day.
import boto3, os, time, datetime, sys, json
from datetime import date
from botocore.exceptions import ClientError
from time import gmtime, strftime
from datetime import datetimeiam = boto3.client('iam')
secretmanager = boto3.client('secretsmanager')email_list = []todaysDate = strftime("%Y-%m-%d %H:%M:%S", gmtime())
todaysDate = str(todaysDate)
todaysDate = todaysDate[0:10]
todaysDate =…