-
Notifications
You must be signed in to change notification settings - Fork 467
AWS IAM Policy for Vault AWS Auth method #71
base: master
Are you sure you want to change the base?
Changes from 19 commits
3323a71
93339ed
6eee689
c624968
03d8194
3eef292
720adbf
6cf8e19
7dc1638
8de0eab
c544ca3
8893851
b4f4e31
ab63036
fdeb3e0
17a02db
a268913
3b85902
932d711
7512e42
199b04a
0f03108
69e47eb
dae9f4b
471b5f5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -202,7 +202,8 @@ resource "aws_iam_role_policy" "vault_s3" { | |
} | ||
|
||
data "aws_iam_policy_document" "vault_s3" { | ||
count = "${var.enable_s3_backend ? 1 : 0}" | ||
count = "${var.enable_s3_backend ? 1 : 0}" | ||
|
||
statement { | ||
effect = "Allow" | ||
actions = ["s3:*"] | ||
|
@@ -213,3 +214,27 @@ data "aws_iam_policy_document" "vault_s3" { | |
] | ||
} | ||
} | ||
|
||
resource "aws_iam_role_policy" "vault_aws_EC2_IAM_Auth" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use all lower case for resource and variable names. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done with latest commit, but I leave it to you to 'resolve', if you're satisfied. :) |
||
count = "${var.enable_EC2_IAM_Auth ? 1 : 0}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @brikis98 Done with latest commit, but I leave it to you to 'resolve', if you're satisfied. :) (TM) |
||
name = "vault_aws_EC2_IAM_Auth" | ||
role = "${aws_iam_role.instance_role.id}" | ||
policy = "${element(concat(data.aws_iam_policy_document.vault_aws_EC2_IAM_Auth.*.json, list("")), 0)}" | ||
} | ||
|
||
data "aws_iam_policy_document" "vault_aws_EC2_IAM_Auth" { | ||
count = "${var.enable_EC2_IAM_Auth ? 1 : 0}" | ||
|
||
statement { | ||
effect = "Allow" | ||
|
||
actions = [ | ||
"ec2:DescribeInstances", | ||
"iam:GetInstanceProfile", | ||
"iam:GetUser", | ||
"iam:GetRole", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a link to the docs where the requirements for these policies are defined? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am setting up something similar myself. The docs for this policy are located at: https://www.vaultproject.io/docs/auth/aws.html#recommended-vault-iam-policy However, it would be nice to have an option for the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @brikis98 Done with latest commit but I leave it to you to 'resolve', if you're satisfied. :) @BMonsalvatge That's exactly where I got them. Thanks for the link. :) Re: cross-account 'sts:AssumeRole': I know the original policies have the sts:AssumeRole stanza, but I'm not sure how to properly enumerate the roles and accounts that's 'generic' for all cases. My present company doesn't really need it - we have sts:AssumeRole added to the IAM Instance Profile at line 175 in this file, and that was enough. However, I added a "TODO", seen in the recent commit. If you have this sussed out, I'd love to see it in the code, too. :) |
||
] | ||
|
||
resources = ["*"] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -185,3 +185,8 @@ variable "force_destroy_s3_bucket" { | |
description = "If 'configure_s3_backend' is enabled and you set this to true, when you run terraform destroy, this tells Terraform to delete all the objects in the S3 bucket used for backend storage. You should NOT set this to true in production or you risk losing all your data! This property is only here so automated tests of this module can clean up after themselves. Only used if 'enable_s3_backend' is set to true." | ||
default = false | ||
} | ||
|
||
variable "enable_EC2_IAM_Auth" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps |
||
description = "Configure IAM Instance Profile on Vault cluster members to permit the user to enable AWS Auth backend. Note that this does NOT actually enable the backend, but merely sets policies that will permit it to function as expected." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The description is a little confusing. Perhaps: "If set to true, create the IAM policies required by the AWS Auth backend. Note that this does NOT..." |
||
default = false | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be configurable by variable and probably disabled by default. I know this is vault cluster private, but the default settings run it in the Default VPC, which for most users will have no private subnets. We could add comments to mention that for prod usage, this should be a custom VPC and private subnets.