Skip to content

Commit

Permalink
fix: Allow running on custom AWS partition (incl. govcloud) (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
DrFaust92 authored Sep 8, 2020
1 parent dec1778 commit 5bdf722
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions modules/iam-group-with-policies/policies.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ data "aws_caller_identity" "current" {
count = var.aws_account_id == "" ? 1 : 0
}

data "aws_partition" "current" {}

locals {
aws_account_id = element(
concat(
Expand Down Expand Up @@ -41,9 +43,9 @@ data "aws_iam_policy_document" "iam_self_management" {

# Allow for both users with "path" and without it
resources = [
"arn:aws:iam::${local.aws_account_id}:user/*/$${aws:username}",
"arn:aws:iam::${local.aws_account_id}:user/$${aws:username}",
"arn:aws:iam::${local.aws_account_id}:mfa/$${aws:username}",
"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}",
"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:user/$${aws:username}",
"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:mfa/$${aws:username}",
]
}

Expand Down Expand Up @@ -71,9 +73,9 @@ data "aws_iam_policy_document" "iam_self_management" {

# Allow for both users with "path" and without it
resources = [
"arn:aws:iam::${local.aws_account_id}:user/*/$${aws:username}",
"arn:aws:iam::${local.aws_account_id}:user/$${aws:username}",
"arn:aws:iam::${local.aws_account_id}:mfa/$${aws:username}",
"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}",
"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:user/$${aws:username}",
"arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:mfa/$${aws:username}",
]

condition {
Expand Down

0 comments on commit 5bdf722

Please sign in to comment.