SEC03-BP01 Grant least privilege access in workload components
Every component in a workload runs with some set of permissions. When those permissions exceed what a component needs, each component becomes a wider path for an unauthorized user to move through. Grant each component only the permissions its function requires, and remove access as functions change. This limits the impact of any single component under unauthorized control to what that component could already do.
Desired outcome:
-
Each of your workload components or services runs under a distinct identity scoped to the permissions its function requires.
-
Your components use temporary credentials instead of long-lived keys wherever the service supports them.
-
You detect unused permissions and permission drift automatically, and you refine access on a defined cadence.
-
You keep permission ownership clear, with your application and infrastructure teams agreeing on who requests, approves, and revokes access.
Common anti-patterns:
-
Teams share a single service account or role across multiple components, which breaks separation of concerns.
-
Components carry administrative access that lets them modify their own permission sets.
-
Services deploy with broad permissions rather than function-specific access.
-
Teams leave permissions in place after the features or integrations that needed them are removed.
-
Manual permission assignment cannot keep pace as the number of components grows.
-
Development environments run with the same permissions granted to production.
Benefits of establishing this best practice:
-
A component under unauthorized control exposes only the narrow set of actions it was granted, which limits blast radius.
-
Automated analysis of granted compared to used permissions makes over-provisioning visible.
-
Function-scoped identities produce clearer audit trails, because each action traces to a specific component.
-
Defining permissions as code lets you review and version access changes alongside application changes.
-
Removing unused access on a cadence keeps permissions aligned with current function.
Level of risk exposed if this best practice is not established: High
Implementation guidance
Least privilege at the component level treats permissions as an attack surface. A web service that only reads one database table and writes logs does not need broad database or logging access. If an unauthorized user gains control of that service, they inherit exactly what you granted it. Scoping permissions to the component's function turns a potential full-account incident into a contained one.
The process of determining the minimum set of permissions is the hard part. A more reliable approach is to derive permissions from observed activity: run the component, capture which actions it calls, and generate a policy from that record. Even then, permissions can decay as features are removed and integrations are deprecated, and the grants that supported those features and integrations stay behind as permission drift. Without continuous analysis, the gap between granted and used permissions widens.
Treat least privilege as continuous work across your environments,
because cleaning up access already granted does not stop the next
code change from reintroducing broad permissions. Tighten access
as code promotes toward production. In sandbox and development
environments, reduce the friction of manually writing policies
with
IAM Policy Autopilot
Give each component its own identity. Shared roles blur audit trails and force the permission set to be the union of every consumer's needs. Where the runtime supports it, attach a role to the compute itself and use temporary credentials that rotate automatically, so no long-lived key exists that could be exposed. For service-to-service access, resource-based policies let the target resource state which principals it trusts, complementing the identity-based policies attached to the caller.
Ownership determines whether least privilege holds over time. Infrastructure teams typically set the outer boundary with organization-wide controls and permission boundaries, and application teams define the specific grants within that boundary. When neither side clearly owns refinement, permissions accumulate. Agree early on who requests, approves, and revokes access, and treat that process as part of the workload's operating model. Guardrails such as service control policies and permission boundaries limit what can be granted, but they do not replace scoping each component.
IAM Access Analyzer generates policies from access activity recorded in AWS CloudTrail, so policies reflect real usage. Its unused access analysis flags roles, keys, and permissions that have gone idle. Defining roles and policies through AWS CloudFormation or the AWS CDK puts every permission change under review and version control.
Implementation steps
-
Map the permissions each component needs: Document the function of each component and the specific actions and resources it requires. Analyze AWS CloudTrail to see which actions each component actually calls, and use IAM Access Analyzer policy generation to derive a policy from that activity. Confirm the result stays within the service control policies your infrastructure team defines.
-
Generate baseline policies in development without slowing developers: In sandbox and development environments, use IAM Policy Autopilot
to generate a baseline identity-based policy from the AWS SDK calls in your application code, either through its CLI or its MCP server integration with an AI coding assistant. This removes the friction that pushes teams toward over-granting when they write policies manually. Because these policies favor working functionality over minimal permissions, and do not cover resource-based policies, treat the output as a reviewed starting point rather than a final grant, and refine it in the steps below. -
Assign a distinct identity with temporary credentials to each component: Attach a scoped IAM role to each component rather than sharing one. For containers, use task roles in Amazon ECS or IAM roles for service accounts in Amazon EKS. For instances, use Amazon EC2 instance profiles. Store any unavoidable secrets in AWS Secrets Manager with automatic rotation enabled.
-
Set boundaries between components: Control service-to-service access with resource-based policies that name the principals each resource trusts. Apply permissions boundaries so a team can create roles without granting more than the boundary allows. Confirm cross-account paths with your security team before enabling them.
-
Monitor permission use and errors: Track access-denied errors and service interactions with Amazon CloudWatch, and use AWS X-Ray to trace permission failures across components in distributed workloads. Set alerting thresholds with your infrastructure team so denied calls surface as signals for refinement rather than noise.
-
Gate least privilege through your promotion pipeline: Define roles and policies as code with AWS CloudFormation or the AWS CDK so every permission change is reviewed and versioned. As a change promotes toward production, tighten access at each stage rather than only after deployment. Enable IAM Access Analyzer unused access analysis to identify permissions the component has not exercised, and remove them before promoting to the next environment. Add IAM Access Analyzer custom policy checks to the pipeline as gates: CheckNoNewAccess blocks a change that would widen access beyond the current policy without explicit review, CheckNoPublicAccess confirms a resource-based policy does not expose a resource publicly, and CheckAccessNotGranted fails the build when a policy grants sensitive actions you have designated off-limits, such as write access to a regulated data store. Validate changes with the IAM policy simulator before deployment, and continue to review unused access on a recurring cadence in production.
Resources
Related best practices:
Related documents:
Related examples:
Related tools: