Skip to content

Commit dbdc126

Browse files
fix(docs): add X-Ray resource policy prerequisite and build credential notes
On a fresh AWS account, `aws xray update-trace-segment-destination` fails with AccessDeniedException because X-Ray needs a CloudWatch Logs resource policy before it can write spans. Added the prerequisite `aws logs put-resource-policy` command to Quick Start Step 3. Also documented that `mise run build` requires AWS credentials with ec2:DescribeAvailabilityZones for CDK synthesis, and added common error table entries for the X-Ray, build credential, and non-TTY deploy issues. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c7df384 commit dbdc126

2 files changed

Lines changed: 28 additions & 8 deletions

File tree

docs/guides/QUICK_START.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Go from zero to your first agent-created pull request in about 30 minutes. This
66

77
Install these before you begin:
88

9-
- **AWS account** with credentials configured (`aws configure`)
9+
- **AWS account** with credentials configured (`aws configure`). If you use named profiles, set `AWS_PROFILE` before running any commands in this guide.
1010
- **Docker** - for building the agent container image
1111
- **mise** - task runner ([install guide](https://mise.jdx.dev/getting-started.html))
1212
- **AWS CDK CLI** - `npm install -g aws-cdk` (after mise is active)
@@ -35,6 +35,8 @@ mise run build
3535

3636
`mise run install` installs all JavaScript and Python dependencies across the monorepo. `mise run build` compiles the CDK app, the CLI, the agent image, and the docs site. A successful build means you are ready to deploy.
3737

38+
> **Note:** `mise run build` includes CDK synthesis, which queries AWS for availability zones. Your active AWS credentials must have at least `ec2:DescribeAvailabilityZones` permission, or the build will fail. If you use named profiles, make sure `AWS_PROFILE` is set before running the build.
39+
3840
## Step 2 - Prepare a repository
3941

4042
The agent works by cloning a GitHub repository, creating a branch, making code changes, running the build and tests, and opening a pull request. This means it needs **write access** to a real repository.
@@ -75,7 +77,12 @@ The `repo` value must match **exactly** what you will pass to the CLI later (`ow
7577
The CDK stack deploys the full platform: API Gateway, Lambda functions (orchestrator, task CRUD, webhooks), DynamoDB tables, AgentCore Runtime, VPC with network isolation, Cognito user pool, and CloudWatch dashboards.
7678

7779
```bash
78-
# One-time account setup (X-Ray destination)
80+
# One-time account setup: allow X-Ray to write spans to CloudWatch Logs.
81+
# On a fresh account, X-Ray needs a resource policy before the destination can be set.
82+
ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
83+
aws logs put-resource-policy \
84+
--policy-name xray-spans-policy \
85+
--policy-document "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Sid\":\"XRaySpansAccess\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"xray.amazonaws.com\"},\"Action\":[\"logs:PutLogEvents\",\"logs:CreateLogGroup\",\"logs:CreateLogStream\"],\"Resource\":\"*\"}]}"
7986
aws xray update-trace-segment-destination --destination CloudWatchLogs
8087

8188
# Bootstrap CDK (first time only)
@@ -85,7 +92,7 @@ mise run //cdk:bootstrap
8592
mise run //cdk:deploy
8693
```
8794

88-
The X-Ray command is a one-time per-account setup. CDK bootstrap provisions the staging resources CDK needs (S3 bucket, IAM roles). The deploy itself takes around 10 minutes - most of the time is spent building the Docker image and provisioning the AgentCore Runtime.
95+
The X-Ray commands are a one-time per-account setup. On a fresh account the `put-resource-policy` call is required first — without it, the `update-trace-segment-destination` command fails with an `AccessDeniedException` because X-Ray cannot write to the `aws/spans` log group. CDK bootstrap provisions the staging resources CDK needs (S3 bucket, IAM roles). The deploy itself takes around 10 minutes - most of the time is spent building the Docker image and provisioning the AgentCore Runtime.
8996

9097
## Step 4 - Store the GitHub token
9198

@@ -183,7 +190,10 @@ Here is what the platform did after you ran `bgagent submit`:
183190
|---|---|---|
184191
| `yarn: command not found` | Corepack not enabled or mise not activated in your shell | Run `eval "$(mise activate zsh)"`, then `corepack enable && corepack prepare yarn@1.22.22 --activate` |
185192
| `MISE_EXPERIMENTAL required` | Namespaced tasks need the experimental flag | `export MISE_EXPERIMENTAL=1` |
186-
| CDK deploy fails with "X-Ray Delivery Destination..." | Missing one-time account setup | `aws xray update-trace-segment-destination --destination CloudWatchLogs` |
193+
| `AccessDeniedException` on `update-trace-segment-destination` | Fresh account missing CloudWatch Logs resource policy for X-Ray | Run `aws logs put-resource-policy` first (see Step 3) |
194+
| CDK deploy fails with "X-Ray Delivery Destination..." | Missing one-time account setup | Run both X-Ray commands in Step 3 |
195+
| `mise run build` fails with `ec2:DescribeAvailabilityZones` error | AWS credentials missing or insufficient for CDK synth | Set `AWS_PROFILE` or configure credentials with at least EC2 read access |
196+
| CDK deploy prompts for approval and hangs | Non-interactive terminal (CI/CD, scripts) | Pass `--require-approval never` to `cdk deploy` or use an interactive terminal |
187197
| `put-secret-value` returns double-dot endpoint | `REGION` variable is empty | Set `REGION=us-east-1` (or your actual region) before running the command |
188198
| `REPO_NOT_ONBOARDED` on task submit | Blueprint `repo` does not match what you passed to the CLI | Check `cdk/src/stacks/agent.ts` - the `repo` value must be exactly `owner/repo` matching your fork |
189199
| `INSUFFICIENT_GITHUB_REPO_PERMISSIONS` | PAT is missing required permissions or is scoped to the wrong repo | Regenerate the PAT with Contents (read/write) and Pull requests (read/write) scoped to your fork, then update Secrets Manager |

docs/src/content/docs/getting-started/Quick-start.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Go from zero to your first agent-created pull request in about 30 minutes. This
1010

1111
Install these before you begin:
1212

13-
- **AWS account** with credentials configured (`aws configure`)
13+
- **AWS account** with credentials configured (`aws configure`). If you use named profiles, set `AWS_PROFILE` before running any commands in this guide.
1414
- **Docker** - for building the agent container image
1515
- **mise** - task runner ([install guide](https://mise.jdx.dev/getting-started.html))
1616
- **AWS CDK CLI** - `npm install -g aws-cdk` (after mise is active)
@@ -39,6 +39,8 @@ mise run build
3939

4040
`mise run install` installs all JavaScript and Python dependencies across the monorepo. `mise run build` compiles the CDK app, the CLI, the agent image, and the docs site. A successful build means you are ready to deploy.
4141

42+
> **Note:** `mise run build` includes CDK synthesis, which queries AWS for availability zones. Your active AWS credentials must have at least `ec2:DescribeAvailabilityZones` permission, or the build will fail. If you use named profiles, make sure `AWS_PROFILE` is set before running the build.
43+
4244
## Step 2 - Prepare a repository
4345

4446
The agent works by cloning a GitHub repository, creating a branch, making code changes, running the build and tests, and opening a pull request. This means it needs **write access** to a real repository.
@@ -79,7 +81,12 @@ The `repo` value must match **exactly** what you will pass to the CLI later (`ow
7981
The CDK stack deploys the full platform: API Gateway, Lambda functions (orchestrator, task CRUD, webhooks), DynamoDB tables, AgentCore Runtime, VPC with network isolation, Cognito user pool, and CloudWatch dashboards.
8082

8183
```bash
82-
# One-time account setup (X-Ray destination)
84+
# One-time account setup: allow X-Ray to write spans to CloudWatch Logs.
85+
# On a fresh account, X-Ray needs a resource policy before the destination can be set.
86+
ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
87+
aws logs put-resource-policy \
88+
--policy-name xray-spans-policy \
89+
--policy-document "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Sid\":\"XRaySpansAccess\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"xray.amazonaws.com\"},\"Action\":[\"logs:PutLogEvents\",\"logs:CreateLogGroup\",\"logs:CreateLogStream\"],\"Resource\":\"*\"}]}"
8390
aws xray update-trace-segment-destination --destination CloudWatchLogs
8491

8592
# Bootstrap CDK (first time only)
@@ -89,7 +96,7 @@ mise run //cdk:bootstrap
8996
mise run //cdk:deploy
9097
```
9198

92-
The X-Ray command is a one-time per-account setup. CDK bootstrap provisions the staging resources CDK needs (S3 bucket, IAM roles). The deploy itself takes around 10 minutes - most of the time is spent building the Docker image and provisioning the AgentCore Runtime.
99+
The X-Ray commands are a one-time per-account setup. On a fresh account the `put-resource-policy` call is required first — without it, the `update-trace-segment-destination` command fails with an `AccessDeniedException` because X-Ray cannot write to the `aws/spans` log group. CDK bootstrap provisions the staging resources CDK needs (S3 bucket, IAM roles). The deploy itself takes around 10 minutes - most of the time is spent building the Docker image and provisioning the AgentCore Runtime.
93100

94101
## Step 4 - Store the GitHub token
95102

@@ -187,7 +194,10 @@ Here is what the platform did after you ran `bgagent submit`:
187194
|---|---|---|
188195
| `yarn: command not found` | Corepack not enabled or mise not activated in your shell | Run `eval "$(mise activate zsh)"`, then `corepack enable && corepack prepare yarn@1.22.22 --activate` |
189196
| `MISE_EXPERIMENTAL required` | Namespaced tasks need the experimental flag | `export MISE_EXPERIMENTAL=1` |
190-
| CDK deploy fails with "X-Ray Delivery Destination..." | Missing one-time account setup | `aws xray update-trace-segment-destination --destination CloudWatchLogs` |
197+
| `AccessDeniedException` on `update-trace-segment-destination` | Fresh account missing CloudWatch Logs resource policy for X-Ray | Run `aws logs put-resource-policy` first (see Step 3) |
198+
| CDK deploy fails with "X-Ray Delivery Destination..." | Missing one-time account setup | Run both X-Ray commands in Step 3 |
199+
| `mise run build` fails with `ec2:DescribeAvailabilityZones` error | AWS credentials missing or insufficient for CDK synth | Set `AWS_PROFILE` or configure credentials with at least EC2 read access |
200+
| CDK deploy prompts for approval and hangs | Non-interactive terminal (CI/CD, scripts) | Pass `--require-approval never` to `cdk deploy` or use an interactive terminal |
191201
| `put-secret-value` returns double-dot endpoint | `REGION` variable is empty | Set `REGION=us-east-1` (or your actual region) before running the command |
192202
| `REPO_NOT_ONBOARDED` on task submit | Blueprint `repo` does not match what you passed to the CLI | Check `cdk/src/stacks/agent.ts` - the `repo` value must be exactly `owner/repo` matching your fork |
193203
| `INSUFFICIENT_GITHUB_REPO_PERMISSIONS` | PAT is missing required permissions or is scoped to the wrong repo | Regenerate the PAT with Contents (read/write) and Pull requests (read/write) scoped to your fork, then update Secrets Manager |

0 commit comments

Comments
 (0)