Skip to content

Instantly share code, notes, and snippets.

@p0bailey
Last active October 27, 2017 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save p0bailey/7debef438264cf41c96da082157900f1 to your computer and use it in GitHub Desktop.
Save p0bailey/7debef438264cf41c96da082157900f1 to your computer and use it in GitHub Desktop.
terraform iam group aws api mfa protected
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"
}
}
}
]
}
EOF
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment