-
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 all 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 |
---|---|---|
|
@@ -183,7 +183,7 @@ data "aws_iam_policy_document" "instance_role" { | |
} | ||
|
||
resource "aws_s3_bucket" "vault_storage" { | ||
count = "${var.enable_s3_backend ? 1 : 0}" | ||
count = "${var.enable_s3_backend}" | ||
bucket = "${var.s3_bucket_name}" | ||
force_destroy = "${var.force_destroy_s3_bucket}" | ||
|
||
|
@@ -194,14 +194,14 @@ resource "aws_s3_bucket" "vault_storage" { | |
} | ||
|
||
resource "aws_iam_role_policy" "vault_s3" { | ||
count = "${var.enable_s3_backend ? 1 : 0}" | ||
count = "${var.enable_s3_backend}" | ||
name = "vault_s3" | ||
role = "${aws_iam_role.instance_role.id}" | ||
policy = "${element(concat(data.aws_iam_policy_document.vault_s3.*.json, list("")), 0)}" | ||
} | ||
|
||
data "aws_iam_policy_document" "vault_s3" { | ||
count = "${var.enable_s3_backend ? 1 : 0}" | ||
count = "${var.enable_s3_backend}" | ||
|
||
statement { | ||
effect = "Allow" | ||
|
@@ -213,3 +213,30 @@ data "aws_iam_policy_document" "vault_s3" { | |
] | ||
} | ||
} | ||
|
||
resource "aws_iam_role_policy" "vault_aws_ec2_iam_auth" { | ||
count = "${var.create_aws_auth_backend_iam_policies}" | ||
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)}" | ||
} | ||
|
||
# Source for IAM policies: https://www.vaultproject.io/docs/auth/aws.html#recommended-vault-iam-policy | ||
# TODO: Add Cross Account Access stanza, enumerating all roles with cross-account access | ||
|
||
data "aws_iam_policy_document" "vault_aws_ec2_iam_auth" { | ||
count = "${var.create_aws_auth_backend_iam_policies}" | ||
|
||
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 = ["*"] | ||
} | ||
} |
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.