Created
July 15, 2022 20:48
-
-
Save jamesiarmes/d367fdb5bf3284426964a724cf3c12e2 to your computer and use it in GitHub Desktop.
CloudFormation template to create a group and policy that will require users to configure an MFA device.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Description: Require MFA for user access. | |
Resources: | |
MFAPolicy: | |
Type: AWS::IAM::ManagedPolicy | |
Properties: | |
ManagedPolicyName: RequireSelfManagedMFA | |
PolicyDocument: | |
Version: '2012-10-17' | |
Statement: | |
- Sid: AllowViewAccountInfo | |
Effect: Allow | |
Action: iam:ListVirtualMFADevices | |
Resource: "*" | |
- Sid: AllowManageOwnVirtualMFADevice | |
Effect: Allow | |
Action: | |
- iam:CreateVirtualMFADevice | |
- iam:DeleteVirtualMFADevice | |
Resource: arn:aws:iam::*:mfa/${aws:username} | |
- Sid: AllowManageOwnUserMFA | |
Effect: Allow | |
Action: | |
- iam:DeactivateMFADevice | |
- iam:EnableMFADevice | |
- iam:GetUser | |
- iam:ListMFADevices | |
- iam:ResyncMFADevice | |
Resource: arn:aws:iam::*:user/${aws:username} | |
- Sid: DenyAllExceptListedIfNoMFA | |
Effect: Deny | |
NotAction: | |
- iam:CreateVirtualMFADevice | |
- iam:EnableMFADevice | |
- iam:GetUser | |
- iam:ListMFADevices | |
- iam:ListVirtualMFADevices | |
- iam:ResyncMFADevice | |
- sts:GetSessionToken | |
Resource: "*" | |
Condition: | |
BoolIfExists: | |
aws:MultiFactorAuthPresent: 'false' | |
MFAGroup: | |
Type: AWS::IAM::Group | |
Properties: | |
GroupName: RequireSelfManagedMFA | |
ManagedPolicyArns: | |
- !Ref MFAPolicy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment