Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Disable AWS deployment when the creds are missing; Remove duplicate env vars

Tomas Valentab9bef6359590
diff --git a/api-service/app.py b/api-service/app.py
index e5679c5bf..c520252c5 100644
--- a/api-service/app.py
+++ b/api-service/app.py
@@ -15,8 +15,8 @@ from codegen.tools.human.tools import create_human_tools
load_dotenv()
-url = os.environ.get("SUPABASE_URL")
-key = os.environ.get("SUPABASE_SECRET_KEY")
+url = os.environ.get("NEXT_PUBLIC_SUPABASE_URL")
+key = os.environ.get("SUPABASE_KEY")
if not url or not key:
raise NotFoundException("Suapbase credentials not found")
@@ -91,8 +91,11 @@ async def generate():
blocks=blocks,
)
- await db.update_state(run_id=run_id, state=DeploymentState.Deploying)
- url = await playground.deploy(project_id)
+ url: str | None = None
+ # Disable deployment if there AWS creds are not present
+ if os.environ.get("AWS_ACCESS_KEY_ID") and os.environ.get("AWS_SECRET_ACCESS_KEY"):
+ await db.update_state(run_id=run_id, state=DeploymentState.Deploying)
+ url = await playground.deploy(project_id)
await db.finish_deployment(run_id=run_id, url=url)
return {}
diff --git a/api-service/playground/scripts/build.js b/api-service/playground/scripts/build.js
index f418d8eb5..9545c420a 100755
--- a/api-service/playground/scripts/build.js
+++ b/api-service/playground/scripts/build.js
@@ -4,7 +4,7 @@
const esbuild = require('esbuild')
const path = require('path')
-const isDev = process.env.NODE_ENV === 'dev'
+const isDev = process.env.NODE_ENV === 'development'
const makeAllPackagesExternalPlugin = {
name: 'make-all-packages-external',
diff --git a/api-service/playground/src/data/logOutput.ts b/api-service/playground/src/data/logOutput.ts
index d1cfef3c5..a68994cbd 100644
--- a/api-service/playground/src/data/logOutput.ts
+++ b/api-service/playground/src/data/logOutput.ts
@@ -9,8 +9,7 @@ dotenv.config({
path: '../../.env',
})
-const client = createClient<Database>(process.env.SUPABASE_URL!, process.env.SUPABASE_SECRET_KEY!)
-
+const client = createClient<Database>(process.env.NEXT_PUBLIC_SUPABASE_URL!, process.env.SUPABASE_KEY!)
export const projectsTable = 'projects'
export const deploymentsTable = 'deployments'
diff --git a/api-service/playground/src/deployments/deployment.ts b/api-service/playground/src/deployments/deployment.ts
index f0297b748..950da50cb 100644
--- a/api-service/playground/src/deployments/deployment.ts
+++ b/api-service/playground/src/deployments/deployment.ts
@@ -9,7 +9,6 @@ import {
GetFunctionCommand,
GetFunctionUrlConfigCommand,
} from '@aws-sdk/client-lambda'
-// import { APIGatewayClient } from '@aws-sdk/client-api-gateway'
import { EnvVars, Session } from '@devbookhq/sdk'
import * as dotenv from 'dotenv'
@@ -19,30 +18,21 @@ dotenv.config({
path: '../../.env',
})
-const credentials = {
- accessKeyId: process.env.AWS_ACCESS_KEY_ID!,
- secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,
-}
-
-if (!credentials.accessKeyId || !credentials.secretAccessKey) {
- throw new Error('AWS credentials not found')
-}
+const credentials = process.env.AWS_ACCESS_KEY_ID && process.env.AWS_SECRET_ACCESS_KEY
+ ? {
+ accessKeyId: process.env.AWS_ACCESS_KEY_ID,
+ secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
+ }
+ : undefined
const region = 'us-east-1'
const architecture = 'arm64'
-// TODO: lambda.destroy() on quit?
const lambda = new LambdaClient({
region,
credentials,
})
-// TODO: gateway.destroy() on quit?
-// const gateway = new APIGatewayClient({
-// region,
-// credentials,
-// })
-
const deploymentParams = {
Runtime: 'nodejs18.x',
Role: 'arn:aws:iam::458837768593:role/service-role/ai-api-deploy',
diff --git a/api-service/playground/src/deployments/deploymentsController.ts b/api-service/playground/src/deployments/deploymentsController.ts
index f6d6ec4ce..13dd104ee 100644
--- a/api-service/playground/src/deployments/deploymentsController.ts
+++ b/api-service/playground/src/deployments/deploymentsController.ts
@@ -3,7 +3,6 @@ import {
BodyProp,
Put,
Path,
- Patch,
Route,
Query,
} from 'tsoa'