Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: require deterministic values for the for loop from var.account_assignments #53

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,24 @@ module "sso_account_assignments" {

account_assignments = [
{
account = "111111111111", # Represents the "production" account
account_id = "111111111111", # Represents the "production" account
account_name = "Account1"
permission_set_arn = module.permission_sets.permission_sets["AdministratorAccess"].arn,
permission_set_name = "AdministratorAccess",
principal_type = "GROUP",
principal_name = "Administrators"
},
{
account = "111111111111",
account_id = "111111111111",
account_name = "Account1"
permission_set_arn = module.permission_sets.permission_sets["S3AdministratorAccess"].arn,
permission_set_name = "S3AdministratorAccess",
principal_type = "GROUP",
principal_name = "S3Adminstrators"
},
{
account = "222222222222", # Represents the "Sandbox" account
account_id = "222222222222", # Represents the "Sandbox" account
account_name = "account2"
permission_set_arn = module.permission_sets.permission_sets["AdministratorAccess"].arn,
permission_set_name = "AdministratorAccess",
principal_type = "GROUP",
Expand Down
2 changes: 1 addition & 1 deletion examples/complete/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ terraform {
required_version = ">= 1.3.0"

required_providers {
local = "~> 1.2"
local = "~> 2.4.1"
}
}
4 changes: 2 additions & 2 deletions modules/account-assignments/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ data "aws_identitystore_user" "this" {
locals {
assignment_map = {
for a in var.account_assignments :
format("%v-%v-%v-%v", a.account, substr(a.principal_type, 0, 1), a.principal_name, a.permission_set_name) => a
format("%v-%v-%v-%v", a.account_name, substr(a.principal_type, 0, 1), a.principal_name, a.permission_set_name) => a
}
}

Expand All @@ -48,7 +48,7 @@ resource "aws_ssoadmin_account_assignment" "this" {
principal_id = each.value.principal_type == "GROUP" ? data.aws_identitystore_group.this[each.value.principal_name].id : data.aws_identitystore_user.this[each.value.principal_name].id
principal_type = each.value.principal_type

target_id = each.value.account
target_id = each.value.account_id
target_type = "AWS_ACCOUNT"
}

Expand Down
11 changes: 6 additions & 5 deletions modules/account-assignments/variables.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
variable "account_assignments" {
type = list(object({
account = string
permission_set_name = string
permission_set_arn = string
principal_name = string
principal_type = string
account_name = string // has to be determined value before terraform apply
account_id = string // can be determined later
permission_set_name = string // has to be determined value before terraform apply
permission_set_arn = string // can be determined later
principal_name = string // has to be determined value before terraform apply
principal_type = string // has to be determined value before terraform apply
}))
}

Expand Down
Loading