← All articles
Best PracticesNov 29, 202619 min read

Move from IAM Users to AWS IAM Identity Center: A Step-by-Step Guide

Serdal Tarkan AltunSecurity Research EngineerLinkedIn

Summary

AWS IAM Identity Center, formerly AWS SSO, replaces IAM users and their long-term access keys with one central sign-in and short-term role credentials from permission sets. To move, audit IAM users and keys, enable an organization instance, require MFA, assign permission sets to groups, switch the AWS CLI to SSO profiles, then deactivate and delete the old keys.

Quick steps

  1. Run the read-only audit to save the credential report and the last use of every access key.
  2. Enable an organization instance of IAM Identity Center in the management account and register a delegated administrator.
  3. Connect one identity source: the Identity Center directory, Active Directory, or an external identity provider with SAML 2.0 and SCIM.
  4. Require MFA at every sign-in, with security keys or built-in authenticators.
  5. Rebuild your IAM groups as permission sets and assign them to groups, not users.
  6. Move CLI users to aws configure sso profiles.
  7. Deactivate access keys nobody uses anymore, watch for breakage, then delete them.
  8. Centralize root access, delete member account root credentials, and alert on the CloudTrail events that undo the work.

Applies to: AWS IAM Identity Center organization instances in AWS Organizations, IAM users and the root user in management and member accounts, and AWS CLI version 2 (PKCE sign-in is the default from version 2.22.0), as of November 2026.

What is AWS IAM Identity Center and why move off IAM users?

AWS IAM Identity Center is the AWS service that connects your workforce users to AWS accounts and AWS managed applications, either from your existing identity provider or from users you create in it. AWS's overview records that AWS Single Sign-On was renamed AWS IAM Identity Center on July 26, 2022. That is why many people still search for "AWS SSO", and why the CLI kept aws configure sso, sso-admin and identitystore.

What do AWS IAM best practices say about human users?

The first entry in AWS's IAM security best practices is blunt: "Require your human users to use temporary credentials when accessing AWS." For central access management, the same page recommends IAM Identity Center. Our glossary entry on AWS IAM best practices covers the rest of the list.

An IAM user carries long-term credentials: a console password and up to two access keys. A key copied into a laptop profile, a script or a repository lets anyone who finds it sign API requests as that user, which MITRE ATT&CK tracks as Valid Accounts: Cloud Accounts (T1078.004). An attacker who already has a foothold can also add a key to another user, the pattern our rules for access keys created for another IAM user watch.

With Identity Center, people sign in once and pick an account and a role. Each permission set you assign becomes an Identity Center-controlled IAM role in each target account, and users get temporary credentials for it. The IAM user vs role comparison shows why that difference matters.

Organization instance or account instance?

You need an organization instance to replace IAM users. AWS's instance comparison shows that only the organization instance supports multi-account permissions:

Capability Organization instance (management account) Account instance (member or standalone account)
Permission sets and access to AWS accounts Yes No
AWS access portal sign-in to AWS accounts Yes No
Delegated administrator Yes No
SAML 2.0 customer managed applications Yes No
Scope The whole organization One account and one Region

An account instance can't be converted or merged into an organization instance later. IAM Identity Center is offered at no extra charge (as of November 2026, per the AWS FAQ).

Which identity source should you choose?

The identity source decides where users and groups live and who enforces MFA. An organization has one identity source at a time:

Identity source Where users and groups are managed Who enforces MFA Notes
Identity Center directory IAM Identity Center IAM Identity Center The default when you enable the service
Active Directory AWS Managed Microsoft AD, or a self-managed AD through AD Connector or a two-way trust IAM Identity Center, or RADIUS MFA through AWS Directory Service Simple AD isn't supported
External identity provider Your IdP, provisioned with SCIM or by hand The external IdP Users and groups must exist in Identity Center before you assign them

If your workforce already signs in through an identity provider, connect it with SAML 2.0 for sign-in and SCIM for provisioning. For SCIM to provision a user, the user needs a first name, last name, user name and display name.

Before you start

Plan the access you'll recreate, who runs the change, and a way back in if sign-in breaks. Test the whole sequence in a sandbox organization or test accounts first, because a wrong identity source change can remove every assignment.

Permissions and accounts

  • Enable IAM Identity Center from the Organizations management account. Choose a Region that all your users can reach; the instance starts in that Region.
  • Administer it from a delegated administrator member account, so fewer people need the management account. AWS's managed policies split the roles: AWSSSOMasterAccountAdministrator and AWSSSOMemberAccountAdministrator for Identity Center administrators, AWSSSOReadOnly and AWSSSODirectoryReadOnly for read-only reviewers.
  • Retire keys with a principal allowed iam:ListAccessKeys, iam:GetAccessKeyLastUsed, iam:UpdateAccessKey and iam:DeleteAccessKey; the audit needs only IAM read and list actions.
  • Run in parallel. Enabling Identity Center doesn't change existing IAM users, roles or direct IAM federation, so both can run during the move.

Plan emergency access

AWS recommends an emergency access configuration for an Identity Center or Region disruption: a separate emergency operations account that your IdP reaches through direct IAM federation, with an empty group that you fill only during an outage. Build and test it before the cutover. Keep the management account root user, protected with MFA, as the last resort.

Find what depends on each key

Not every access key belongs to a person. AWS lists use cases that still need IAM users with long-term credentials, among them workloads that can't use IAM roles, third-party AWS clients without Identity Center support, and CodeCommit or Amazon Keyspaces credentials. Workloads running on AWS compute should use IAM roles instead, and workloads outside AWS can use IAM Roles Anywhere or web identity federation. Separate human and non-human identities in your inventory.

Step 1: Audit IAM users and access keys

Start with a list of every IAM user, its console password and MFA status, and each access key with its last use. Two AWS sources give you that: the IAM credential report and the access key last used API.

AWS's credential report page describes a CSV of all users and the status of their passwords, access keys and MFA devices. IAM generates a new one at most every four hours. The report covers only the first two access keys per user and no service-specific credentials, so the script also reads every key with list-access-keys and get-access-key-last-used.

The script below is read-only: it changes no AWS configuration. Its generate-credential-report call, an IAM read action, asks IAM for a new report, which replaces the one report IAM keeps. Run it in AWS CloudShell or on a Linux admin workstation, once per AWS account, as a principal allowed the IAM read and list actions named in its header. AWS returns only key IDs, never a secret access key.

#!/usr/bin/env bash
# audit-iam-user-credentials.sh
#
# Purpose:  Read-only inventory of IAM user credentials in one AWS account. It saves the
#           IAM credential report (passwords, MFA and the first two access keys of each
#           user and of the root user) and writes one row per access key with its status,
#           creation date and last use (date, service, Region).
# Mode:     Read-only. Changes no AWS configuration. generate-credential-report (an IAM
#           Read action) asks IAM for a new report, which replaces the one report IAM
#           keeps. Writes two CSV files to the output folder.
#           AWS returns access key IDs only; no secret access key is read or written.
# Needs:    AWS CLI v2, and a principal allowed iam:GenerateCredentialReport,
#           iam:GetCredentialReport, iam:ListUsers, iam:ListAccessKeys,
#           iam:GetAccessKeyLastUsed and iam:GetAccountSummary.
# Run on:   AWS CloudShell or a Linux admin workstation, once per AWS account.
# Usage:    ./audit-iam-user-credentials.sh <output-dir> [profile]
#           ./audit-iam-user-credentials.sh ./iam-audit
#           ./audit-iam-user-credentials.sh ./iam-audit audit-111122223333

set -euo pipefail

OUT_DIR="${1:?usage: audit-iam-user-credentials.sh <output-dir> [profile]}"
PROFILE="${2:-}"

aws_cli() {
  if [[ -n "$PROFILE" ]]; then
    aws --profile "$PROFILE" "$@"
  else
    aws "$@"
  fi
}

mkdir -p "$OUT_DIR"
ACCOUNT_ID="$(aws_cli sts get-caller-identity --query Account --output text)"
REPORT="$OUT_DIR/credential-report-$ACCOUNT_ID.csv"
KEYS="$OUT_DIR/access-keys-$ACCOUNT_ID.csv"

# 1. Credential report: request it, wait until it is complete, then decode it (Base64).
state=""
for attempt in 1 2 3 4 5 6 7 8 9 10; do
  state="$(aws_cli iam generate-credential-report --query State --output text)"
  if [[ "$state" == "COMPLETE" ]]; then
    break
  fi
  sleep 5
done
if [[ "$state" != "COMPLETE" ]]; then
  echo "Credential report not ready after $attempt attempts (state: $state)" >&2
  exit 1
fi
aws_cli iam get-credential-report --query Content --output text | base64 --decode > "$REPORT"

# 2. One row per access key of every IAM user, with its last use.
echo "account_id,user,access_key_id,status,created,last_used,last_service,last_region" > "$KEYS"
users=0
keys=0
active=0
never_used=0
for user in $(aws_cli iam list-users --query 'Users[].UserName' --output text); do
  users=$((users + 1))
  key_rows="$(aws_cli iam list-access-keys --user-name "$user" \
    --query 'AccessKeyMetadata[].[AccessKeyId,Status,CreateDate]' --output text)"
  while read -r key_id status created; do
    if [[ -z "${key_id:-}" ]]; then
      continue
    fi
    last="$(aws_cli iam get-access-key-last-used --access-key-id "$key_id" \
      --query 'AccessKeyLastUsed.[LastUsedDate,ServiceName,Region]' --output text)"
    read -r last_used last_service last_region <<< "$last"
    echo "$ACCOUNT_ID,\"$user\",$key_id,$status,$created,$last_used,$last_service,$last_region" >> "$KEYS"
    keys=$((keys + 1))
    if [[ "$status" == "Active" ]]; then
      active=$((active + 1))
    fi
    if [[ "$last_used" == "None" ]]; then
      never_used=$((never_used + 1))
    fi
  done <<< "$key_rows"
done

# 3. Console passwords without MFA (from the report) and root user credentials (account summary).
no_mfa="$(awk -F',' 'NR == 1 { for (i = 1; i <= NF; i++) col[$i] = i; next }
  $col["password_enabled"] == "true" || $col["password_enabled"] == "TRUE" {
    if ($col["mfa_active"] == "false" || $col["mfa_active"] == "FALSE") n++ }
  END { print n + 0 }' "$REPORT")"
root_keys="$(aws_cli iam get-account-summary --query 'SummaryMap.AccountAccessKeysPresent' --output text)"
root_mfa="$(aws_cli iam get-account-summary --query 'SummaryMap.AccountMFAEnabled' --output text)"

echo "Account:                       $ACCOUNT_ID"
echo "Credential report:             $REPORT"
echo "Access key inventory:          $KEYS"
echo "IAM users:                     $users"
echo "Access keys:                   $keys (active: $active, never used: $never_used)"
echo "Console passwords without MFA: $no_mfa"
echo "Root user access keys present: $root_keys"
echo "Root user MFA enabled:         $root_mfa"

Run it for one account, optionally with a named profile:

./audit-iam-user-credentials.sh ./iam-audit audit-111122223333

Example output (the values are illustrative):

Account:                       111122223333
Credential report:             ./iam-audit/credential-report-111122223333.csv
Access key inventory:          ./iam-audit/access-keys-111122223333.csv
IAM users:                     23
Access keys:                   17 (active: 12, never used: 3)
Console passwords without MFA: 4
Root user access keys present: 0
Root user MFA enabled:         1

The key inventory has one row per key:

account_id,user,access_key_id,status,created,last_used,last_service,last_region
111122223333,"jdoe",AKIAIOSFODNN7EXAMPLE,Active,2023-04-11T08:20:00+00:00,2026-11-27T16:02:00+00:00,s3,us-east-1
111122223333,"legacy-admin",AKIAI44QH8DHBEXAMPLE,Active,2021-02-03T10:41:00+00:00,2026-10-19T07:55:00+00:00,iam,us-east-1
111122223333,"build-bot",AKIAJ2EXAMPLEKEYID01,Active,2022-09-30T12:00:00+00:00,None,N/A,N/A

How to read the results:

  • A person's active key: move that person to Identity Center (Steps 2 to 5), then retire the key in Step 6.
  • None in last_used: the key has never been used, or not since AWS began tracking. Deactivate it first.
  • Console passwords without MFA: each is an IAM user who signs in to the console with a password alone, which the console sign-in without MFA rules flag.
  • Root user access keys present above 0: handle the root user in Step 7; AWS recommends no root access keys at all.

IAM records each call in CloudTrail, so the audit itself leaves GenerateCredentialReport and GetCredentialReport events. Tell your SOC before you run it. Last use is coarse: in the credential report, AWS records only the first use of a key in each 15-minute span.

Step 2: Enable IAM Identity Center and connect the identity source

Enable an organization instance in the management account, hand daily administration to a delegated administrator, and connect the identity source your people already use.

Enable the organization instance

  1. Sign in to the management account with administrative credentials and open the IAM Identity Center console in the Region you chose.
  2. Choose Enable. Where the Region supports it, AWS first asks for a single-Region, multi-Region or custom instance configuration.
  3. Leave Enable multi-account permissions on, as it is by default. Without it, the AWS accounts section doesn't appear in the console.

Register a delegated administrator

Open Settings > Management > Delegated administrator > Register account while signed in to the management account, and pick a dedicated member account. Only one member account can be the delegated administrator at a time. It can manage almost everything, with exceptions that shape your design:

  • It can't manage permission sets provisioned in the management account, or user access to that account. Create dedicated permission sets for the management account and manage them from there.
  • AWS advises assigning users, not groups, to permission sets in the management account. Anyone who can change those groups, in your IdP or directory, would otherwise decide who reaches it.

Connect your identity source

Change the source under Settings > Identity source > Actions > Change identity source. AWS's identity source considerations explain what each direction keeps:

Change Users, groups and assignments
Identity Center directory to external IdP, or between two external IdPs Kept
Active Directory to the Identity Center directory or an external IdP Kept; the default access portal URL changes
Any source to Active Directory, or between two Active Directory directories Permanently deleted

For an external IdP, configure SAML 2.0 and SCIM automatic provisioning. The attribute your IdP sends as the SAML NameID must match the user name that SCIM maps, or sign-in fails. AWS generates SCIM access tokens with a one-year validity; when one expires, provisioning stops.

Changes to the identity source are rare and powerful, so the Identity Center identity source rules watch events such as AssociateDirectory.

Step 3: Configure MFA in IAM Identity Center

Require MFA at every sign-in when Identity Center authenticates users itself. That is the case with the Identity Center directory and with Active Directory; with an external IdP, the MFA section isn't available and your IdP enforces MFA.

Open Settings > Authentication > Multi-factor authentication > Configure. AWS's MFA settings page describes each option:

Setting Options Recommended value Effect
Prompt users for MFA Every time they sign in (always-on), the default; Only when their sign-in context changes (context-aware); Never (disabled) Every time they sign in (always-on) Context-aware lets users trust a device; Never disables Identity Center MFA
Users can authenticate with these MFA types Security keys and built-in authenticators; Authenticator apps Security keys and built-in authenticators FIDO2 credentials are phishing-resistant; authenticator apps use TOTP codes
If a user does not yet have a registered MFA device Require them to register an MFA device at sign in (the default when you first configure MFA); Require them to provide a one-time password sent by email to sign in; Block their sign-in; Allow them to sign in Require them to register an MFA device at sign in, or Block their sign-in once everyone is enrolled AWS notes that email codes aren't bound to a device, so they fall short of industry-standard MFA

Two details matter. With context-aware prompting, a user who marks a device as trusted isn't prompted for MFA, even when Block their sign-in is set. And each user can register up to eight MFA devices, up to two authenticator apps and six FIDO authenticators, so ask people to register a backup.

The console saves these settings with PutMfaDeviceManagementForDirectory, an sso action in the Service Authorization Reference that is not part of the public IAM Identity Center API. CloudTrail records it as a console operation, which the Identity Center MFA settings rules watch.

Step 4: Create permission sets and assign groups

A permission set is the template of an IAM role that Identity Center provisions into each account you assign it to. Rebuild each IAM group from Step 1 as a permission set, then assign permission sets to groups.

Choose the policy types

AWS's permission set policy page lists four building blocks:

Policy type Where it lives What to know
AWS managed policy Every AWS account Ready to use; a predefined permission set uses exactly one AWS managed policy
Customer managed policy Your AWS accounts Create a policy with the same name and path in every account you assign the permission set to
Inline policy The permission set Identity Center creates it in each assigned account
Permissions boundary AWS managed or customer managed policy Sets the maximum permissions the other policies can grant; it grants nothing itself

By default, a custom permission set takes up to 10 AWS managed and customer managed policies, plus one inline policy. The permissions boundary glossary entry explains how boundaries cap access, and least privilege access is the goal for every set.

Create the permission set

  1. In the IAM Identity Center console, under Multi-account permissions, choose Permission sets > Create permission set.
  2. Pick Predefined permission set with one AWS managed policy, or Custom permission set to combine policies and a boundary.
  3. Name it, and set Session duration. The default is one hour and the maximum is 12 hours; AWS advises no longer than the work needs.

The AWS access portal session is separate: users stay signed in for eight hours by default, and you can raise it to 90 days. Keep it short for administrators.

Assign it to groups

Under Multi-account permissions, choose AWS accounts, select up to 10 accounts, and choose Assign users or groups. Select the groups and the permission set, then submit. AWS recommends assigning access to groups rather than individual users, except in the management account.

The same steps with the AWS CLI change configuration. Run them in the management account or the delegated administrator account, in the Identity Center Region:

INSTANCE_ARN=$(aws sso-admin list-instances --query 'Instances[0].InstanceArn' --output text)
STORE_ID=$(aws sso-admin list-instances --query 'Instances[0].IdentityStoreId' --output text)

PS_ARN=$(aws sso-admin create-permission-set --instance-arn "$INSTANCE_ARN" \
  --name ReadOnlyAccess --session-duration PT4H \
  --query 'PermissionSet.PermissionSetArn' --output text)

aws sso-admin attach-managed-policy-to-permission-set --instance-arn "$INSTANCE_ARN" \
  --permission-set-arn "$PS_ARN" --managed-policy-arn arn:aws:iam::aws:policy/ReadOnlyAccess

aws sso-admin put-permissions-boundary-to-permission-set --instance-arn "$INSTANCE_ARN" \
  --permission-set-arn "$PS_ARN" \
  --permissions-boundary '{ "CustomerManagedPolicyReference": { "Name": "WorkforceBoundary", "Path": "/" } }'

GROUP_ID=$(aws identitystore get-group-id --identity-store-id "$STORE_ID" \
  --alternate-identifier '{ "UniqueAttribute": { "AttributePath": "displayName", "AttributeValue": "aws-readonly" } }' \
  --query GroupId --output text)

REQUEST_ID=$(aws sso-admin create-account-assignment --instance-arn "$INSTANCE_ARN" \
  --target-id 111122223333 --target-type AWS_ACCOUNT --permission-set-arn "$PS_ARN" \
  --principal-type GROUP --principal-id "$GROUP_ID" \
  --query 'AccountAssignmentCreationStatus.RequestId' --output text)

aws sso-admin describe-account-assignment-creation-status --instance-arn "$INSTANCE_ARN" \
  --account-assignment-creation-request-id "$REQUEST_ID"

The boundary policy WorkforceBoundary must already exist in the target account. Repeat the last command until it reports SUCCEEDED, or FAILED with a reason. If you change the permission set later, the CLI reference says the IAM policies on the roles in your accounts aren't updated automatically until you call aws sso-admin provision-permission-set, for example with --target-type ALL_PROVISIONED_ACCOUNTS.

Each assignment is a CreateAccountAssignment event and each new set a CreatePermissionSet event. The permission set and assignment change rules alert on both.

Step 5: Configure AWS SSO login in the AWS CLI v2

CLI users swap their access key profiles for SSO profiles that fetch short-term credentials. AWS's CLI SSO guide recommends the SSO token provider configuration, which refreshes tokens automatically.

Find the start URL first. In the AWS access portal, choose Access keys next to a permission set and open the IAM Identity Center credentials method for the SSO Start URL and SSO Region. From CLI version 2.22.0, the Issuer URL on the Identity Center Dashboard or Settings page works too. Then run the wizard:

aws configure sso

It asks for a session name, the start URL, the SSO Region and the registration scope (sso:account:access). It then opens a browser, lists your accounts and roles, and writes a profile and an sso-session section to ~/.aws/config:

[profile admin-prod]
sso_session = corp
sso_account_id = 111122223333
sso_role_name = ReadOnlyAccess
region = us-east-1
output = json

[sso-session corp]
sso_start_url = https://<portal>.awsapps.com/start
sso_region = us-east-1
sso_registration_scopes = sso:account:access

Sign in, then check who you are:

aws sso login --profile admin-prod
aws sts get-caller-identity --profile admin-prod --query Arn --output text
arn:aws:sts::111122223333:assumed-role/AWSReservedSSO_ReadOnlyAccess_0123456789abcdef/jdoe

The role name starts with AWSReservedSSO_ followed by the permission set name. The CLI caches the token under ~/.aws/sso/cache and renews role credentials while the Identity Center session is valid. aws sso logout deletes the cached credentials.

From version 2.22.0, the CLI uses PKCE authorization by default, which needs a browser on the same device. The older device authorization flow is still there behind --use-device-code for hosts without a browser. MITRE ATT&CK describes device code phishing under Spearphishing Link (T1566.002), and the Identity Center device code phishing rules look for it.

Step 6: Deactivate, then delete IAM user access keys

Retire each key in two moves: deactivate it, wait, then delete it. AWS's access key administration page explains why the order matters: a deactivated key can be activated again, but a deleted key can't be recovered.

Before you deactivate a key, confirm the owner signs in through Identity Center and look for recent calls signed with it. CloudTrail event history keeps 90 days of management events per Region:

aws cloudtrail lookup-events \
  --lookup-attributes AttributeKey=AccessKeyId,AttributeValue=AKIAI44QH8DHBEXAMPLE \
  --max-items 20 --query 'Events[].[EventTime,EventName,EventSource]' --output table

Event history holds management events only, so a key used only for data events, such as reading S3 objects, won't show there. Check the last_used column from Step 1 too, which comes from IAM's record of the key's most recent signed API request.

The PowerShell script below changes configuration. It calls the AWS CLI, so it needs AWS CLI v2 in PATH and Windows PowerShell 5.1 or later; no AWS Tools for PowerShell module is required. It deactivates keys, or deletes keys that are already inactive, and skips any key used within -MinimumUnusedDays. It supports -WhatIf and -Confirm.

#Requires -Version 5.1

<#
.SYNOPSIS
    Deactivates IAM user access keys, or deletes keys that are already inactive, through the AWS CLI.

.DESCRIPTION
    Reads the access key inventory that audit-iam-user-credentials.sh writes (columns user and
    access_key_id). For each key it reads the current status (aws iam list-access-keys) and the
    last use (aws iam get-access-key-last-used). A key used within MinimumUnusedDays is skipped;
    a key that was never used is measured from its creation date.

      -Mode Deactivate  Sets each Active key to Inactive (aws iam update-access-key). Reversible.
      -Mode Delete      Deletes each key whose status is already Inactive (aws iam delete-access-key).
                        A deleted access key can't be recovered.

    Supports -WhatIf and -Confirm. Each change asks for confirmation unless you pass -Confirm:$false.
    It never reads or writes a secret access key. Returns one object per key.

.PARAMETER Mode
    Deactivate or Delete.

.PARAMETER InventoryPath
    Path of the CSV from audit-iam-user-credentials.sh, for example
    '.\iam-audit\access-keys-111122223333.csv'.

.PARAMETER MinimumUnusedDays
    Skip keys used (or created, if never used) within this many days, for example 30.

.PARAMETER UserName
    Optional. Act only on the keys of these IAM users, for example 'jdoe'.

.PARAMETER AwsProfile
    Optional. The AWS CLI profile to use, for example 'iam-admin-111122223333'.

.EXAMPLE
    .\Invoke-IamAccessKeyRetirement.ps1 -Mode Deactivate -InventoryPath '.\iam-audit\access-keys-111122223333.csv' -MinimumUnusedDays 30 -WhatIf

.EXAMPLE
    .\Invoke-IamAccessKeyRetirement.ps1 -Mode Delete -InventoryPath '.\iam-audit\access-keys-111122223333.csv' -MinimumUnusedDays 60 -UserName 'jdoe'

.NOTES
    Changes configuration. Deactivates or deletes IAM user access keys in the AWS account of the
    AWS CLI profile. Needs AWS CLI v2 in PATH and a principal allowed iam:ListAccessKeys,
    iam:GetAccessKeyLastUsed, iam:UpdateAccessKey and iam:DeleteAccessKey.
    Run it on an admin workstation after the key owners have moved to IAM Identity Center.
#>
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')]
param(
    [Parameter(Mandatory = $true)]
    [ValidateSet('Deactivate', 'Delete')]
    [string]$Mode,

    [Parameter(Mandatory = $true)]
    [ValidateScript({ Test-Path -Path $_ -PathType Leaf })]
    [string]$InventoryPath,

    [Parameter(Mandatory = $true)]
    [ValidateRange(1, 3650)]
    [int]$MinimumUnusedDays,

    [string[]]$UserName = @(),

    [string]$AwsProfile
)

Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'

if ($null -eq (Get-Command -Name 'aws' -ErrorAction SilentlyContinue)) {
    throw 'AWS CLI v2 not found in PATH.'
}

function Invoke-AwsCli {
    param([string[]]$Arguments)
    $allArguments = @($Arguments) + @('--output', 'json')
    if ($AwsProfile) { $allArguments += @('--profile', $AwsProfile) }
    $output = & aws @allArguments
    if ($LASTEXITCODE -ne 0) {
        throw "aws $($Arguments -join ' ') failed with exit code $LASTEXITCODE."
    }
    $text = ($output | Out-String).Trim()
    if ($text) { return ($text | ConvertFrom-Json) }
    return $null
}

function ConvertTo-UtcDate {
    param($Value)
    if ($null -eq $Value -or [string]$Value -eq '') { return $null }
    if ($Value -is [datetime]) { return $Value.ToUniversalTime() }
    return [datetime]::Parse([string]$Value, [System.Globalization.CultureInfo]::InvariantCulture, [System.Globalization.DateTimeStyles]::AdjustToUniversal)
}

$rows = @(Import-Csv -Path $InventoryPath)
if ($rows.Count -gt 0) {
    foreach ($column in @('user', 'access_key_id')) {
        if (@($rows[0].PSObject.Properties.Name) -notcontains $column) {
            throw "Column '$column' not found in $InventoryPath."
        }
    }
}
if ($UserName.Count -gt 0) {
    $rows = @($rows | Where-Object { $UserName -contains $_.user })
}

$now = (Get-Date).ToUniversalTime()

foreach ($row in $rows) {
    $user = $row.user
    $keyId = $row.access_key_id

    $listed = Invoke-AwsCli -Arguments @('iam', 'list-access-keys', '--user-name', $user)
    $key = @($listed.AccessKeyMetadata | Where-Object { $_.AccessKeyId -eq $keyId })
    if ($key.Count -eq 0) {
        [pscustomobject]@{ User = $user; AccessKeyId = $keyId; Status = 'NotFound'; UnusedDays = $null; Action = $Mode; Result = 'Skipped: key not found' }
        continue
    }
    $status = $key[0].Status

    $usage = Invoke-AwsCli -Arguments @('iam', 'get-access-key-last-used', '--access-key-id', $keyId)
    $lastUsed = $null
    if (@($usage.AccessKeyLastUsed.PSObject.Properties.Name) -contains 'LastUsedDate') {
        $lastUsed = ConvertTo-UtcDate -Value $usage.AccessKeyLastUsed.LastUsedDate
    }
    $since = if ($null -ne $lastUsed) { $lastUsed } else { ConvertTo-UtcDate -Value $key[0].CreateDate }
    $unusedDays = [int][math]::Floor(($now - $since).TotalDays)

    if ($unusedDays -lt $MinimumUnusedDays) {
        $result = "Skipped: used or created $unusedDays day(s) ago"
    }
    elseif ($Mode -eq 'Deactivate' -and $status -ne 'Active') {
        $result = "Skipped: status is already $status"
    }
    elseif ($Mode -eq 'Delete' -and $status -ne 'Inactive') {
        $result = "Skipped: status is $status; deactivate it first"
    }
    elseif ($Mode -eq 'Deactivate') {
        if ($PSCmdlet.ShouldProcess("$user / $keyId", "Deactivate access key unused for $unusedDays days")) {
            $null = Invoke-AwsCli -Arguments @('iam', 'update-access-key', '--user-name', $user, '--access-key-id', $keyId, '--status', 'Inactive')
            $result = 'Deactivated'
        }
        else {
            $result = 'Not changed'
        }
    }
    else {
        if ($PSCmdlet.ShouldProcess("$user / $keyId", "Delete inactive access key unused for $unusedDays days (cannot be undone)")) {
            $null = Invoke-AwsCli -Arguments @('iam', 'delete-access-key', '--user-name', $user, '--access-key-id', $keyId)
            $result = 'Deleted'
        }
        else {
            $result = 'Not changed'
        }
    }

    [pscustomobject]@{ User = $user; AccessKeyId = $keyId; Status = $status; UnusedDays = $unusedDays; Action = $Mode; Result = $result }
}

Preview the first pass with -WhatIf:

.\Invoke-IamAccessKeyRetirement.ps1 -Mode Deactivate -InventoryPath '.\iam-audit\access-keys-111122223333.csv' -MinimumUnusedDays 30 -UserName 'jdoe', 'legacy-admin' -WhatIf

Example output (the values are illustrative):

User        : jdoe
AccessKeyId : AKIAIOSFODNN7EXAMPLE
Status      : Active
UnusedDays  : 2
Action      : Deactivate
Result      : Skipped: used or created 2 day(s) ago

What if: Performing the operation "Deactivate access key unused for 41 days" on target "legacy-admin / AKIAI44QH8DHBEXAMPLE".
User        : legacy-admin
AccessKeyId : AKIAI44QH8DHBEXAMPLE
Status      : Active
UnusedDays  : 41
Action      : Deactivate
Result      : Not changed

Run it again without -WhatIf to deactivate, wait through at least one full business cycle (month-end jobs included), then run -Mode Delete. Each change is an UpdateAccessKey or DeleteAccessKey event.

Remove console passwords the same way. This command changes configuration; to undo it, you set a new password with aws iam create-login-profile:

aws iam delete-login-profile --user-name legacy-admin

Step 7: Centralize root access for member accounts

Every member account has its own root user with full access to that account. With centralized root access, the management account or a delegated administrator for IAM can delete member account root credentials and run a short list of root-only tasks without them.

AWS's centralized root access page lists the prerequisites: accounts managed in AWS Organizations, trusted access for IAM, and the IAM and Organizations permissions it names. In the IAM console, choose Root access management > Enable, select Root credentials management and Privileged root actions in member accounts, and optionally register a delegated administrator for IAM. AWS recommends an account meant for security or management.

The CLI equivalent runs in the management account and changes configuration:

aws organizations enable-aws-service-access --service-principal iam.amazonaws.com
aws iam enable-organizations-root-credentials-management
aws iam enable-organizations-root-sessions

Then remove the credentials. For each member account, choose Root access management, select the account, then Take privileged action > Delete root credentials. That removes the root password, access keys and signing certificates and deactivates MFA.

Afterward, the member account can't sign in as root or recover the root password. New accounts created in the organization have no root user credentials by default.

When a root-only task comes up, the privileged session (sts:AssumeRoot) lasts at most 15 minutes and is scoped to one AWS managed task policy. Each session is an AssumeRoot event, watched by the AssumeRoot member account session rules.

Root user best practices for the management account

Centralized root access applies to member accounts, so the management account's own root user still needs its own protection. AWS requires MFA on the root user of every account type, recommends registering more than one MFA device, and advises against root access keys. The AWS root account risk entry explains what a compromised root user can do.

Verify

Check the result from four sides: remaining IAM credentials, Identity Center access, CLI sign-in and root.

Check How Expected result
IAM user keys Run audit-iam-user-credentials.sh again Active keys only for documented exceptions; Console passwords without MFA: 0
Root user aws iam get-account-summary --query 'SummaryMap.[AccountAccessKeysPresent,AccountMFAEnabled]' 0 keys, MFA 1 in the management account
Centralized root access aws iam list-organizations-features EnabledFeatures lists RootCredentialsManagement and RootSessions
Identity Center assignments audit-identity-center-assignments.sh (below) Group assignments, apart from the management account; AdministratorAccess for a named few
CLI sign-in aws sts get-caller-identity --profile <profile> An assumed role whose name starts with AWSReservedSSO_
Long-term key use First KQL query in Monitor and detect No rows apart from the documented exceptions

The assignment export is read-only. Run it in the management account or the delegated administrator account, as a principal with AWSSSOReadOnly and AWSSSODirectoryReadOnly:

#!/usr/bin/env bash
# audit-identity-center-assignments.sh
#
# Purpose:  Read-only export of the IAM Identity Center permission sets and their account
#           assignments: one row per permission set, account and assigned user or group,
#           with the session duration, the attached AWS managed policies and the name of
#           the user or group.
# Mode:     Read-only. Makes no change in AWS. Writes one CSV file.
# Needs:    AWS CLI v2. Run in the Organizations management account or the Identity Center
#           delegated administrator account, as a principal with the AWSSSOReadOnly and
#           AWSSSODirectoryReadOnly AWS managed policies (or the equivalent sso:List*,
#           sso:Describe* and identitystore:Describe* actions).
# Run on:   AWS CloudShell or an admin workstation, in the Region where Identity Center runs.
# Usage:    ./audit-identity-center-assignments.sh <output-csv> [profile] [region]
#           ./audit-identity-center-assignments.sh ./idc-assignments.csv
#           ./audit-identity-center-assignments.sh ./idc-assignments.csv idc-admin us-east-1

set -euo pipefail

OUT_FILE="${1:?usage: audit-identity-center-assignments.sh <output-csv> [profile] [region]}"
PROFILE="${2:-}"
REGION="${3:-}"

aws_cli() {
  local opts=()
  if [[ -n "$PROFILE" ]]; then opts+=(--profile "$PROFILE"); fi
  if [[ -n "$REGION" ]]; then opts+=(--region "$REGION"); fi
  aws ${opts[@]+"${opts[@]}"} "$@"
}

instance="$(aws_cli sso-admin list-instances --query 'Instances[0].[InstanceArn,IdentityStoreId]' --output text)"
read -r INSTANCE_ARN STORE_ID <<< "$instance"
if [[ -z "${INSTANCE_ARN:-}" || "$INSTANCE_ARN" == "None" ]]; then
  echo "No IAM Identity Center instance found for this account and Region." >&2
  exit 1
fi

echo "permission_set,session_duration,managed_policies,admin_access,account_id,principal_type,principal_name,principal_id" > "$OUT_FILE"
rows=0
admin_rows=0
user_rows=0
for ps_arn in $(aws_cli sso-admin list-permission-sets --instance-arn "$INSTANCE_ARN" --query 'PermissionSets[]' --output text); do
  details="$(aws_cli sso-admin describe-permission-set --instance-arn "$INSTANCE_ARN" \
    --permission-set-arn "$ps_arn" --query 'PermissionSet.[Name,SessionDuration]' --output text)"
  read -r ps_name session <<< "$details"
  policies="$(aws_cli sso-admin list-managed-policies-in-permission-set --instance-arn "$INSTANCE_ARN" \
    --permission-set-arn "$ps_arn" --query 'AttachedManagedPolicies[].Name' --output text | tr '\t' ';')"
  admin="no"
  if [[ ";$policies;" == *";AdministratorAccess;"* ]]; then
    admin="yes"
  fi
  for account in $(aws_cli sso-admin list-accounts-for-provisioned-permission-set \
      --instance-arn "$INSTANCE_ARN" --permission-set-arn "$ps_arn" --query 'AccountIds[]' --output text); do
    assignments="$(aws_cli sso-admin list-account-assignments --instance-arn "$INSTANCE_ARN" \
      --account-id "$account" --permission-set-arn "$ps_arn" \
      --query 'AccountAssignments[].[PrincipalType,PrincipalId]' --output text)"
    while read -r principal_type principal_id; do
      if [[ -z "${principal_type:-}" ]]; then
        continue
      fi
      if [[ "$principal_type" == "USER" ]]; then
        name="$(aws_cli identitystore describe-user --identity-store-id "$STORE_ID" \
          --user-id "$principal_id" --query UserName --output text)"
        user_rows=$((user_rows + 1))
      else
        name="$(aws_cli identitystore describe-group --identity-store-id "$STORE_ID" \
          --group-id "$principal_id" --query DisplayName --output text)"
      fi
      echo "\"$ps_name\",$session,\"$policies\",$admin,$account,$principal_type,\"$name\",$principal_id" >> "$OUT_FILE"
      rows=$((rows + 1))
      if [[ "$admin" == "yes" ]]; then
        admin_rows=$((admin_rows + 1))
      fi
    done <<< "$assignments"
  done
done

echo "Instance:                $INSTANCE_ARN"
echo "Report:                  $OUT_FILE"
echo "Assignments:             $rows"
echo "With AdministratorAccess: $admin_rows"
echo "Made to users directly:  $user_rows"
./audit-identity-center-assignments.sh ./idc-assignments.csv idc-admin us-east-1

Example output (the values are illustrative):

Instance:                arn:aws:sso:::instance/ssoins-0000000000000000
Report:                  ./idc-assignments.csv
Assignments:             42
With AdministratorAccess: 5
Made to users directly:  3

Roll back

Most of the move is reversible; deleted keys and a change of identity source to Active Directory aren't, and a deleted password can only be replaced with a new one.

Change How to roll back Notes
Access key deactivated aws iam update-access-key --user-name <user> --access-key-id <key-id> --status Active AWS says a deactivated key can be activated again
Access key deleted Can't be undone Create a new key only for an approved exception and record its owner
Console password deleted aws iam create-login-profile with a new password The old password is gone
Account assignment Remove it in the console or with aws sso-admin delete-account-assignment When the last assignment of a permission set in an account goes, Identity Center deletes the role; a new assignment creates a role with a new suffix, so update resource policies that name it
Identity source changed to Active Directory Can't be undone AWS permanently deletes users, groups, memberships and assignments; back up and reapply them
Identity source changed between the Identity Center directory and an external IdP Change it back AWS keeps users, groups, memberships and assignments in this direction
MFA settings Settings > Authentication > Multi-factor authentication > Configure Restore the previous values from your change record
Member account root credentials deleted Root access management > Take privileged action > Allow password recovery Then the owner of the root email inbox resets the password
Centralized root access aws iam disable-organizations-root-credentials-management and aws iam disable-organizations-root-sessions Run Allow password recovery first for any member account that needs its root user back

Keep the Step 1 CSV files as the record of which users held which keys before the change.

Monitor and detect

Watch three things in CloudTrail: changes to who can reach accounts through Identity Center, new long-term credentials, and root activity. AWS's Identity Center CloudTrail page maps each event to its source: sso.amazonaws.com for Identity Center calls and the OIDC CreateToken call, identitystore.amazonaws.com for public Identity Store calls and sso-directory.amazonaws.com for the console's directory calls.

CloudTrail event Event source What it means Related rules
CreateAccountAssignment, AttachManagedPolicyToPermissionSet, PutInlinePolicyToPermissionSet sso.amazonaws.com Someone gained or widened access to an account Permission set and assignment change rules
PutMfaDeviceManagementForDirectory, UpdateSSOConfiguration sso.amazonaws.com Identity Center MFA or instance settings changed (console operations) Identity Center MFA settings rules
CreateUser, CreateGroupMembership identitystore.amazonaws.com; the console's calls, such as AddMemberToGroup, use sso-directory.amazonaws.com A user or group member was added to Identity Center Identity Center user or group created rules
CreateToken sso.amazonaws.com An OIDC access token was issued, for example to the CLI Device code phishing rules
CreateAccessKey iam.amazonaws.com A new long-term key appeared after the cleanup Access key created for another user rules
ConsoleLogin signin.amazonaws.com A console sign-in; after the move, records for IAM users and the root user need a reason Console sign-in without MFA rules
AssumeRoot and any record with userIdentity.type Root sts.amazonaws.com and others Root work in a member account AWS root user activity rules

The first query lists API calls signed with long-term IAM user access keys. It reads the AWSCloudTrail table that Microsoft Sentinel's AWS connector fills; access key IDs that start with AKIA are long-term keys and ASIA marks temporary STS keys.

// API calls signed with long-term IAM user access keys (AKIA prefix), per account, user and key.
// Needs CloudTrail logs in the AWSCloudTrail table (Microsoft Sentinel AWS connector).
AWSCloudTrail
| where TimeGenerated > ago(30d)
| where UserIdentityType == "IAMUser"
| where UserIdentityAccessKeyId startswith "AKIA"
| summarize Calls = count(), Services = make_set(EventSource, 20), SourceIps = make_set(SourceIpAddress, 20),
    FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated)
    by RecipientAccountId, UserIdentityUserName, UserIdentityAccessKeyId
| order by LastSeen desc

The second query lists Identity Center, credential and root changes for daily review.

// Identity Center access changes, new long-term credentials and root activity to review.
let WatchedEvents = dynamic(["CreateAccountAssignment", "AttachManagedPolicyToPermissionSet",
    "PutInlinePolicyToPermissionSet", "DeletePermissionsBoundaryFromPermissionSet",
    "PutMfaDeviceManagementForDirectory", "UpdateSSOConfiguration", "DeleteMfaDeviceForUser",
    "CreateAccessKey", "UpdateAccessKey", "CreateLoginProfile", "AssumeRoot"]);
AWSCloudTrail
| where TimeGenerated > ago(7d)
| where EventName in (WatchedEvents) or UserIdentityType == "Root"
| project TimeGenerated, RecipientAccountId, EventSource, EventName, UserIdentityType,
    UserIdentityArn, SourceIpAddress, ErrorCode, RequestParameters
| order by TimeGenerated desc

New IAM users and console passwords after the move deserve the same attention; the rules for console passwords created for IAM users cover CreateLoginProfile events.

Troubleshooting

Most problems come from where you make a change, missing attributes or an old CLI habit.

Symptom Cause Fix
Cannot perform the operation on the protected role 'AWSReservedSSO_...' Roles that Identity Center creates can be changed only through Identity Center Edit the permission set and reprovision it
A changed permission set doesn't reach the accounts The CLI reference says the IAM policies on existing roles aren't updated automatically Run aws sso-admin provision-permission-set with --target-type ALL_PROVISIONED_ACCOUNTS
A permission set with a customer managed policy doesn't work in one account AWS requires a policy with the same name and path in each assigned account Create the policy in every target account before you assign the permission set
The delegated administrator can't assign access to the management account That task is reserved for the management account Assign it from the management account with a dedicated permission set
An external IdP user never appears in Identity Center A first name, last name, user name or display name is missing, or the SCIM token expired Fill the attributes; rotate the token before its one-year validity ends
SCIM users can't sign in The SAML NameID differs from the user name SCIM maps Send the same attribute for both
Users lose the access portal after leaving Active Directory The default awsapps.com portal URL changes Use the dual-stack portal URL and update bookmarks and allow-lists
Block their sign-in is set but some users skip MFA Context-aware prompting honors trusted devices Switch to Every time they sign in (always-on)
aws sso login waits on a remote host PKCE needs a browser on the same device Use --use-device-code on that host only
A job breaks after a key is deactivated Something still used the key, for example a monthly task Reactivate the key, find the caller in CloudTrail by its access key ID, then move it to a role

How Forestall helps

Forestall collects the IAM Identity Center instance once, from the management account or the delegated administrator, and shows each of its permission sets with its users, groups, policies, AWSReservedSSO_ roles and accounts. The AWS_SSO_ASSIGN_PERMISSION_SET edge points from an IAM principal that can call sso:CreateAccountAssignment to the account it could take over with a privileged permission set. AWS_HAS_ACCESS_KEY shows IAM users that still hold long-term keys. Identity Attack Surface Management maps these AWS identities, access keys and accounts in the same agentless, read-only graph as the rest of your environment.

Frequently Asked Questions

Is AWS SSO the same as AWS IAM Identity Center?

Yes, AWS renamed AWS Single Sign-On to AWS IAM Identity Center on July 26, 2022, and it is the same service. For backward compatibility, AWS kept the old names in the CLI (aws configure sso, sso, sso-admin, sso-oidc and identitystore), in managed policies that start with AWSSSO, in CloudFormation resources that start with AWS::SSO and in console and documentation URLs.

How do I get the SSO start URL for the AWS CLI?

To find the SSO start URL, sign in to the AWS access portal, choose Access keys next to the permission set you use, and open the IAM Identity Center credentials method. It shows the SSO Start URL and the SSO Region that aws configure sso asks for. From AWS CLI version 2.22.0 you can also use the Issuer URL, shown on the IAM Identity Center console Dashboard and on the Settings page.

Where does aws sso login store credentials?

The AWS CLI caches the IAM Identity Center token as a file under ~/.aws/sso/cache. It uses that token to fetch credentials for the role in your profile and renews them while the Identity Center session is valid. Run aws sso logout to delete the cached credentials. Protect the folder like any other credential store.

Is AWS IAM Identity Center free?

Yes, AWS offers IAM Identity Center at no extra charge (as of November 2026). Related services can still cost money: a multi-Region instance creates a customer managed KMS key, and AWS KMS charges apply. Creating an AWS organization for an organization instance also upgrades a free tier account to a paid plan, and its free tier credits expire at once.

Do I still need IAM users after moving to IAM Identity Center?

After the move to IAM Identity Center, you need IAM users only for use cases that require long-term credentials, such as the ones AWS lists: workloads that can't use IAM roles, third-party AWS clients that don't support Identity Center, and CodeCommit or Amazon Keyspaces credentials. Give each remaining IAM user an owner, least privilege and a key rotation plan. Workloads on AWS compute should use IAM roles. Each account still has a root user, which you secure separately.

How long does an IAM Identity Center session last?

Two settings control how long an IAM Identity Center session lasts. The permission set session duration decides how long console and CLI role sessions last: one hour by default, up to 12 hours. The AWS access portal session decides how long a user stays signed in before authenticating again: eight hours by default, up to 90 days. Keep both short for administrator permission sets.

References

Share This Article, Secure Your Friends!

See your identity exposure clearly.

Start with a 1-day Proof of Value in your own environment.