๐ AWS App Runner Deployment - The Permission Guide โ
Core Concept: Three Permission Layers โ
Your User โ Service Role โ Docker Image
(ai-engineer) (AppRunnerECR) (in ECR)
| | |
|--PassRole permission--->| |
|--Pull permission-->|Setup Steps โ
1. Create IAM Group with Permissions (as Root) โ
IAM โ Groups โ Create group: BroadAIEngineerAccess
Attach AWS managed policies:
AmazonEC2ContainerRegistryFullAccess- Push/pull Docker imagesAWSAppRunnerFullAccess- Create App Runner servicesCloudWatchLogsFullAccess- View logsIAMUserChangePassword- Change own password
2. Create IAM User โ
IAM โ Users โ Create user: ai-engineer
- Enable console access
- Add to group:
BroadAIEngineerAccess
3. Create Service Role (CRITICAL) โ
IAM โ Roles โ Create role
- Trusted entity: AWS service โ App Runner
- Attach policy:
AWSAppRunnerServicePolicyForECRAccess - Role name:
AppRunnerECRAccessRole
What it does: Allows App Runner to pull your Docker images from ECR
4. Add Inline Policy: View Roles โ
IAM โ Groups โ BroadAIEngineerAccess โ Create inline policy
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "iam:ListRoles",
"Resource": "*"
}
]
}Name: AllowListRoles
Why: User can see available roles in dropdowns
5. Add Inline Policy: PassRole (MOST CRITICAL) โ
Create another inline policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "iam:PassRole",
"Resource": "arn:aws:iam::YOUR_ACCOUNT_ID:role/AppRunnerECRAccessRole"
}
]
}Name: AllowPassAppRunnerRole
โ ๏ธ Replace YOUR_ACCOUNT_ID with your AWS account ID โ ๏ธ No extra spaces in the ARN!
Why: This is the bridge that lets your user assign the service role to App Runner
Permission Flow โ
โโโโโโโโโโโโโโโโโโโโ
โ ai-engineer โ Has: AWSAppRunnerFullAccess + PassRole
โโโโโโโโโโฌโโโโโโโโโโ
โ
โ Uses PassRole permission to assign โ
โ
โโโโโโโโโโผโโโโโโโโโโโโโโโโโโโ
โ AppRunnerECRAccessRole โ Has: AWSAppRunnerServicePolicyForECRAccess
โโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโ
โ
โ Pulls images from โ
โ
โโโโโโโโโโผโโโโโโโโโโโ
โ ECR Repository โ
โโโโโโโโโโโโโโโโโโโโโCommon Errors & Fixes โ
| Error | Cause | Fix |
|---|---|---|
not authorized to perform: iam:PassRole | Missing PassRole permission | Add AllowPassAppRunnerRole inline policy |
error occurred while fetching options | Missing ListRoles permission | Add AllowListRoles inline policy |
not authorized to perform: iam:CreateRole | User trying to create roles | Create roles as root, not as user |
After adding policies: Always sign out and back in to refresh permissions!
Security Rule: Never Use IAMFullAccess โ
โ IAMFullAccess = Complete account takeover risk
Instead use:
- โ Specific managed policies (App Runner, ECR)
- โ Narrow inline policies (ListRoles, PassRole)
- โ Principle of least privilege
Quick Deploy (After Permissions Set) โ
Build & Push to ECR: โ
docker build -t <PROJECT_NAME> .
aws ecr create-repository --repository-name <PROJECT_NAME> --region us-east-1
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin <YOUR_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com
docker tag <PROJECT_NAME>:latest <YOUR_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/<PROJECT_NAME>:latest
docker push <YOUR_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/<PROJECT_NAME>:latestReplace:
<PROJECT_NAME>with your actual project name (e.g.,prism,myapp,consultation-app)<YOUR_ACCOUNT_ID>with your 12-digit AWS account ID
Deploy to App Runner: โ
- Sign in as
ai-engineer - App Runner โ Create service
- Select ECR image from repository
- ECR access role: Select
AppRunnerECRAccessRoleโ PassRole used here - Configure & deploy
Verification Checklist โ
Group has these policies: โ
- โ
AmazonEC2ContainerRegistryFullAccess - โ
AWSAppRunnerFullAccess - โ
AllowListRoles(inline) - โ
AllowPassAppRunnerRole(inline)
Roles exist: โ
- โ
AppRunnerECRAccessRolewith trust forbuild.apprunner.amazonaws.com
Key Takeaway โ
The entire deployment hinges on three permissions:
- AWSAppRunnerFullAccess - User can create services
- PassRole - User can assign the ECR access role
- Service Role - App Runner can pull images
Without all three, deployment fails. Get permissions right = smooth deployment! ๐