Skip to content
Least Privilege Principle

Least privilege for service identities in AWS means scoping roles that services assume and retiring access keys

Service identities in AWS are the roles and IAM users that services, integrations and third-party tools use to act in an account. AWS's documentation, read 16 Nov 2026, covers service-linked roles, service roles and access keys. This guide lists the controls, the steps and the measures.

Open the calculator ยท All guides

Service identities are service-linked roles, service roles and IAM users with keys

This guide uses service identity for a non-human identity that an AWS service or an outside integration uses, as distinct from code running on your own compute, which the workload identities guide covers.

A service-linked role is a role predefined by an AWS service. AWS's documentation says the linked service defines its permissions, an IAM administrator can view but not edit them, and the permissions policy cannot be attached to any other IAM entity. Your control is whether the service may create the role, and monitoring what it does.

A service role is a role a service assumes on your behalf. AWS says an IAM administrator can create, modify and delete it, so its permissions are yours to scope. Bedrock Agents and Lambda use roles of this kind.

IAM users with long-term access keys complete the set. AWS's best practices page names workloads that cannot use roles, third-party clients that do not support IAM Identity Center and some service-specific credentials as the cases where they remain.

Access Analyzer and last accessed data show which service roles are idle

The IAM Access Analyzer unused access analyzer reports unused roles, unused access keys and unused permissions for roles and users in the usage window you choose. AWS says it reviews last accessed information for all roles in the organization to do this.

For keys, AWS tells you to use access last used information to update and remove them safely, and says you can keep at most two access keys per IAM user.

For roles you own, policy generation reads CloudTrail for up to 90 days and returns a template of the services and actions used. AWS notes that the service role used by Access Analyzer must have access to your CloudTrail trail. That makes policy generation a practical way to cut a service role that was written broadly during a project.

Service control policies and resource control policies add a ceiling across accounts. AWS states that they grant nothing by themselves, so they limit service roles without replacing the scoping work. The ceiling idea is covered under what least privilege access means.

Steps to bring service identities to least privilege

  • Inventory roles by who assumes them: AWS services, third-party vendors, CI/CD systems, other accounts. Mark service-linked roles separately because their permissions are fixed.
  • List IAM users that act as service accounts. For each, record the key age, the access last used date and the owner.
  • Replace keys with roles wherever the caller can assume one: IAM Roles Anywhere for certificate holders, AssumeRoleWithWebIdentity for OIDC tokens, AssumeRoleWithSAML for SAML (all listed in AWS's best practices).
  • Delete keys and roles that the unused access analyzer reports as unused, after a notice period to the owner.
  • Generate a policy for each service role you own, review the action list, add resource ARNs and conditions, and attach it.
  • Where developers may create their own roles, require a permissions boundary so delegated roles cannot exceed the maximum you set.
  • Review again on a fixed date. Roles drift back to broad grants when a new feature needs one more action.

Permissions and credentials to avoid on service identities

Policy or credentialDocumented reason (AWS, read 16 Nov 2026)Use instead
AdministratorAccess on a service roleAWS describes it as all actions on all resources, which turns any failure of the service into account-wide access.A policy generated from the role's CloudTrail activity.
IAM user access keys for an integration that can assume a roleAWS recommends temporary credentials and says IAM users with access keys are an account security risk.A role with Roles Anywhere, web identity or SAML.
Keys saved in the shared credentials fileAWS says such keys are stored in plaintext.A role session from a credential provider.
Keys that are never rotated or reviewedAWS says to update keys when needed and to use access last used information to remove them safely.A scheduled review driven by unused access findings.
No permissions boundary on delegated rolesAWS says a boundary sets the maximum permissions a delegated identity-based policy can grant.A permissions boundary on every role that developers create.

Measure idle roles, idle keys and unused actions

Track four counts per account: service roles with no activity in the window, IAM user keys with no activity in the window, service roles with AdministratorAccess, and for each service role the actions granted against the actions last accessed. AWS's action-level data covers management actions, so record that data events are not part of the comparison.

A falling count of idle roles and keys shows clean-up is happening. A flat count of service roles with administrator policies shows the work is stuck at the hardest step. See how privilege creep builds and the routes to least privilege for what to do when the manual loop stops scaling.

Related guides: Azure service identities and Google Cloud service identities.

Sources

  1. AWS IAM User Guide: Security best practices in IAM, read 16 Nov 2026
  2. AWS IAM User Guide: Service-linked roles, read 16 Nov 2026
  3. AWS IAM User Guide: Using IAM Access Analyzer, read 16 Nov 2026
  4. AWS IAM User Guide: IAM Access Analyzer findings, read 16 Nov 2026
  5. AWS IAM User Guide: Refine permissions using last accessed information, read 16 Nov 2026
  6. AWS IAM User Guide: IAM Access Analyzer policy generation, read 16 Nov 2026
  7. AWS IAM User Guide: Manage access keys for IAM users, read 16 Nov 2026
  8. AWS IAM User Guide: AWS managed policies for job functions, read 16 Nov 2026
  9. AWS IAM User Guide: IAM roles, read 16 Nov 2026

Last reviewed 16 Nov 2026.