Skip to content

Commit ab05210

Browse files
authored
Merge pull request #91 from awslabs/fix/codebuild-remove-git-dependency
Remove git dependency from CodeBuild deployment script
2 parents b58f646 + e509c01 commit ab05210

4 files changed

Lines changed: 439 additions & 183 deletions

File tree

docs/DEPLOYMENT.md

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ This guide walks you through deploying the Fullstack AgentCore Solution Template
66
77
## Prerequisites
88

9-
Before deploying, ensure you have:
9+
> **Note:** If you prefer not to install local tooling, see [Option B: Deploy via CodeBuild](#option-b-deploy-via-codebuild) — requires only Python 3.11+ and AWS CLI.
10+
11+
For local deployment (Option A), ensure you have:
1012

1113
- **Node.js 20+** installed (see [AWS guide for installing Node.js on EC2](https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-up-node-on-ec2-instance.html))
1214
- **AWS CLI** configured with credentials (`aws configure`) - see [AWS CLI Configuration guide](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html)
@@ -146,7 +148,8 @@ The CDK stack auto-creates a security group for the AgentCore Runtime. This same
146148
## Deployment Steps
147149

148150
### TL;DR version
149-
Here are the commands to deploy backend and frontend:
151+
152+
**Full local setup (Node.js + Docker + CDK):**
150153
```bash
151154
cd infra-cdk
152155
npm install
@@ -156,15 +159,14 @@ cd ..
156159
python scripts/deploy-frontend.py
157160
```
158161

159-
### Deploy Without Local Tooling (via CodeBuild)
160-
161-
If you don't have Node.js, Docker, or CDK installed locally, you can deploy entirely in the cloud using a temporary CodeBuild project. Requires only Python 3.8+ and AWS CLI:
162-
162+
**No local tooling (just Python + AWS CLI):**
163163
```bash
164164
python scripts/deploy-with-codebuild.py
165165
```
166166

167-
See `scripts/README.md` for details and required IAM permissions.
167+
### Option A: Deploy Locally (CDK + Docker)
168+
169+
This path requires the full set of prerequisites listed above (Node.js, Docker, CDK, Python).
168170

169171
### 1. Install Dependencies
170172

@@ -248,6 +250,24 @@ You will see the URL for application in the script's output, which will look sim
248250
1. Sign in with the Cognito user you created
249251
1. You'll be prompted to change your temporary password on first login
250252

253+
---
254+
255+
### Option B: Deploy via CodeBuild
256+
257+
Requires only Python 3.11+, AWS CLI, and git — no Node.js, Docker, or CDK needed.
258+
259+
1. Edit `infra-cdk/config.yaml` (see [Configuration](#configuration) above)
260+
2. Stage or commit your changes — only git-tracked or staged files are packaged for deployment. Untracked files are skipped and reported as a warning.
261+
3. Run:
262+
263+
```bash
264+
python scripts/deploy-with-codebuild.py
265+
```
266+
267+
The script packages your git-tracked source and runs the full CDK + frontend deploy in the cloud via CodeBuild, streaming logs to your terminal. On success, the build resources (project, IAM role, permission boundary, S3 bucket) are removed; on failure they are retained for debugging (the script prints the console URL and log group) and reused on the next run.
268+
269+
See `scripts/README.md` for details and required IAM permissions.
270+
251271
## Post-Deployment
252272

253273
### Updating the Application
@@ -282,7 +302,9 @@ cd infra-cdk
282302
cdk destroy --force
283303
```
284304

285-
**Warning**: This will delete all data including S3 buckets created during deployment and ECR images.
305+
If you deployed via CodeBuild (Option B), its build resources are already removed on success (or on the next successful run) — only the deployed FAST stack above needs tearing down.
306+
307+
**Warning**: `cdk destroy` will delete all data including S3 buckets created during deployment and ECR images.
286308

287309
## Troubleshooting
288310

infra-cdk/lib/backend-stack.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,8 @@ export class BackendStack extends cdk.NestedStack {
929929

930930
const cedarPolicyLambda = new PythonFunction(this, "CedarPolicyLambda", {
931931
runtime: lambda.Runtime.PYTHON_3_13,
932+
// ARM_64 required — avoids cross-platform (amd64-on-arm) bundling failures.
933+
architecture: lambda.Architecture.ARM_64,
932934
entry: path.join(__dirname, "..", "lambdas", "cedar-policy"),
933935
handler: "handler",
934936
timeout: cdk.Duration.minutes(14),

scripts/README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,24 @@ change anything:
5555

5656
### CodeBuild Deployment
5757

58-
- `deploy-with-codebuild.py` - Deploys the entire FAST stack (backend + frontend) using an ephemeral CodeBuild project. No local Node.js, Docker, CDK, or npm required — only Python 3.8+ and AWS CLI.
58+
- `deploy-with-codebuild.py` - Deploys the entire FAST stack (backend + frontend) using a CodeBuild project. No local Node.js, Docker, CDK, or npm required — only Python 3.11+, AWS CLI, and git.
5959

6060
```bash
6161
python scripts/deploy-with-codebuild.py
6262
```
6363

64-
Creates temporary AWS resources (S3 bucket, IAM role with permission boundary, CodeBuild project), runs the full deployment in the cloud, streams logs to your terminal, and cleans up all temporary resources on exit.
64+
Packages your git-tracked source and runs the full deployment in the cloud via a CodeBuild project, streaming logs to your terminal. On a **successful** build, all created resources (S3 source bucket, CodeBuild project, IAM role, permission boundary) are removed. On a **failed** build, they are retained for debugging and reused on the next run.
6565

66-
The temporary IAM role is created with `AdministratorAccess` but constrained by a permission boundary that explicitly denies dangerous actions such as `iam:CreateUser`, `iam:CreateAccessKey`, `organizations:*`, and others. This prevents privilege escalation even if the build is compromised.
66+
Only git-tracked or staged files are deployed — stage or commit first, as untracked files are skipped with a warning. This does not remove your deployed FAST stack; for that, run `cd infra-cdk && cdk destroy`.
67+
68+
The IAM role has `AdministratorAccess` constrained by a permission boundary that denies dangerous actions (`iam:CreateUser`, `iam:CreateAccessKey`, `organizations:*`, etc.) to prevent privilege escalation.
6769

6870
Your IAM user/role needs these permissions to run the script:
6971

70-
- `s3:CreateBucket`, `s3:DeleteBucket`, `s3:PutObject`, `s3:DeleteObject`
72+
- `s3:CreateBucket`, `s3:DeleteBucket`, `s3:PutObject`, `s3:DeleteObject`, `s3:PutLifecycleConfiguration`
7173
- `iam:CreateRole`, `iam:DeleteRole`, `iam:AttachRolePolicy`, `iam:DetachRolePolicy`
7274
- `iam:CreatePolicy`, `iam:DeletePolicy`
73-
- `codebuild:CreateProject`, `codebuild:StartBuild`, `codebuild:BatchGetBuilds`
75+
- `codebuild:CreateProject`, `codebuild:DeleteProject`, `codebuild:StartBuild`, `codebuild:BatchGetBuilds`
7476
- `logs:GetLogEvents`
7577
- `sts:GetCallerIdentity`
7678

@@ -79,7 +81,7 @@ Your IAM user/role needs these permissions to run the script:
7981
## Requirements
8082

8183
- AWS CLI configured with appropriate permissions
82-
- Python 3.8+ (standard library only, no pip install needed for deployment)
84+
- Python 3.11+ (standard library only, no pip install needed for deployment)
8385
- Node.js and npm (for frontend build)
8486
- CDK stack deployed with the required outputs:
8587
- `CognitoClientId`

0 commit comments

Comments
 (0)