Awesome Open Source
Awesome Open Source



Serverless function to automate enforcement of Multi-Factor Authentication (MFA) to all AWS IAM users with access to AWS Management Console.

How to use it ?

Enforcing MFA to IAM users was a manual task. But now all you have to do is, setup Serverless Framework and run the command:

git clone
cd aws-mfa-enforce
# execute awscli commands to configure email notifications
sls deploy

To add email notification feature, edit serverless.js to set the email subject and body. Also execute the following commands before deploying:

aws ssm put-parameter --name email --type String --value [email protected] --region us-east-1
aws ssm put-parameter --name email_password --type String --value your_password --region us-east-1

(Don't forget to allow insecure apps to access your Gmail account. This setup will not work otherwise.)

How does it work ?

This serverless function creates an IAM Group called MFA-enforced with an inline policy which denies access to all AWS services until the IAM user activate MFA. It also has a lambda function which acts as a cron (for every 12 hours) to check for new IAM users and add it to the group.

Lambda Architecture

It can also send emails to the IAM user accounts if the IAM usernames is a valid email ID. But this is optional feature.


How to remove it (if necessary) ?

Goto and remove all users from the group. Then to remove the complete serverless function execute sls remove.


Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Javascript (1,552,287
Aws (11,141
Automation (6,761
Serverless (4,774
Authentication (3,912
Aws Lambda (3,026
Serverless Framework (860
Mfa (155
Aws Iam (129
Related Projects