Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
61a2252
add new api
linnjia-aws Jul 11, 2025
cf5e9a7
add new shared
linnjia-aws Jul 11, 2025
df79e92
add new shared
linnjia-aws Jul 11, 2025
ecb0e3b
merge orchestrator
warren830 Jul 11, 2025
67728ce
remove expectedMigrationTimestamp
linnjia-aws Jul 14, 2025
b0f5d72
add envd
linnjia-aws Jul 14, 2025
2f41b74
add client proxy and docker reverse proxy
linnjia-aws Jul 14, 2025
f5f5ddf
modify Makefile
linnjia-aws Jul 14, 2025
b09ffbc
rm templagte manager
linnjia-aws Jul 14, 2025
0a8aa65
add. log for debug
linnjia-aws Jul 14, 2025
e9bdbd6
remove EXPECTED_MIGRATION_TIMESTAMP
linnjia-aws Jul 15, 2025
605c106
modify nomad job hcl
linnjia-aws Jul 15, 2025
ac404e2
modify readme.md and template manger
linnjia-aws Jul 15, 2025
632a612
add ignore file.
crazyoyo Jul 15, 2025
9d3461b
add edge.hcl
linnjia-aws Jul 15, 2025
b327a8c
Merge branch 'commit-0701' of https://github.com/aws-samples/sample-e…
linnjia-aws Jul 15, 2025
8236ca6
modify deploy.sh
linnjia-aws Jul 15, 2025
c0f7890
modify ConcurrentInstances 20->1000000
linnjia-aws Jul 16, 2025
01d14d8
modify max_length_hours from 1->24
linnjia-aws Jul 16, 2025
69b6e8f
add support for graviton
Jul 17, 2025
71a2653
Update e2b-setup-env.yml
crazyoyo Jul 17, 2025
6f5da97
Update description for DBName
Jul 17, 2025
6a0b2a3
bugfix for graviton support.
Jul 17, 2025
bea646d
bugfix for client-proxy Makefile
Jul 17, 2025
8fe21e4
bugfix for bin upload
Jul 17, 2025
be9f09a
modify upload.sh by chao
linnjia-aws Jul 17, 2025
032d4dc
Add Dockerfile for BrowserUse
Jul 18, 2025
da6fc69
feat(docker-reverse-proxy): Add AWS ECR support
binglius Jul 20, 2025
5140ec0
Code optimization and bugfix.
crazyoyo Jul 20, 2025
8fe25f5
Code optimization and bugfix.
crazyoyo Jul 20, 2025
b474ef5
Code optimization and bugfix.
crazyoyo Jul 21, 2025
59c58dd
modify docker reverse job hcl and build progress
linnjia-aws Jul 21, 2025
e52d987
Code optimization and bugfix.
crazyoyo Jul 21, 2025
d7ce8a6
Code optimization and bugfix.
crazyoyo Jul 21, 2025
a68c21b
Code optimization and bugfix.
crazyoyo Jul 21, 2025
af685d4
Code optimization and bugfix.
crazyoyo Jul 21, 2025
649afca
Code optimization and bugfix.
crazyoyo Jul 21, 2025
1557500
Code optimization and bugfix.
crazyoyo Jul 21, 2025
f5ec5b6
modify
linnjia-aws Jul 22, 2025
4c32e19
Merge branch 'commit-0701' of https://github.com/aws-samples/sample-e…
linnjia-aws Jul 22, 2025
1d01d44
add amazon-ecr-credential-helper to client and server cluster
linnjia-aws Jul 22, 2025
7ac5362
Move AWS constants to docker-reverse-proxy package and add debug logs
binglius Jul 23, 2025
b548b1c
Code optimization and bugfix.
crazyoyo Jul 23, 2025
48432a0
Code optimization and bugfix.
crazyoyo Jul 23, 2025
293f60f
Code optimization and bugfix.
crazyoyo Jul 24, 2025
fe6e069
Code optimization and bugfix.
crazyoyo Jul 24, 2025
304f678
Code optimization and bugfix.
crazyoyo Jul 24, 2025
9e5e97a
modify cnf s3
linnjia-aws Jul 24, 2025
5ebe929
Code optimization and bugfix.
crazyoyo Jul 24, 2025
16212fa
Code optimization and bugfix.
crazyoyo Jul 24, 2025
0765926
Code optimization and bugfix.
crazyoyo Jul 25, 2025
e252997
Code optimization and bugfix.
crazyoyo Jul 25, 2025
4e876e8
update orchestrator Makefile
linnjia-aws Jul 25, 2025
3407071
add destroy cnf shell
linnjia-aws Jul 25, 2025
a583408
Code optimization and bugfix.
crazyoyo Jul 27, 2025
02550ed
Code optimization and bugfix.
crazyoyo Jul 27, 2025
ff5296b
Code optimization and bugfix.
crazyoyo Jul 27, 2025
08f2534
rm template manager getBuilderClient
linnjia-aws Jul 28, 2025
bc83d8b
tm.localClientMutex.RLock() // 改为读锁
linnjia-aws Jul 28, 2025
ef08c94
merge Commit 88dabc2
linnjia-aws Jul 29, 2025
a5a023e
Refactor upload.sh
crazyoyo Jul 29, 2025
853aa16
update destroy.sh
linnjia-aws Jul 29, 2025
bce8562
modify readme
linnjia-aws Jul 29, 2025
a87e523
Update README.
crazyoyo Jul 29, 2025
894679e
Remove Cloudformation test function.
crazyoyo Jul 31, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
115 changes: 115 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
bin/

# Go specific
*.o
*.a
*.test
*.out
go.work

# Mac OS specific
.DS_Store
.AppleDouble
.LSOverride
._*

# Linux specific
*~
.fuse_hidden*
.directory
.Trash-*
.nfs*

# Windows specific
Thumbs.db
ehthumbs.db
Desktop.ini
$RECYCLE.BIN/
*.cab
*.msi
*.msm
*.msp
*.lnk

# Editor directories and files
.idea/
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.sublime-workspace
*.swp
*.swo
*~
.project
.classpath
.c9/
*.launch
.settings/

# Environment files
.env
.env.*
!.env.example

# Build and package artifacts
mkfcenv.tar.gz
*.tar.gz
*.tar
*.zip
dist/
build/

# Dependency directories
vendor/
node_modules/
jspm_packages/
.pnp/
.pnp.js

# Logs
logs/
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Database files
.db
*.db
*.sqlite
*.sqlite3

# Temporary files
.tmp/
.temp/
tmp/
temp/
*.tmp

# Docker
.docker/
docker-compose.override.yml

# Terraform
.terraform/
*.tfstate
*.tfstate.*
.terraformrc
terraform.rc
terraform.tfvars
*.tfvars.json

# Packer
packer_cache/

# Project specific
.shared
10 changes: 10 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

103 changes: 26 additions & 77 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,12 @@

E2B on AWS provides a secure, scalable, and customizable environment for running AI agent sandboxes in your own AWS account. This project addresses the growing need for organizations to maintain control over their AI infrastructure while leveraging the power of E2B's sandbox technology for AI agent development, testing, and deployment.

This project is built based on version [c746fd93d5f1260315c893dbd5d7290c0a41e52a](https://github.com/e2b-dev/infra/commit/c746fd93d5f1260315c893dbd5d7290c0a41e52a) (Mar 2), with newer versions still undergoing modifications. This E2B deployment can be used for testing purposes. If you encounter any issues, please contact the relevant team members or submit a PR directly. We would like to express our special thanks to all contributors involved in the project transformation.
This project is built based on version [0c35ed5c3b8492f96d1e0bbfb91fff96541a8c74](https://github.com/e2b-dev/infra/commit/0c35ed5c3b8492f96d1e0bbfb91fff96541a8c74) (Jul 1). This E2B deployment can be used for testing purposes. If you encounter any issues, please contact the relevant team members or submit a PR directly. We would like to express our special thanks to all contributors involved in the project transformation.

## Table of Contents

- [Prerequisites](#prerequisites)
- [Deployment Steps](#deployment-steps)
- [1. Setup E2B Landing Zone](#1-setup-e2b-landing-zone)
- [2. Setup E2B Infrastructure](#2-setup-e2b-infrastructure)
- [3. Deploy E2B Applications](#3-deploy-e2b-applications)
- [4. Configure E2B Monitoring (Optional)](#4-configure-e2b-monitoring-optional)
- [5. Test by E2B SDK](#5-test-by-e2b-sdk)
- [How to Deploy](#deployment)
- [Using E2B CLI](#using-e2b-cli)
- [E2B SDK Cookbook](#e2b-sdk-cookbook)
- [Troubleshooting](#troubleshooting)
Expand All @@ -42,16 +37,18 @@ This project is built based on version [c746fd93d5f1260315c893dbd5d7290c0a41e52a
> - `S3_BUCKET_LOGGING_ENABLED`
> - `EC2 Metadata service configuration`

## Deployment Steps

### 1. Setup E2B Landing Zone

## Deployment
### 1. E2B Deployment
1. **Deploy CloudFormation Stack**
- Git Clone the project
- Open AWS CloudFormation console and create a new stack
- Upload the `e2b-setup-env.yml` template file
- Upload the `e2b-setup-env.yml` file
- Configure the following parameters:
- **Stack Name**: Enter a name for the stack, **must be lowercase**(e.g., `e2b-infra`)
- **Domain Configuration**: Enter a domain you own (e.g., `example.com`)
- **VPC Configuration**: Deployed new VPC environment configuration
- **Environment Configuration**: Choose an Environment (Support dev and prod, prod has a more stringent resource protection mechanism)
- **Architecture Configuration**: Choose CPU architecture (Support x64 and Graviton)
- **Domain Configuration**: Enter a domain you own(e.g., `example.com`)
- **EC2 Key Pair**: Select an existing key pair for SSH access
- **AllowRemoteSSHIPs**: Adjust IP range for SSH access (default restricts to private networks for security)
- **Database Settings**: Configure RDS parameters following password requirements(must be 8-30 characters with letters and numbers)
Expand All @@ -61,80 +58,26 @@ This project is built based on version [c746fd93d5f1260315c893dbd5d7290c0a41e52a
- Navigate to Amazon Certificate Manager (ACM)
- Find your domain certificate and note the required CNAME record
- Add the CNAME record to your domain's DNS settings(Cloudflare DNS settings)
- Wait for domain validation (typically 5-10 minutes)

3. **Monitor Stack Creation**
- Return to CloudFormation console
- Wait for stack creation to complete successfully
- Wait for domain validation (typically in **5 minutes**)

### 2. Setup E2B Infrastructure

1. **Connect to Deployment Machine**
3. **Connect to Bastion Machine**
- Use SSH with your EC2 key pair: `ssh -i your-key.pem ubuntu@<instance-ip>`
- Or use AWS Session Manager from the EC2 console for browser-based access

2. Execute the following commands:
4. **Watch Deployment Logs**
```bash
# Switch to root user for administrative privileges required for infrastructure setup
sudo su root

# Enter the working directory.
cd /opt/infra/sample-e2b-on-aws

# Initialize the environment by setting up AWS metadata, CloudFormation outputs,
# and creating the configuration file at /opt/config.properties

bash infra-iac/init.sh

# Build custom AMI images using Packer for the E2B infrastructure
# This creates optimized machine images with pre-installed dependencies
# This may take a while, please be patient
bash infra-iac/packer/packer.sh

# Deploy the complete E2B infrastructure using Terraform
# This provisions AWS resources including VPC, EC2 instances, RDS, ALB, etc.
# Wait until the terraform deployment completes
bash infra-iac/terraform/start.sh
tail -f /tmp/e2b.log
```

3. Setup Database:
```bash
bash infra-iac/db/init-db.sh

# Save the following token information for later use:
# User: xxx
# Team ID: <ID>
# Access Token: <e2b_token>
# Team API Key: <e2b_API>
```
4. Configure E2B DNS records(in Cloudflare):
5. **Configure E2B DNS records(in Cloudflare)**
- **Setup Wildcard DNS**: Add a CNAME record for `*` (wildcard) pointing to the DNS name of the automatically created Application Load Balancer (ALB). This enables all E2B subdomains to route through the load balancer.
- **Access Nomad Dashboard**: Navigate to `https://nomad.<your-domain>` in your browser and authenticate using the retrieved token to monitor and manage the Nomad cluster workloads.
- **Retrieve Nomad Access Token**: Execute `more /opt/config.properties | grep NOMAD` to extract the Nomad cluster management token from the configuration file.

### 3. Deploy E2B Applications
- **Retrieve Nomad Access Token**: Execute `cat /opt/config.properties` to extract the Nomad cluster management token from the configuration file.

#### Application Image Configuration

**Custom Image Building**
- **Build Custom Images**: Execute `bash packages/build.sh` to build custom E2B images and push them to your private ECR registry

#### Deploy Nomad Applications

```bash
# Load Nomad environment variables and configuration settings
source nomad/nomad.sh

# Prepare the Nomad cluster and configure job templates
bash nomad/prepare.sh

# Deploy all E2B applications to the Nomad cluster
bash nomad/deploy.sh

# There are 10 applications in total
```

### 4. Configure E2B Monitoring (Optional)
### 2. Configure E2B Monitoring (Optional)

1. Login to https://grafana.com/ (register if needed)
2. Access your settings page at https://grafana.com/orgs/<username>
Expand Down Expand Up @@ -167,22 +110,28 @@ bash nomad/deploy.sh otel-collector

8. Open Grafana Cloud Dashboard to view metrics, traces, and logs(Optional)


### 5. Test by E2B SDK
### 3. E2B Test

1. Create a template:
```bash
# There are three ways to create E2B templates:
# Create a template from e2bdev/code-interpreter
bash packages/create_template.sh

# Create a template from a Dockerfile
bash packages/create_template.sh --docker-file <Docker_File_Path>

# Example for create a template of Desktop
bash packages/create_template.sh --docker-file test_use_case/Docckerfile/e2b.Dockerfile.Desktop

# Example for create a template of BrowserUse
bash packages/create_template.sh --docker-file test_use_case/Docckerfile/e2b.Dockerfile.BrowserUse

# Create a template from an ECR image that in your own account
bash packages/create_template.sh --ecr-image <ECR_IMAGE_URI>
```

2. Create a sandbox(Get the value of e2b_API to execute commands--- more ../infra-iac/db/config.json):
2. Create a sandbox(Get the value of e2b_API to execute commands --- more ../infra-iac/db/config.json):
```bash
curl -X POST \
https://api.<e2bdomain>/sandboxes \
Expand Down
Loading