GithubHelp home page GithubHelp logo

vhascoet / aws-mfa-entity-already-exists-fix Goto Github PK

View Code? Open in Web Editor NEW

This project forked from beartime234/aws-mfa-entity-already-exists-fix

0.0 0.0 0.0 529 KB

A fix for the entity already exists for AWS IAM MFA error

Home Page: https://console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/new?stackName=mfa-entity-already-exists-fix&templateURL=https://aws-mfa-entity-already-exists-fix.s3.amazonaws.com/template.yml

License: MIT License

Python 100.00%

aws-mfa-entity-already-exists-fix's Introduction

AWS MFA Entity Already Exists Fix

This fixes the error that can occur when an IAM user tries to create an MFA device and they click cancel or the session times out. The MFA device is still assigned to the user but not synced properly. So when the user tries to create another virtual MFA device it fails with the error Entity Already Exists. You can see a demonstration of the error occurring below.

error

The Cloudformation template installs a lambda and a cloudwatch event that listens for this error occuring and deletes the MFA device. Meaning that the user can quickly recreate their MFA device. You can see it working below.

fixed

Installation

You can launch this solution yourself using this link .

By default this will launch the stack in us-east-1. It needs to be deployed there or else it wont recevie the event from Cloudwatch. This is due to IAM living in us-east-1.

The Cloudformation template builds a lambda function and a cloudwatch event that triggers the lambda function. Read the cloudformation template for the full list of resources it creates.

Things to note

  • This does not break when a user creates an MFA device correctly. The cloudwatch event specifically listens for the error and only runs the program when the specific error occurs.
  • The lambda only occurs when the error runs. So the user needs to trigger the error for it to work. Normally users will just try it again.
  • This does not delete the MFA device if the user is wanting to resync their MFA device etc.
  • It takes about 5 - 10 seconds after the user triggers the error for the lambda to do its magic.
  • The only way that you could trigger this accidentally is if you made the API call directly while you already had a working MFA device but that seems unlikely.
  • This application assumes users can only create MFA devices for themselves as if not another user could maliciously make the create-virtual-mfa-device call and trigger this on another user.
  • I have noticed that in some accounts this error doesn't occur as it seems to do this on it's own.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

If you change handler.py please update the Cloudformation template accordingly.

Please make sure to update tests as appropriate.

License

MIT

aws-mfa-entity-already-exists-fix's People

Contributors

beartime234 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.