Created
October 27, 2017 15:51
-
-
Save p0bailey/c20e34fd014c70ae372079c3d6d296d6 to your computer and use it in GitHub Desktop.
terraform iam group aws api mfa protected plus ip lockdown
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
resource "aws_iam_group" "ec2Admins" { | |
name = "ec2Admins" | |
} | |
resource "aws_iam_group_policy" "force_MFA_on_apikeys_policy" { | |
name = "force_MFA_on_apikeys_policy" | |
group = "${aws_iam_group.ec2Admins.id}" | |
depends_on = ["aws_iam_group.ec2Admins"] | |
policy = <<EOF | |
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Action": "ec2:*", | |
"Resource": "*", | |
"Condition": { | |
"Bool": { | |
"aws:MultiFactorAuthPresent": "true" | |
}, | |
"IpAddress": { | |
"aws:SourceIp": [ | |
"my.office.ip.address/32" | |
] | |
} | |
} | |
} | |
] | |
} | |
EOF | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment