Commit 5bdf722e authored by Ilia Lazebnik's avatar Ilia Lazebnik Committed by GitHub

fix: Allow running on custom AWS partition (incl. govcloud) (#94)

parent dec17783
...@@ -2,6 +2,8 @@ data "aws_caller_identity" "current" { ...@@ -2,6 +2,8 @@ data "aws_caller_identity" "current" {
count = var.aws_account_id == "" ? 1 : 0 count = var.aws_account_id == "" ? 1 : 0
} }
data "aws_partition" "current" {}
locals { locals {
aws_account_id = element( aws_account_id = element(
concat( concat(
...@@ -41,9 +43,9 @@ data "aws_iam_policy_document" "iam_self_management" { ...@@ -41,9 +43,9 @@ data "aws_iam_policy_document" "iam_self_management" {
# Allow for both users with "path" and without it # Allow for both users with "path" and without it
resources = [ resources = [
"arn:aws:iam::${local.aws_account_id}:user/*/$${aws:username}", "arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}",
"arn:aws:iam::${local.aws_account_id}:user/$${aws:username}", "arn:${data.aws_partition.current.partition}: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}:mfa/$${aws:username}",
] ]
} }
...@@ -71,9 +73,9 @@ data "aws_iam_policy_document" "iam_self_management" { ...@@ -71,9 +73,9 @@ data "aws_iam_policy_document" "iam_self_management" {
# Allow for both users with "path" and without it # Allow for both users with "path" and without it
resources = [ resources = [
"arn:aws:iam::${local.aws_account_id}:user/*/$${aws:username}", "arn:${data.aws_partition.current.partition}:iam::${local.aws_account_id}:user/*/$${aws:username}",
"arn:aws:iam::${local.aws_account_id}:user/$${aws:username}", "arn:${data.aws_partition.current.partition}: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}:mfa/$${aws:username}",
] ]
condition { condition {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment