Homeβ€Ί Blogβ€Ί Week 7 - IAM Identity Center SSO: Multi-Account Pe…
AWS Weekly Lab AWS Terraform

IAM Identity Center SSO: Multi-Account Permission Sets

One set of groups and permission sets, defined entirely in Terraform, that AWS automatically turns into real IAM roles across every account in the Organization

AWS Platform Engineering Lab Β· Week 07

Lab Overview

An AWS account exists. Who is allowed to log into it?

The problem. Answered by hand, it is always answered the same way: an IAM user per person per account, an access key handed over, and no one place that knows who can reach what. Those keys do not expire, and they are the first thing an AWS security review asks about.

The objective. Define the access once β€” three permission sets, three groups β€” and let AWS provision the matching role into every target account. Then sign in as a real test user and see exactly what she gets.

The outcome. It works, and the roles appear in the target account without being declared there. One optional Terraform argument, left at its default, quietly makes the whole thing a no-op.

  1. Define Once A permission set (e.g. Engineers) is written once in Terraform, backed by an AWS managed policy and its own session duration.
  2. Group, Don't User People join a group (Engineers, ReadOnlyAuditors, BreakGlassAdmins) instead of getting individual per-account permissions.
  3. Assign Across Accounts Terraform assigns each group's permission set to every target account in one pass β€” AWS auto-provisions the matching IAM role in each one.
  4. Sign In Once Users sign in to a single SSO portal and federate into whichever account/role they're assigned β€” temporary credentials only, never a static key.

Cloud Services and Concepts

ServicePurpose hereWhat it is
IAM Identity CenterDefines who exists and what they may do, once, for every accountAWS's sign-in and assignment layer for people. Users and groups are defined once, and assignments grant them a role in each account.
Permission setThe three access levels, written once eachA reusable role template β€” a policy plus a session duration β€” that exists on its own until it is assigned to an account.
Account assignmentBinds a group to a permission set in one target accountThe link between a group and a permission set, scoped to a single account. Making one is what causes AWS to provision the real role.
AWSReservedSSO roleWhat actually exists inside the target accountThe IAM role Identity Center creates in the target account when an assignment is made. You never declare it, and it is auditable in that account's own IAM.
AWS access portalWhere a person signs inOne sign-in page that lists only the accounts and roles the signed-in user's own group memberships grant.
AWS OrganizationsSupplies the target accountsGroups AWS accounts under one management account, so policy and billing apply across all of them rather than account by account.
HCP TerraformProvisioning, with no static keysHashiCorp's hosted Terraform. It runs plans and applies on its own machines and keeps the state file, and it assumes an AWS role by OIDC so no static keys exist anywhere.

Two ideas carry the whole build. A permission set is a role that does not exist anywhere yet; an assignment is what makes AWS create it, in one account, for one group. Everything else follows from that split.

Architecture and Workflow

aws AWS Cloud Terraform groups{} + users{} in tfvars 1 Management account IAM Identity Center permission sets, groups one assignment per group x target account account assignment setproduct(groups, accounts) 2 Target account AWSReservedSSO role created by Identity Center 3 the engineer one sign-in, one role 4 Temporary credentials. No static key is ever issued.

Why Groups Instead of Per-User Assignments?

Permission sets are assigned to groups, never to individual users. Adding someone to Engineers grants every account that group already has, with no Terraform apply per person.

Why a Cross-Product for Assignments?

Every group needs its permission set in every account, so the module builds the set as setproduct(keys(groups), target_account_ids). Add an account to the OU and the next apply assigns every group to it.

Prerequisites

RequirementWhyHow to check
An AWS Organization with at least one active account in the target OUAn assignment needs somewhere to land; Week 6's vending machine is what produces theseaws organizations list-accounts-for-parent --parent-id <ou-id>
IAM Identity Center enabled in the management accountA one-time manual switch. No aws_ssoadmin_* resource can create the instance itself, so Terraform fails before it starts without itaws sso-admin list-instances returns an instance ARN
An HCP Terraform workspace with OIDC into the AWS roleKeeps credentials out of the repo and out of CIThe role's trust policy already wildcards workspace:*, so a new workspace inherits it with no IAM change
An email address for the test userIdentity Center users created by Terraform have no password and no MFA device; the invitation is sent to this addressKept in terraform.tfvars, which is gitignored

Implementation

Step 1: The identity-center Terraform Module

One module, six resource types, looped over a single groups map:

HCL β€” Cross-Account Assignment Cross-Product
locals {
  assignments = {
    for pair in setproduct(keys(var.groups), var.target_account_ids) :
    "${pair[0]}-${pair[1]}" => {
      group_name = pair[0]
      account_id = pair[1]
    }
  }
}

resource "aws_ssoadmin_account_assignment" "this" {
  for_each = local.assignments

  instance_arn       = var.instance_arn
  permission_set_arn = aws_ssoadmin_permission_set.this[each.value.group_name].arn
  principal_id        = aws_identitystore_group.this[each.value.group_name].group_id
  principal_type      = "GROUP"
  target_id           = each.value.account_id
  target_type         = "AWS_ACCOUNT"
}

The target accounts are not hardcoded. They are looked up from Week 6's vended OUs with aws_organizations_organizational_unit_child_accounts, so adding an account to Sandbox or Production becomes a new assignment target on the next apply.

Step 2: Enable IAM Identity Center (Manual, One-Time)

Prerequisite β€” No Terraform Resource Creates the Instance Itself

Enable it in the management account and choose the Organization instance type, not Account: only Organization lets assignments target every member account.

Step 3: The HCP workspace

week-07-dev was created through the HCP Terraform API rather than the UI, the same way Week 6's was; the exact call is in the lab guide. The OIDC trust policy on hcp-terraform-role already wildcards workspace:*, so the new workspace inherited working AWS auth with no IAM change at all.

The first apply added nine resources β€” three permission sets, three policy attachments, three groups. Confirmed directly in the console β€” the three groups exist:

IAM Identity Center console Groups page showing Engineers, ReadOnlyAuditors, BreakGlassAdmins
Identity Center β†’ Groups β€” all three created exactly as defined in Terraform

And the permission sets, each backed by its managed policy:

IAM Identity Center console Permission sets page
Identity Center β†’ Permission sets β€” ReadOnlyAuditors, Engineers, BreakGlassAdmins, each with their attached AWS managed policy

Step 4: Adding a Test User and Assigning to a Real Account

A second apply added the test user jane.engineer to the Engineers group and created the three account assignments:

HCP Terraform second apply showing 5 resources added, including identitystore_user and three ssoadmin_account_assignment resources
HCP Terraform β€” second apply: user, group membership, and 3 account assignments created. Outputs confirm assignment_count = 3

The assignment is visible from the account side too β€” all three groups now show up against the target account:

IAM Identity Center AWS accounts tab showing assigned groups and permission sets for the target account
Identity Center β†’ AWS accounts β†’ target account β€” all three groups assigned, each to their own permission set

Step 5: Confirming AWS Auto-Provisioned the Roles

This is the part that makes Identity Center worth using: nothing was ever declared inside the target account's own IAM. Switching into it directly shows three roles that simply appeared the moment the assignment was made:

IAM Roles page inside the target account, filtered to AWSReservedSSO, showing three auto-provisioned roles
Target account β†’ IAM β†’ Roles, filtered to AWSReservedSSO β€” all three roles auto-provisioned by Identity Center, trusted entity is the Identity Center SAML provider

Step 6: Signing In as the Test User

Terraform-created users have no password and no MFA device, so the first sign-in needs an admin-initiated reset (see Troubleshooting). Signed in, the portal showed exactly one account and one role:

AWS access portal showing one account assigned to Jane, with one role (Engineers) available
AWS access portal, signed in as jane.engineer β€” sees the target account with only the Engineers role, even though three permission sets are assigned to that account
Federated AWS console session inside the target account
Federated console session in the target account β€” temporary credentials issued by Identity Center, no IAM user or access key involved anywhere

Validation and Evidence

Each row traces to a figure in this post. The lab was destroyed in July 2026, so these are the results recorded then, not a fresh run.

TestExpectedActualStatus
Terraform creates the identity objectsThree groups and three permission setsAll three groups and all three permission sets present in Identity Center, each with its managed policyPass
Assignments reach the target accountEach group bound to its permission set on the target accountAll three groups listed against the target accountPass
AWS provisions the role itselfAn AWSReservedSSO role per permission set, created by Identity Center and never declared in TerraformThree AWSReservedSSO roles present in the target account's own IAM consolePass
The portal scopes by group membershipThe test user sees only the role her own group grantsSigned in as jane.engineer, the portal showed the target account with the Engineers role onlyPass
No static credential is issuedA temporary federated session, and no IAM user or access key in the target accountFederated console session issued by Identity Center; no IAM user or access key was created in any target accountPass
Session durations differ by privilegeBreakGlassAdmins shorter than EngineersConfigured at 1 hour against 4 hours. Not recorded at the time whether a session was observed expiringConfigured, not observed

Security and Cost

Security β€” Controls at Every Layer

  • Least-privilege permission sets. Three distinct levels (ReadOnlyAccess, PowerUserAccess, AdministratorAccess) rather than one shared admin role handed to anyone who needs any access at all.
  • Shortest session for the highest privilege. BreakGlassAdmins gets a 1-hour session, deliberately shorter than the 4-hour Engineers one. Full-admin access should expire fastest.
  • No static credentials anywhere. Every session is federated and temporary. No IAM user and no access key was created in any target account, not even for the test user used to validate this.
  • Real emails stay out of git. terraform.tfvars is gitignored; the committed .example shows the shape only.
What's Missing for Production
  • MFA enforcement was relaxed to "Allow them to sign in" purely to unblock testing β€” must be reverted to requiring MFA registration before any real user gets one of these permission sets
  • No automated lifecycle for removing a user's group membership when they leave a team or the org
  • BreakGlassAdmins has no approval workflow or alerting on use β€” a real break-glass process should notify someone the moment that permission set is actually assumed
  • Permission sets use broad AWS managed policies; a production rollout should move toward narrower customer-managed or inline policies per role

Cost

IAM Identity Center, permission sets, groups, users, and account assignments are all free β€” so are the IAM roles Identity Center provisions into target accounts.

Destroyed: $0. Nothing in this week's build carries a per-resource cost β€” the only thing worth cleaning up deliberately is the test deviations (MFA setting, OU override), not billable infrastructure.

Troubleshooting and Lessons

Problem. The first plan created zero account assignments and reported success.
Root cause. The module derives its targets by listing the child accounts of named OUs, and Week 6's Sandbox and Production OUs existed but had nothing vended into them yet. An empty OU is not an error: it returns an empty list, and setproduct of three groups with zero accounts is zero assignments.
Resolution. Overrode target_ou_names to ["Dev"] through an HCP workspace variable, pointing at an older OU with one active account. A deliberate deviation, written into the README to be reverted once accounts exist in the intended OUs.
Lesson. A cross-product over a data source yields nothing at all when one side is empty, and Terraform calls that a successful plan. Assert the count.

Problem. Signing in as the Terraform-created test user returned "You are required to provide multi-factor authentication that you do not have" β€” for a user with no MFA device, and after the MFA setting had already been relaxed.
Root cause. Not established. It behaved like a stuck sign-in state left by an earlier blocked attempt rather than a policy being evaluated: relaxing the setting and waiting for propagation did not clear it.
Resolution. Used the admin-initiated Reset password on the user's detail page instead of the self-service "Forgot password?" flow. That path issued a fresh credential and the block disappeared.
Lesson. Identity Center users created by Terraform have no password and no MFA device, and there is no Terraform equivalent of "send the invitation". The first sign-in is a manual step, and the admin path is the one that behaves.

Problem. All three permission sets were assigned to the target account, but the test user's portal showed only Engineers, which looked like two assignments having failed.
Root cause. Not a fault. The portal scopes by the signed-in user's own group membership, not by everything assigned to the account, and the test user was only in Engineers.
Resolution. None needed; confirmed against the assignment API, which listed all three.
Lesson. The portal and the API answer different questions. Check the one that reports configuration before concluding the configuration is wrong.

Cleanup and Key Takeaways

Cleanup β€” Tearing It Down

week-07-dev is VCS-connected, same restriction as Weeks 5–6 β€” destroy is confirmed from the HCP UI, not local CLI.

ResourceDestroyed by Terraform?Manual step needed?
Permission sets, policy attachmentsYesAWS refuses to delete a permission set with live assignments anywhere β€” remove assignments first
Identity Store groups, users, membershipYesNone
Account assignmentsYesNone
IAM Identity Center instance itselfNo β€” never in stateDisable manually via console, if desired, the same way it was enabled
Test deviations to revert, not just destroy
The target_ou_names = ["Dev"] workspace variable override and the relaxed MFA setting were both introduced purely to validate this module end-to-end. Reverting them is a settings/variable change, separate from a Terraform destroy.

References

Takeaways β€” What I'd Do Differently

  1. Groups scale; per-user assignments do not. Onboarding becomes a group-membership change rather than a Terraform apply, so the access model scales independently of headcount.
  2. Verify the auto-provisioning. The account-side roles are real, auditable resources. Checking them inside the target account, rather than trusting the plan output, is what confirmed the pipeline end to end.
  3. "Not showing up" is not always a fault. The portal scopes by group membership. Checking the assignment API first saved a wrong fix.
  4. Document deviations rather than hiding them. Testing against a live account meant diverging from the stated design twice; both are written into the README as reversible.

Comments

How was your experience?
Your feedback helps improve this site.
PoorExcellent