Sub topic 4
Users and groups as assignment targets
This chapter assumes you know what an identity source is and what a permission set is, and that you can run AWS CLI commands. It covers the two kinds of principal you can assign to an account, and why you should almost always pick groups.
Principals in Identity Center
An account assignment combines three things: a principal, a permission set, and an AWS account. The principal is either a user or a group. Both live in the identity store attached to your Identity Center instance. They are separate from IAM users, which Identity Center does not use.
Where the principals come from depends on your identity source:
- Identity Center directory: you create users and groups in Identity Center itself, in the console or with the
identitystoreAPI. - External identity provider: a SCIM sync copies users and groups from your IdP. They are read-only in Identity Center, so you manage membership in the IdP.
- Active Directory: users and groups are synced from the directory.
Assignment calls take the principal's ID, not its name. The ID is a GUID such as a1b2c3d4-.... You must look it up first.
Creating and finding principals
With the Identity Center directory as your source, you can create a group and add a user from the CLI. The IDs come from get-group-id and get-user-id.
IDENTITY_STORE_ID=$(aws sso-admin list-instances --query 'Instances[0].IdentityStoreId' --output text)
GROUP_ID=$(aws identitystore create-group \
--identity-store-id "$IDENTITY_STORE_ID" \
--display-name Auditors \
--description "Read-only auditors" \
--query 'GroupId' --output text)
USER_ID=$(aws identitystore get-user-id \
--identity-store-id "$IDENTITY_STORE_ID" \
--alternate-identifier '{"UniqueAttribute":{"AttributePath":"UserName","AttributeValue":"[email protected]"}}' \
--query 'UserId' --output text)
aws identitystore create-group-membership \
--identity-store-id "$IDENTITY_STORE_ID" \
--group-id "$GROUP_ID" \
--member-id "{\"UserId\":\"$USER_ID\"}"If your source is an external IdP, the group already exists after the sync. In that case you only need the lookup by DisplayName, as in the assignment example in a later chapter.
Why groups are the better target
You can set --principal-type USER or --principal-type GROUP in create-account-assignment. Both work, but they behave differently over time:
| Aspect | Assign a user | Assign a group |
|---|---|---|
| Someone joins the team | New assignments for each account | Add one membership |
| Someone leaves | Find and delete every assignment | Remove one membership |
| Audit question "who has access?" | Scan all assignments | Read the group's members |
| Assignment count | Users × accounts × permission sets | Groups × accounts × permission sets |
A user who belongs to several groups gets the union of their assignments. Assigning to a group does not create roles per member. The account has one role for each permission set, and every member of the group signs in to that same role.
Things that catch people out
- Membership changes are not provisioning events. Adding a user to a group does not change any role in any account. The user gets access at their next sign-in.
- Existing sessions keep their access. Removing someone from a group does not end a session they already opened. It lasts until it expires, so a shorter session duration limits the exposure.
- Synced principals can't be edited. With an external IdP, changes you make in Identity Center are overwritten or rejected. Fix membership in the IdP.
- Names are not stable keys. Display names can be changed. Store GUIDs in automation where you can, and look names up only when you start.
Exercise
A contractor leaves. They were assigned individually as a USER to 40 accounts, while the rest of the team is in the Auditors group. Name two problems with the user-level approach, and say what you would change.
Show answer
Offboarding means finding and deleting 40 separate assignments, and an audit of who has access has to scan every assignment instead of one group's members. Assign the Auditors group to the accounts instead, put the contractor in that group, and offboard by removing one membership (or by disabling the user in the identity source). Any session the contractor already opened stays valid until it expires.