# Outputs ====================================================================

output "account_ids" {
  description = "Map of logical account key to AWS account ID"
  value       = { for account_key, account in aws_organizations_account.this : account_key => account.id }
}

output "account_arns" {
  description = "Map of logical account key to account ARN"
  value       = { for account_key, account in aws_organizations_account.this : account_key => account.arn }
}

output "account_access_role_arns" {
  description = "Map of logical account key to cross-account access role ARN — used by the calling stack to assume into each vended account"
  value = {
    for account_key, account in aws_organizations_account.this :
    account_key => "arn:aws:iam::${account.id}:role/${var.accounts[account_key].account_access_role_name}"
  }
}
