You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
8
+
9
+
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.
- A domain name that you own(Cloudflare is recommended)
30
+
31
+
- Recommended for monitoring and logging
32
+
- Grafana Account & Stack (see Step 15 for detailed notes)
33
+
- Posthog Account (optional)
34
+
35
+
> **Production Security Checklist:** Before deploying to production, verify these critical security and reliability settings are enabled:
36
+
> -`DB_INSTANCE_BACKUP_ENABLED`
37
+
> -`RDS_AUTOMATIC_MINOR_VERSION_UPGRADE_ENABLED`
38
+
> -`RDS_ENHANCED_MONITORING_ENABLED`
39
+
> -`RDS_INSTANCE_LOGGING_ENABLED`
40
+
> -`RDS_MULTI_AZ_SUPPORT`
41
+
> -`S3_BUCKET_LOGGING_ENABLED`
42
+
> -`EC2 Metadata service configuration`
43
+
44
+
## Deployment Steps
45
+
46
+
### 1. Setup E2B Landing Zone
47
+
48
+
1.**Deploy CloudFormation Stack**
49
+
- Open AWS CloudFormation console and create a new stack
50
+
- Upload the `e2b-setup-env.yml` template file
51
+
- Configure the following parameters:
52
+
-**Stack Name**: Enter a name for the stack, **must be lowercase**(e.g., `e2b-infra`)
53
+
-**Domain Configuration**: Enter a domain you own (e.g., `example.com`)
54
+
-**EC2 Key Pair**: Select an existing key pair for SSH access
55
+
-**AllowRemoteSSHIPs**: Adjust IP range for SSH access (default restricts to private networks for security)
56
+
-**Database Settings**: Configure RDS parameters following password requirements(must be 8-30 characters with letters and numbers)
57
+
- Complete all required fields and launch the stack
58
+
59
+
2.**Validate Domain Certificate**
60
+
- Navigate to Amazon Certificate Manager (ACM)
61
+
- Find your domain certificate and note the required CNAME record
62
+
- Add the CNAME record to your domain's DNS settings(Cloudflare DNS settings)
63
+
- Wait for domain validation (typically 5-10 minutes)
64
+
65
+
3.**Monitor Stack Creation**
66
+
- Return to CloudFormation console
67
+
- Wait for stack creation to complete successfully
68
+
69
+
### 2. Setup E2B Infrastructure
70
+
71
+
1.**Connect to Deployment Machine**
72
+
- Use SSH with your EC2 key pair: `ssh -i your-key.pem ubuntu@<instance-ip>`
73
+
- Or use AWS Session Manager from the EC2 console for browser-based access
74
+
75
+
2. Execute the following commands:
76
+
```bash
77
+
# Switch to root user for administrative privileges required for infrastructure setup
78
+
sudo su root
79
+
80
+
# Initialize the environment by setting up AWS metadata, CloudFormation outputs,
81
+
# and creating the configuration file at /opt/config.properties
82
+
bash infra-iac/init.sh
83
+
84
+
# Build custom AMI images using Packer for the E2B infrastructure
85
+
# This creates optimized machine images with pre-installed dependencies
86
+
# This may take a while, please be patient
87
+
bash infra-iac/packer/packer.sh
88
+
89
+
# Deploy the complete E2B infrastructure using Terraform
90
+
# This provisions AWS resources including VPC, EC2 instances, RDS, ALB, etc.
91
+
# Wait until the terraform deployment completes
92
+
bash infra-iac/terraform/start.sh
93
+
```
94
+
95
+
3. Setup Database:
96
+
```bash
97
+
bash infra-iac/db/init-db.sh
98
+
99
+
# Save the following token information for later use:
100
+
# User: xxx
101
+
# Team ID: <ID>
102
+
# Access Token: <e2b_token>
103
+
# Team API Key: <e2b_API>
104
+
```
105
+
4. Configure E2B DNS records(in Cloudflare):
106
+
-**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.
107
+
-**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.
108
+
-**Retrieve Nomad Access Token**: Execute `more /opt/config.properties | grep NOMAD` to extract the Nomad cluster management token from the configuration file.
109
+
110
+
### 3. Deploy E2B Applications
111
+
112
+
#### Application Image Configuration
113
+
114
+
**Custom Image Building**
115
+
-**Build Custom Images**: Execute `bash packages/build.sh` to build custom E2B images and push them to your private ECR registry
116
+
117
+
#### Deploy Nomad Applications
118
+
119
+
```bash
120
+
# Load Nomad environment variables and configuration settings
121
+
source nomad/nomad.sh
122
+
123
+
# Prepare the Nomad cluster and configure job templates
124
+
bash nomad/prepare.sh
125
+
126
+
# Deploy all E2B applications to the Nomad cluster
127
+
bash nomad/deploy.sh
128
+
129
+
# There are 10 applications in total
130
+
```
131
+
132
+
### 4. Configure E2B Monitoring (Optional)
133
+
134
+
1. Login to https://grafana.com/ (register if needed)
135
+
2. Access your settings page at https://grafana.com/orgs/<username>
136
+
3. In your Stack, find 'Manage your stack' page
137
+
4. Find 'OpenTelemetry' and click 'Configure'
138
+
5. Note the following values from the dashboard:
139
+
```
140
+
Endpoint for sending OTLP signals: xxxx
141
+
Instance ID: xxxxxxx
142
+
Password / API Token: xxxxx
143
+
```
144
+
145
+
6. Export NOMAD environment variables:(Optional)
146
+
```bash
147
+
cat <<EOF >> /opt/config.properties
148
+
149
+
# Grafana configuration
150
+
grafana_otel_collector_token=xxx
151
+
grafana_otlp_url=xxx
152
+
grafana_username=xxx
153
+
EOF
154
+
155
+
echo"Appended Grafana configuration to /opt/config.properties"
156
+
```
157
+
158
+
7. Deploy OpenTelemetry collector:(Optional)
159
+
```bash
160
+
bash nomad/deploy.sh otel-collector
161
+
```
162
+
163
+
8. Open Grafana Cloud Dashboard to view metrics, traces, and logs(Optional)
164
+
165
+
166
+
### 5. Test by E2B SDK
167
+
168
+
Test creation template(The script includes the following steps 1-6)
169
+
```bash
170
+
bash nomad/create_template.sh
171
+
```
172
+
173
+
1. In EC2 Auto Scaling Group, set the desired capacity of **<e2b>client-asg** server to 1
1.**No nodes were eligible for evaluation error when deploying applications**
291
+
- Check node status and constraints
292
+
293
+
2.**Driver Failure: Failed to pull from ECR**
294
+
- Error: `Failed to pull xxx.dkr.ecr.us-west-2.amazonaws.com/e2b-orchestration/api:latest: API error (404): pull access denied for xxx.dkr.ecr.us-west-2.amazonaws.com/e2b-orchestration/api, repository does not exist or may require 'docker login': denied: Your authorization token has expired. Reauthenticate and try again.`
295
+
- Solution: Execute `aws ecr get-login-password --region us-east-1` to get a new ECR token and update the HCL file
296
+
297
+
3. For other unresolved issues, contact support
298
+
299
+
## Appendix
6
300
7
-
* Change the title in this README
8
-
* Edit your repository description on GitHub
9
301
10
302
## Security
11
303
@@ -15,3 +307,4 @@ See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more inform
15
307
16
308
This project is licensed under the Apache-2.0 License.
0 commit comments