Designing IAM Roles and Policies for ML and AI
This lesson explains how to design the IAM identities that every ML job, endpoint, notebook, knowledge base and agent acts with, and the permissions of the people who use them.
Learning outcomes
After completing this lesson, you will be able to:
- Configure execution roles and service roles.
- Grant iam:PassRole narrowly.
- Enforce secure configurations with SageMaker condition keys.
Execution roles and service roles
SageMaker AI training jobs, processing jobs, endpoints, pipelines and Studio domains run with an execution role whose trust policy allows sagemaker.amazonaws.com to assume it. The role's permissions decide which S3 data, ECR images, KMS keys and other services the job can use. Bedrock features have their own service roles: a knowledge base role reads data sources and calls the embedding model and vector store; a model customisation role reads training data and writes output; an evaluation job role reads datasets and invokes models; a Bedrock agent role invokes its model. Lambda functions used as agent tools have execution roles too.
Execution roles
Permissions for people: iam:PassRole
A user or pipeline that creates a SageMaker AI job or Bedrock resource must be allowed to pass the execution role to the service with iam:PassRole. Restricting PassRole to specific role ARNs, with the condition iam:PassedToService, stops users from escalating privileges by attaching a more powerful role to a job. Missing PassRole is one of the most common causes of AccessDenied when starting training jobs.
{
"Effect": "Allow",
"Action": "iam:PassRole",
"Resource": "arn:aws:iam::111122223333:role/sagemaker-training-churn",
"Condition": {"StringEquals": {"iam:PassedToService": "sagemaker.amazonaws.com"}}
}Condition keys and personas
SageMaker AI condition keys enforce secure configurations in IAM or SCPs: sagemaker:VpcSubnets and sagemaker:VpcSecurityGroupIds require VPC placement; sagemaker:NetworkIsolation and sagemaker:InterContainerTrafficEncryption require isolation and encryption; sagemaker:VolumeKmsKey and sagemaker:OutputKmsKey require KMS keys; sagemaker:InstanceTypes limits instance types. For Bedrock, policies can limit bedrock:InvokeModel to specific model or inference profile ARNs and require a guardrail with bedrock:GuardrailIdentifier. SageMaker Role Manager creates roles for personas such as data scientist and MLOps engineer from templates. The following table summarises the identities.
| Identity | Used by | Typical permissions |
|---|---|---|
| SageMaker AI execution role | Training, processing, endpoints, pipelines | S3 prefixes, ECR pull, KMS, CloudWatch Logs |
| Knowledge base service role | Bedrock Knowledge Bases | Data source read, embedding model, vector store |
| Customization job role | Bedrock fine-tuning | Training data read, output write |
| Agent / tool roles | Bedrock Agents, AgentCore, Lambda tools | Only the APIs each tool needs |
| Human roles (personas) | Data scientists, MLOps engineers | Create jobs, PassRole for approved roles |
The following diagram shows where each security rule for SageMaker AI training jobs is enforced when a data scientist calls the API.

A policy that is too loose
Enforcing secure training jobs
A security team requires that every training job in the ML accounts runs in the VPC, with network isolation and KMS-encrypted volumes, and that data scientists can use only the approved execution role.
- An SCP denies
sagemaker:CreateTrainingJobwhensagemaker:VpcSubnetsis absent orsagemaker:NetworkIsolationis false, or whensagemaker:VolumeKmsKeyis absent. - The data scientist persona role allows
iam:PassRoleonly onsagemaker-training-*roles passed to SageMaker AI. - Execution roles allow S3 access only to the team's prefixes and decrypt only with the team's KMS key.
Guidance documents alone would not stop a misconfigured job; condition keys in SCPs enforce the rules at the API.
Which permission does a user need to create a SageMaker training job with an execution role?
Show answer
iam:PassRole on that execution role.
Exam Tips
Remember for the exam
- SageMaker AI jobs and endpoints act with an execution role trusted by sagemaker.amazonaws.com.
- Creating jobs requires iam:PassRole on the execution role.
- Enforce VPC, isolation and KMS with SageMaker AI condition keys in IAM or SCPs.
- Limit Bedrock invocation to approved model ARNs; require guardrails with a condition key.
- Persona roles from SageMaker Role Manager simplify least privilege.