Skip to content

Commit 338615f

Browse files
fibanezbgagent
andauthored
fix: two bugs that prevent ECS Fargate from working (#494)
* fix two bugs that prevent ECS Fargate from working The bootstrap policy at cdk/src/bootstrap/policies/infrastructure.ts is missing iam:UpdateAssumeRolePolicy. When ECS is enabled, AgentSessionRole.admitComputeRole(ecsTaskRole) rewrites the SessionRole trust — fails at deploy time with 'User: cdk-...-cfn-exec-role is not authorized to perform: iam:UpdateAssumeRolePolicy'. cdk/src/handlers/shared/strategies/ecs-strategy.ts:93 has the boot command do sys.path.insert(0, '/app') and from entrypoint import run_task, but agent/Dockerfile copies the agent code to /app/src/. Container exits 1 immediately with 'ModuleNotFoundError: No module named entrypoint'. Easy to miss — the orchestrator just surfaces 'Essential container exited'; you have to dig into the ECS task's CloudWatch stream to see the actual error. Verified: uncommented EcsAgentCluster locally, set a repo to compute_type=ecs, submitted a smoke task on a Rust repo. cargo check ran clean inside the ECS container (exit 0, ~78s wall, $0.09). * docs: add iam:UpdateAssumeRolePolicy to DEPLOYMENT_ROLES golden Per @krokoko on PR #494 — the golden-baseline test compares the TypeScript policy source against the JSON blocks in DEPLOYMENT_ROLES.md. This adds the new action there and regenerates the Starlight mirror. --------- Co-authored-by: bgagent <bgagent@noreply.github.com>
1 parent 979ab69 commit 338615f

6 files changed

Lines changed: 6 additions & 1 deletion

File tree

cdk/bootstrap/bootstrap-template.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,7 @@ Resources:
821821
- iam:DeleteRole
822822
- iam:GetRole
823823
- iam:UpdateRole
824+
- iam:UpdateAssumeRolePolicy
824825
- iam:TagRole
825826
- iam:UntagRole
826827
- iam:ListRoleTags

cdk/bootstrap/policies/infrastructure.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"iam:DeleteRole",
3333
"iam:GetRole",
3434
"iam:UpdateRole",
35+
"iam:UpdateAssumeRolePolicy",
3536
"iam:TagRole",
3637
"iam:UntagRole",
3738
"iam:ListRoleTags",

cdk/src/bootstrap/policies/infrastructure.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export function infrastructurePolicy(): iam.PolicyDocument {
6666
'iam:DeleteRole',
6767
'iam:GetRole',
6868
'iam:UpdateRole',
69+
'iam:UpdateAssumeRolePolicy',
6970
'iam:TagRole',
7071
'iam:UntagRole',
7172
'iam:ListRoleTags',

cdk/src/handlers/shared/strategies/ecs-strategy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export class EcsComputeStrategy implements ComputeStrategy {
9090
const bootCommand = [
9191
'python', '-c',
9292
'import json, os, sys; '
93-
+ 'sys.path.insert(0, "/app"); '
93+
+ 'sys.path.insert(0, "/app/src"); '
9494
+ 'from entrypoint import run_task; '
9595
+ 'p = json.loads(os.environ["AGENT_PAYLOAD"]); '
9696
+ 'r = run_task('

docs/design/DEPLOYMENT_ROLES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ CloudFormation stack operations, IAM roles/policies, VPC networking, and Route 5
117117
"iam:DeleteRole",
118118
"iam:GetRole",
119119
"iam:UpdateRole",
120+
"iam:UpdateAssumeRolePolicy",
120121
"iam:TagRole",
121122
"iam:UntagRole",
122123
"iam:ListRoleTags",

docs/src/content/docs/architecture/Deployment-roles.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ CloudFormation stack operations, IAM roles/policies, VPC networking, and Route 5
121121
"iam:DeleteRole",
122122
"iam:GetRole",
123123
"iam:UpdateRole",
124+
"iam:UpdateAssumeRolePolicy",
124125
"iam:TagRole",
125126
"iam:UntagRole",
126127
"iam:ListRoleTags",

0 commit comments

Comments
 (0)