### Create Full Prisma Postgres Setup Source: https://alchemy.run/providers/prisma-postgres/connection.md This example demonstrates creating a complete setup, from project to database to connection. It requires importing Project, Database, and Connection from 'alchemy/prisma-postgres'. ```typescript import { Project, Database, Connection } from "alchemy/prisma-postgres"; const project = await Project("my-app"); const database = await Database("production", { project: project, }); const connection = await Connection("app-connection", { database: database, name: "production-api-connection" }); console.log(`Host: ${connection.host}`); console.log(`User: ${connection.user}`); console.log(`Password: ${connection.password?.unencrypted}`); console.log(`Connection String: ${connection.connectionString.unencrypted}`); ``` -------------------------------- ### Install Alchemy CLI Source: https://alchemy.run/blog/2025-07-01-how-alchemy-is-different.md Install the Alchemy library using Bun. This is the only setup required to start using Alchemy. ```sh bun add alchemy ``` -------------------------------- ### Complete Authentication Setup Example Source: https://alchemy.run/providers/random/random-string.md Demonstrates a complete authentication setup by generating multiple secrets (JWT, session, database password) and then creating a database and a worker with these secrets configured as environment variables. ```typescript import { RandomString } from "alchemy/random"; import { Worker } from "alchemy/cloudflare"; import { PostgresDatabase } from "alchemy/neon"; // Generate all required secrets const jwtSecret = await RandomString("jwt-secret", { length: 64 }); const sessionSecret = await RandomString("session-secret", { length: 32 }); const dbPassword = await RandomString("db-password"); // Create database with secure password const database = await PostgresDatabase("auth-db", { name: "authentication", password: dbPassword.value }); // Create worker with secrets as environment variables const authWorker = await Worker("auth-api", { entrypoint: "./src/auth.ts", bindings: { JWT_SECRET: jwtSecret.value, SESSION_SECRET: sessionSecret.value, DATABASE_URL: database.connectionUrl } }); ``` -------------------------------- ### Start Local HTTP Server Source: https://alchemy.run/guides/cloudflare-tunnel.md Example command to start a simple HTTP server on port 3000 for testing your tunnel. ```bash # Example: Start a simple HTTP server on port 3000 npx http-server -p 3000 # Or run your application # node app.js # python -m http.server 3000 # etc. ``` -------------------------------- ### Complete Internet Setup with Routing Source: https://alchemy.run/providers/aws/internet-gateway-attachment.md This comprehensive example sets up a VPC, Internet Gateway, attaches them, creates a public subnet, a route table, and configures a route to the Internet Gateway for full internet connectivity. It also associates the subnet with the route table. ```typescript import { Vpc, InternetGateway, InternetGatewayAttachment, Subnet, RouteTable, Route, RouteTableAssociation } from "alchemy/aws/ec2"; // Create VPC with DNS enabled const vpc = await Vpc("web-vpc", { cidrBlock: "10.0.0.0/16", enableDnsHostnames: true, enableDnsSupport: true, tags: { Name: "web-vpc", Environment: "production" } }); // Create Internet Gateway const igw = await InternetGateway("web-igw", { tags: { Name: "web-internet-gateway" } }); // Attach Internet Gateway to VPC const attachment = await InternetGatewayAttachment("web-igw-attachment", { internetGateway: igw, vpc: vpc }); // Create public subnet const publicSubnet = await Subnet("public-subnet", { vpc, cidrBlock: "10.0.1.0/24", availabilityZone: "us-east-1a", mapPublicIpOnLaunch: true, tags: { Name: "public-subnet-1a", Type: "public" } }); // Create route table for public access const publicRouteTable = await RouteTable("public-rt", { vpc, tags: { Name: "public-route-table" } }); // Add route to Internet Gateway (depends on attachment) const internetRoute = await Route("internet-route", { routeTable: publicRouteTable, destinationCidrBlock: "0.0.0.0/0", target: { internetGateway: igw } }); // Associate subnet with route table const routeAssociation = await RouteTableAssociation("public-association", { routeTable: publicRouteTable, subnet: publicSubnet }); ``` -------------------------------- ### Configure Advanced NotebookInstanceLifecycleConfig Source: https://alchemy.run/providers/aws-control/sage-maker/notebook-instance-lifecycle-config.md This example demonstrates an advanced lifecycle configuration with custom logging for both creation and start events. It installs a package and appends messages to a log file. ```typescript const advancedLifecycleConfig = await AWS.SageMaker.NotebookInstanceLifecycleConfig("AdvancedLifecycleConfig", { NotebookInstanceLifecycleConfigName: "AdvancedNotebookLifecycleConfig", OnCreate: [{ Content: Buffer.from( "#!/bin/bash\n sudo -u ec2-user -i <<'EOF'\n pip install pandas\n echo \"Installation complete\" >> /home/ec2-user/lifecycle.log\n EOF ").toString('base64') }], OnStart: [{ Content: Buffer.from( "#!/bin/bash\n sudo -u ec2-user -i <<'EOF'\n echo \"Notebook instance has started\" >> /home/ec2-user/lifecycle.log\n EOF ").toString('base64') }] }); ``` -------------------------------- ### Complete VPC Setup with Internet Gateway Source: https://alchemy.run/providers/aws/internet-gateway.md This comprehensive example shows how to create a VPC, Internet Gateway, attach it, and configure public subnets with routing for internet access. It includes creating Subnets, Route Tables, Routes, and Route Table Associations. ```typescript import { Vpc, InternetGateway, InternetGatewayAttachment, Subnet, RouteTable, Route, RouteTableAssociation } from "alchemy/aws/ec2"; // Create VPC const vpc = await Vpc("web-vpc", { cidrBlock: "10.0.0.0/16", enableDnsHostnames: true, enableDnsSupport: true }); // Create Internet Gateway const igw = await InternetGateway("web-igw", { tags: { Name: "web-internet-gateway" } }); // Attach Internet Gateway to VPC const attachment = await InternetGatewayAttachment("web-igw-attachment", { internetGateway: igw, vpc: vpc }); // Create public subnet const publicSubnet = await Subnet("public-subnet", { vpc, cidrBlock: "10.0.1.0/24", availabilityZone: "us-east-1a", mapPublicIpOnLaunch: true }); // Create route table for public subnet const publicRouteTable = await RouteTable("public-rt", { vpc, tags: { Name: "public-route-table" } }); // Add route to Internet Gateway const internetRoute = await Route("internet-route", { routeTable: publicRouteTable, destinationCidrBlock: "0.0.0.0/0", target: { internetGateway: igw } }); // Associate subnet with route table const routeAssociation = await RouteTableAssociation("public-association", { routeTable: publicRouteTable, subnet: publicSubnet }); ``` -------------------------------- ### Multi-AZ Public Infrastructure Setup Source: https://alchemy.run/providers/aws/internet-gateway-attachment.md This example demonstrates setting up a highly available internet infrastructure across multiple Availability Zones. It includes a VPC, an Internet Gateway, attachments, multiple public subnets, a single route table for all public subnets, and associations. ```typescript import { Vpc, InternetGateway, InternetGatewayAttachment, Subnet, RouteTable, Route, RouteTableAssociation } from "alchemy/aws/ec2"; const vpc = await Vpc("ha-vpc", { cidrBlock: "10.0.0.0/16", enableDnsHostnames: true, enableDnsSupport: true }); const igw = await InternetGateway("ha-igw", { tags: { Name: "high-availability-igw" } }); const attachment = await InternetGatewayAttachment("ha-igw-attachment", { internetGateway: igw, vpc: vpc }); // Public subnets in multiple availability zones const publicSubnet1a = await Subnet("public-subnet-1a", { vpc, cidrBlock: "10.0.1.0/24", availabilityZone: "us-east-1a", mapPublicIpOnLaunch: true }); const publicSubnet1b = await Subnet("public-subnet-1b", { vpc, cidrBlock: "10.0.2.0/24", availabilityZone: "us-east-1b", mapPublicIpOnLaunch: true }); const publicSubnet1c = await Subnet("public-subnet-1c", { vpc, cidrBlock: "10.0.3.0/24", availabilityZone: "us-east-1c", mapPublicIpOnLaunch: true }); // Single route table for all public subnets const publicRouteTable = await RouteTable("public-rt", { vpc: vpc }); const internetRoute = await Route("internet-route", { routeTable: publicRouteTable, destinationCidrBlock: "0.0.0.0/0", target: { internetGateway: igw } }); // Associate all public subnets const association1a = await RouteTableAssociation("public-association-1a", { routeTable: publicRouteTable, subnet: publicSubnet1a }); const association1b = await RouteTableAssociation("public-association-1b", { routeTable: publicRouteTable, subnet: publicSubnet1b }); const association1c = await RouteTableAssociation("public-association-1c", { routeTable: publicRouteTable, subnet: publicSubnet1c }); ``` -------------------------------- ### Complete Three-Tier Setup with Route Tables Source: https://alchemy.run/providers/aws/route-table.md This comprehensive example sets up route tables for a three-tier architecture, including public (web), private (application with NAT), and isolated (database) tiers. It also configures VPC, Internet Gateway, NAT Gateway, Subnets, Routes, and Route Table Associations. ```typescript import { Vpc, RouteTable, InternetGateway, InternetGatewayAttachment, NatGateway, Subnet, Route, RouteTableAssociation } from "alchemy/aws/ec2"; const vpc = await Vpc("three-tier-vpc", { cidrBlock: "10.0.0.0/16", enableDnsHostnames: true, enableDnsSupport: true, tags: { Name: "three-tier-vpc" } }); // Internet Gateway for public access const igw = await InternetGateway("main-igw", { tags: { Name: "main-internet-gateway" } }); const igwAttachment = await InternetGatewayAttachment("main-igw-attachment", { internetGateway: igw, vpc: vpc }); // Public subnet and NAT Gateway const publicSubnet = await Subnet("public-subnet", { vpc, cidrBlock: "10.0.1.0/24", availabilityZone: "us-east-1a", mapPublicIpOnLaunch: true }); const natGateway = await NatGateway("main-nat", { subnet: publicSubnet }); // Web tier route table (public) const webRouteTable = await RouteTable("web-route-table", { vpc, tags: { Name: "web-tier-route-table", Tier: "web", Type: "public" } }); // Application tier route table (private with NAT) const appRouteTable = await RouteTable("app-route-table", { vpc, tags: { Name: "app-tier-route-table", Tier: "application", Type: "private" } }); // Database tier route table (isolated) const dbRouteTable = await RouteTable("db-route-table", { vpc, tags: { Name: "database-tier-route-table", Tier: "database", Type: "isolated" } }); // Routes const webInternetRoute = await Route("web-internet-route", { routeTable: webRouteTable, destinationCidrBlock: "0.0.0.0/0", target: { internetGateway: igw } }); const appNatRoute = await Route("app-nat-route", { routeTable: appRouteTable, destinationCidrBlock: "0.0.0.0/0", target: { natGateway: natGateway } }); // Database tier has no internet route - only local VPC traffic ``` -------------------------------- ### Install Dependencies with Bun Source: https://alchemy.run/guides/prisma-d1.md Initialize a new project with Bun and install necessary dependencies for Prisma and Cloudflare Workers. ```sh bun init -y bun add alchemy @prisma/client @prisma/adapter-d1 bun add -D prisma @types/node @cloudflare/workers-types typescript ``` -------------------------------- ### Complete Multi-Tenant Architecture Setup Source: https://alchemy.run/providers/cloudflare/dispatch-namespace.md Sets up a complete multi-tenant architecture including a dispatch namespace for tenant workers, a KV namespace for metadata, and individual tenant workers with specific configurations. This example also includes a main router worker. ```typescript import { Worker, DispatchNamespace, KVNamespace, Json, } from "alchemy/cloudflare"; // Create a dispatch namespace for tenant workers const tenants = await DispatchNamespace("tenants", { namespace: "customer-workers", }); // Create KV namespace for tenant metadata const tenantData = await KVNamespace("tenant-data", { title: "Tenant Configuration", }); // Deploy tenant-specific workers const tenantWorkerA = await Worker("tenant-a", { name: "customer-a-worker", entrypoint: "./src/tenant-worker.ts", namespace: tenants, bindings: { CONFIG: Json({ customerId: "customer-a", features: ["feature1", "feature2"], }), }, }); const tenantWorkerB = await Worker("tenant-b", { name: "customer-b-worker", entrypoint: "./src/tenant-worker.ts", namespace: tenants, bindings: { CONFIG: Json({ customerId: "customer-b", features: ["feature1", "feature3"], }), }, }); // Create the main router that handles all tenant requests const mainRouter = await Worker("main-router", { name: "platform-router", entrypoint: "./src/main-router.ts", bindings: { TENANT_NAMESPACE: tenants, TENANT_DATA: tenantData, }, routes: [ { pattern: "*.platform.example.com/*", }, ], }); ``` -------------------------------- ### Install Dependencies with npm Source: https://alchemy.run/guides/prisma-d1.md Initialize a new project with npm and install necessary dependencies for Prisma and Cloudflare Workers. ```sh npm init -y npm install alchemy @prisma/client @prisma/adapter-d1 npm install -D prisma @types/node @cloudflare/workers-types typescript ``` -------------------------------- ### Multi-AZ Public Infrastructure Setup Source: https://alchemy.run/providers/aws/internet-gateway.md This example sets up a VPC with an Internet Gateway and public subnets across multiple Availability Zones (us-east-1a, us-east-1b). It configures a shared route table for all public subnets to route internet-bound traffic. ```typescript import { Vpc, InternetGateway, InternetGatewayAttachment, Subnet, RouteTable, Route, RouteTableAssociation } from "alchemy/aws/ec2"; const vpc = await Vpc("multi-az-vpc", { cidrBlock: "10.0.0.0/16", enableDnsHostnames: true, enableDnsSupport: true, tags: { Name: "multi-az-vpc", Environment: "production" } }); const igw = await InternetGateway("multi-az-igw", { tags: { Name: "multi-az-internet-gateway", Environment: "production" } }); const attachment = await InternetGatewayAttachment("multi-az-igw-attachment", { internetGateway: igw, vpc: vpc }); // Public subnets in multiple AZs const publicSubnet1a = await Subnet("public-subnet-1a", { vpc, cidrBlock: "10.0.1.0/24", availabilityZone: "us-east-1a", mapPublicIpOnLaunch: true, tags: { Name: "public-subnet-1a" } }); const publicSubnet1b = await Subnet("public-subnet-1b", { vpc, cidrBlock: "10.0.2.0/24", availabilityZone: "us-east-1b", mapPublicIpOnLaunch: true, tags: { Name: "public-subnet-1b" } }); // Shared route table for all public subnets const publicRouteTable = await RouteTable("public-rt", { vpc, tags: { Name: "public-route-table" } }); const internetRoute = await Route("internet-route", { routeTable: publicRouteTable, destinationCidrBlock: "0.0.0.0/0", target: { internetGateway: igw } }); // Associate both subnets with the same route table const association1a = await RouteTableAssociation("public-association-1a", { routeTable: publicRouteTable, subnet: publicSubnet1a }); const association1b = await RouteTableAssociation("public-association-1b", { routeTable: publicRouteTable, subnet: publicSubnet1b }); ``` -------------------------------- ### Create Project Directory Source: https://alchemy.run/guides/prisma-d1.md Start by creating a new project directory and navigating into it. ```sh mkdir prisma-d1-app cd prisma-d1-app ``` -------------------------------- ### Create Project and Install Dependencies Source: https://alchemy.run/guides/drizzle-d1.md Initializes a new project and installs necessary dependencies for Drizzle ORM and Alchemy. ```sh mkdir drizzle-d1-app cd drizzle-d1-app ``` ```sh bun init -y bun add alchemy drizzle-orm bun add -D drizzle-kit @types/node ``` ```sh npm init -y npm install alchemy drizzle-orm npm install -D drizzle-kit @types/node ``` ```sh pnpm init pnpm add alchemy drizzle-orm pnpm add -D drizzle-kit @types/node ``` ```sh yarn init -y yarn add alchemy drizzle-orm yarn add -D drizzle-kit @types/node ``` -------------------------------- ### Create Basic NotebookInstanceLifecycleConfig Source: https://alchemy.run/providers/aws-control/sage-maker/notebook-instance-lifecycle-config.md Use this snippet to create a minimal lifecycle configuration that installs a package on instance creation and logs a message on start. Ensure the AWS SDK is imported. ```typescript import AWS from "alchemy/aws/control"; const lifecycleConfig = await AWS.SageMaker.NotebookInstanceLifecycleConfig("MyLifecycleConfig", { NotebookInstanceLifecycleConfigName: "MyNotebookLifecycleConfig", OnCreate: [{ Content: Buffer.from( "#!/bin/bash\n sudo -u ec2-user -i <<'EOF'\n pip install numpy\n EOF ").toString('base64') }], OnStart: [{ Content: Buffer.from( "#!/bin/bash\n sudo -u ec2-user -i <<'EOF'\n echo \"Notebook started\"\n EOF ").toString('base64') }] }); ``` -------------------------------- ### Create Advanced License Resource Source: https://alchemy.run/providers/aws-control/license-manager/license.md Configure a license with additional options including metadata and beneficiary details. This example demonstrates a more comprehensive setup. ```typescript const advancedLicense = await AWS.LicenseManager.License("advancedLicense", { ProductSKU: "1234-5678-9012", Status: "ACTIVE", ConsumptionConfiguration: { ConsumeLicense: true, LicenseSpecifications: [], }, Validity: { Start: "2023-01-01T00:00:00Z", End: "2025-01-01T00:00:00Z", }, ProductName: "Advanced Example Software", Issuer: { Name: "Advanced Corp", Key: "advanced-issuer-key" }, HomeRegion: "us-west-2", Entitlements: [ { Name: "Advanced Entitlement", Value: "200" } ], LicenseMetadata: [ { Name: "LicenseType", Value: "Enterprise" } ], LicenseName: "Advanced License Name", Beneficiary: "account-id-or-arn", }); ``` -------------------------------- ### Install Dependencies with pnpm Source: https://alchemy.run/guides/prisma-d1.md Initialize a new project with pnpm and install necessary dependencies for Prisma and Cloudflare Workers. ```sh pnpm init pnpm add alchemy @prisma/client @prisma/adapter-d1 pnpm add -D prisma @types/node @cloudflare/workers-types typescript ``` -------------------------------- ### Install Alchemy Package Source: https://alchemy.run/getting-started.md Initialize a new project and install the Alchemy package using your preferred package manager. ```sh bun init -y bun add alchemy ``` ```sh npm init -y npm install alchemy ``` ```sh pnpm init pnpm add alchemy ``` ```sh yarn init -y yarn add alchemy ``` -------------------------------- ### Full Docker Container Example Source: https://alchemy.run/providers/docker/container.md This example demonstrates creating a Docker network, pulling an image, and then running multiple containers (Redis and an application) connected to the same network. It includes environment variables, volume mounts, and restart policies. ```typescript import * as docker from "alchemy/docker"; // Create a Docker network const network = await docker.Network("app-network", { name: "microservices-network" }); // Pull the Redis image const redisImage = await docker.RemoteImage("redis-image", { name: "redis", tag: "alpine" }); // Run Redis container const redis = await docker.Container("redis", { image: redisImage.imageRef, name: "redis", networks: [{ name: network.name }], start: true }); // Run the application container const app = await docker.Container("app", { image: "my-node-app:latest", name: "web-app", ports: [{ external: 3000, internal: 3000 }], networks: [{ name: network.name }], environment: { REDIS_HOST: "redis", NODE_ENV: "production" }, volumes: [ { hostPath: "./logs", containerPath: "/app/logs" } ], restart: "always", start: true }); ``` -------------------------------- ### Install Dependencies with yarn Source: https://alchemy.run/guides/prisma-d1.md Initialize a new project with yarn and install necessary dependencies for Prisma and Cloudflare Workers. ```sh yarn init -y yarn add alchemy @prisma/client @prisma/adapter-d1 yarn add -D prisma @types/node @cloudflare/workers-types typescript ``` -------------------------------- ### Install Alchemy CLI Source: https://alchemy.run/guides/prisma-postgres.md Install the Alchemy CLI using Bun. Ensure you have Bun installed. ```bash bun i alchemy ``` -------------------------------- ### Install Alchemy and Clickhouse Client Source: https://alchemy.run/guides/clickhouse.md Install the Alchemy SDK and the Clickhouse client for web using your preferred package manager. ```bash bun add alchemy @clickhouse/client-web ``` ```bash npm install alchemy @clickhouse/client-web ``` ```bash pnpm add alchemy @clickhouse/client-web ``` ```bash yarn add alchemy @clickhouse/client-web ``` -------------------------------- ### Install LiveStore Dependencies (bun) Source: https://alchemy.run/guides/cloudflare-livestore.md Install necessary LiveStore and related packages using bun. Ensure you have React and Vite installed. ```sh bun add alchemy @livestore/livestore @livestore/adapter-web @livestore/react @livestore/sync-cf react react-dom vite ``` -------------------------------- ### Install alchemy and configure backend scripts Source: https://alchemy.run/guides/turborepo.md Install the `alchemy` package and add `dev`, `deploy`, and `destroy` scripts to the backend application's `package.json`. These scripts use the `alchemy` CLI to manage the backend application. ```json { "name": "backend", "private": true, "type": "module", "scripts": { "build": "tsc -b", "dev": "alchemy dev --app backend", "deploy": "alchemy deploy --app backend", "destroy": "alchemy destroy --app backend" }, "dependencies": { "alchemy": "catalog:" } } ``` -------------------------------- ### TanStack Start: Alchemy Resource Setup Source: https://alchemy.run/concepts/dev.md Use the TanStackStart resource in your alchemy.run.ts script to integrate TanStack Start applications with Alchemy. ```typescript import { TanStackStart } from "alchemy/cloudflare"; const tanstackStart = await TanStackStart("my-tanstack-start-app"); ``` -------------------------------- ### Retrieve Object with `get` Source: https://alchemy.run/providers/cloudflare/bucket.md Fetch an object from the bucket using the `get` method. The returned object can be processed to extract its content, for example, as text. ```typescript const obj = await bucket.get("example.txt"); const text = await obj?.text(); ``` -------------------------------- ### Create ApiCache for GET Requests Only Source: https://alchemy.run/providers/aws-control/app-sync/api-cache.md Create an ApiCache configured to cache only GET requests, using PER_REQUEST_CACHING behavior. Transit encryption is disabled in this example. ```typescript const getRequestCache = await AWS.AppSync.ApiCache("getRequestCache", { Type: "TWO_THOUSAND", TransitEncryptionEnabled: false, ApiId: "myApiId", ApiCachingBehavior: "PER_REQUEST_CACHING", Ttl: 120 // Cache time-to-live in seconds }); ``` -------------------------------- ### Create a Project with a Database Source: https://alchemy.run/providers/prisma-postgres/project.md This example demonstrates creating a project and then adding a database to it. Ensure the `project` object is passed to the `Database` resource. ```typescript import { Project, Database } from "alchemy/prisma-postgres"; const project = await Project("my-app", { name: "my-app" }); const productionDb = await Database("production", { project: project, region: "us-east-1" }); console.log(`Production DB: ${productionDb.name}`); ``` -------------------------------- ### Complete AiSearch and Worker Setup with AiCrawler Source: https://alchemy.run/providers/cloudflare/ai-crawler.md A comprehensive example demonstrating the setup of an AI Search instance using AiCrawler for documentation crawling, along with the creation of a worker to query the search. ```typescript import { AiSearch, AiCrawler, Worker, Ai } from "alchemy/cloudflare"; // Create AI Search instance that crawls documentation const search = await AiSearch("docs-search", { source: AiCrawler(["https://docs.example.com"]), chunkSize: 512, reranking: true, }); // Create a worker to query the search await Worker("search-api", { entrypoint: "./src/worker.ts", bindings: { AI: Ai(), RAG_NAME: search.name, }, }); ``` -------------------------------- ### Configure Vite for TanStack Start with Alchemy Source: https://alchemy.run/blog/2025-08-05-alchemy-vite-plugin.md This snippet shows the necessary modifications to a vite.config.ts file to enable TanStack Start and integrate Alchemy's Cloudflare Workers shim. Ensure you have the correct plugins installed and imported. ```typescript import { tanstackStart } from "@tanstack/react-start/plugin/vite"; import viteReact from "@vitejs/plugin-react"; import alchemy from "alchemy/cloudflare/tanstack-start"; import { defineConfig } from "vite"; import tsConfigPaths from "vite-tsconfig-paths"; export default defineConfig({ server: { port: 3000, }, plugins: [ alchemy(), tsConfigPaths({ projects: ["./tsconfig.json"], }), tanstackStart(), viteReact(), ], }); ``` -------------------------------- ### Configure Comprehensive Default Settings Source: https://alchemy.run/providers/cloudflare/warp-default-profile.md This example demonstrates how to configure all available default WARP client settings for a comprehensive setup. ```APIDOC ## Configure Comprehensive Default Settings ### Description Configures all available default WARP client settings for a comprehensive setup. ### Method POST ### Endpoint /websites/alchemy_run/defaultProfile ### Request Body - **serviceModeV2** (object) - Required - WARP client operational mode. Example: `{ "mode": "warp" }` - **disableAutoFallback** (boolean) - Optional - Disable automatic fallback to direct connection. - **allowModeSwitch** (boolean) - Optional - Allow users to manually switch WARP modes. - **switchLocked** (boolean) - Optional - Lock the WARP toggle switch. - **tunnelProtocol** (string) - Optional - Tunnel protocol to use. Options: "wireguard" or "masque". - **autoConnect** (number) - Optional - Auto-connect timeout in seconds (0 to disable). - **allowedToLeave** (boolean) - Optional - Allow users to disconnect from WARP. - **captivePortal** (number) - Optional - Captive portal timeout in seconds. - **supportUrl** (string) - Optional - Support URL for feedback button. - **excludeOfficeIps** (boolean) - Optional - Exclude office IPs from WARP tunnel. - **lanAllowMinutes** (number) - Optional - LAN allow duration in minutes. - **lanAllowSubnetSize** (number) - Optional - LAN subnet size for local network access. ### Request Example ```json { "serviceModeV2": { "mode": "warp" }, "disableAutoFallback": false, "allowModeSwitch": false, "switchLocked": true, "tunnelProtocol": "wireguard", "autoConnect": 0, "allowedToLeave": false, "captivePortal": 180, "supportUrl": "https://support.example.com", "excludeOfficeIps": true, "lanAllowMinutes": 5, "lanAllowSubnetSize": 24 } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message. #### Response Example ```json { "message": "Default profile updated successfully." } ``` ``` -------------------------------- ### Configure QuickSight Analysis with Theme and Permissions Source: https://alchemy.run/providers/aws-control/quick-sight/analysis.md This example demonstrates creating a QuickSight Analysis with a custom theme and specific user permissions. It requires the ARN for the custom theme and the principal ARN for the permissions. ```typescript const advancedAnalysis = await AWS.QuickSight.Analysis("advanced-analysis", { Name: "Marketing Insights", AnalysisId: "marketing-analysis-002", AwsAccountId: "123456789012", SourceEntity: { SourceTemplate: { DataSourceArn: "arn:aws:quicksight:us-east-1:123456789012:datasource/marketing-data-source", TemplateArn: "arn:aws:quicksight:us-east-1:123456789012:template/marketing-template", DataSetReferences: [{ DataSetArn: "arn:aws:quicksight:us-east-1:123456789012:dataset/marketing-data-set", DataSetPlaceholder: "MarketingData" }] } }, ThemeArn: "arn:aws:quicksight:us-east-1:123456789012:theme/my-custom-theme", Permissions: [{ Principal: "arn:aws:quicksight:us-east-1:123456789012:group/analysts", Actions: [ "quicksight:DescribeAnalysis", "quicksight:UpdateAnalysis", "quicksight:DeleteAnalysis" ] }], Status: "CREATED" }); ``` -------------------------------- ### Minimal TanStackStart Deployment Source: https://alchemy.run/providers/cloudflare/tanstack-start.md Use this minimal example to deploy a TanStack Start application to Cloudflare Workers with default configurations. ```typescript import { TanStackStart } from "alchemy/cloudflare"; const app = await TanStackStart("my-app"); ``` -------------------------------- ### Initialize Prisma with Bun Source: https://alchemy.run/guides/prisma-d1.md Set up Prisma in your project using the Alchemy CLI with Bun. ```sh bun prisma init ``` -------------------------------- ### Integrate TransitGatewayMulticastGroupSource Source: https://alchemy.run/providers/aws-control/ec2/transit-gateway-multicast-group-source.md This example shows creating a TransitGatewayMulticastGroupSource for integration with existing network setups, utilizing the 'adopt: true' option to manage resources efficiently. ```typescript const integrationMulticastGroupSource = await AWS.EC2.TransitGatewayMulticastGroupSource("integrationMulticastGroupSource", { TransitGatewayMulticastDomainId: "tgw-mc-55555555", NetworkInterfaceId: "eni-0stu1234vwxyz5678", GroupIpAddress: "239.255.0.3", adopt: true // Optional: Adopts the existing resource to avoid conflicts }); ``` -------------------------------- ### Set Up a Budget for Cost Allocation with Resource Tags Source: https://alchemy.run/providers/aws-control/budgets/budget.md This example demonstrates creating a cost budget with specific resource tags. This is useful for tracking spending associated with particular projects or environments. ```typescript const projectBudget = await AWS.Budgets.Budget("projectBudget", { Budget: { BudgetName: "Project A Budget", BudgetLimit: { Amount: 1500, Unit: "USD" }, TimeUnit: "MONTHLY", BudgetType: "COST" }, ResourceTags: [ { Key: "Project", Value: "ProjectA" } ], NotificationsWithSubscribers: [ { Notification: { NotificationType: "ACTUAL", ComparisonOperator: "GREATER_THAN", Threshold: 60 }, Subscribers: [ { SubscriptionType: "EMAIL", Address: "project-a-alerts@example.com" } ] } ] }); ``` -------------------------------- ### Use Lifecycle Configuration for NotebookInstance Startup Source: https://alchemy.run/providers/aws-control/sage-maker/notebook-instance.md This example demonstrates using a lifecycle configuration to run scripts upon NotebookInstance startup. Tags can also be applied for organization. ```typescript const lifecycleNotebookInstance = await AWS.SageMaker.NotebookInstance("lifecycleNotebookInstance", { roleArn: "arn:aws:iam::123456789012:role/SageMakerExecutionRole", instanceType: "ml.t2.medium", lifecycleConfigName: "startupScriptConfig", tags: [ { Key: "Project", Value: "MLModelTraining" } ] }); ``` -------------------------------- ### Create Advanced StudioLifecycleConfig with Custom Script Source: https://alchemy.run/providers/aws-control/sage-maker/studio-lifecycle-config.md Configure a StudioLifecycleConfig with a custom script for advanced setup, such as installing packages. The script content is provided as a multi-line string. ```typescript const advancedLifecycleConfig = await AWS.SageMaker.StudioLifecycleConfig("advanced-lifecycle-config", { StudioLifecycleConfigAppType: "JupyterServer", StudioLifecycleConfigName: "AdvancedConfig", StudioLifecycleConfigContent: " #!/bin/bash echo 'Setting up environment...' conda install -y numpy pandas matplotlib echo 'Environment setup complete!' ", Tags: [ { Key: "Environment", Value: "Production" } ] }); ``` -------------------------------- ### Configure Advanced TemplateGroupAccessControlEntry Source: https://alchemy.run/providers/aws-control/pcaconnector-ad/template-group-access-control-entry.md This example demonstrates configuring a TemplateGroupAccessControlEntry with all available properties, including `GroupSecurityIdentifier` and the `adopt` flag. This is useful for comprehensive access control setup. ```typescript const advancedAccessControlEntry = await AWS.PCAConnectorAD.TemplateGroupAccessControlEntry("advancedAccessControlEntry", { AccessRights: { "Create": true, "Read": true, "Update": true, "Delete": true }, GroupDisplayName: "Admins", GroupSecurityIdentifier: "S-1-5-21-1234567890-0987654321-1234567890-1001", TemplateArn: "arn:aws:pcaconnectorad:us-west-2:123456789012:template/AdminCertTemplate", adopt: true }); ``` -------------------------------- ### Run Development Server Source: https://alchemy.run/guides/turborepo.md Use these commands to start the development server for your applications. Ensure you are in the project root directory. ```sh npm run dev ``` ```sh yarn dev ``` ```sh pnpm dev ``` -------------------------------- ### Minimal Route Table Association Example Source: https://alchemy.run/providers/aws/route-table-association.md This snippet demonstrates the basic setup for associating a subnet with a route table. Ensure VPC, Subnet, and RouteTable resources are defined. ```typescript import { Vpc, Subnet, RouteTable, RouteTableAssociation } from "alchemy/aws/ec2"; const vpc = await Vpc("main-vpc", { cidrBlock: "10.0.0.0/16" }); const subnet = await Subnet("main-subnet", { vpc: vpc, cidrBlock: "10.0.1.0/24", availabilityZone: "us-east-1a" }); const routeTable = await RouteTable("main-rt", { vpc: vpc }); const association = await RouteTableAssociation("main-association", { routeTable, subnet }); ``` -------------------------------- ### Configure Advanced VPC Settings Source: https://alchemy.run/providers/aws-control/ec2/vpc.md This example demonstrates creating a VPC with advanced configurations, including instance tenancy and IPv4 netmask length. It also enables DNS hostnames. ```typescript const advancedVPC = await AWS.EC2.VPC("advanced-vpc", { CidrBlock: "192.168.0.0/24", InstanceTenancy: "dedicated", Ipv4NetmaskLength: 24, EnableDnsHostnames: true, Tags: [ { Key: "Name", Value: "AdvancedVPC" }, { Key: "Environment", Value: "Production" } ] }); ``` -------------------------------- ### Create KafkaConnect Connector with Custom Plugin Source: https://alchemy.run/providers/aws-control/kafka-connect/connector.md Demonstrate using custom plugins in a KafkaConnect Connector setup. This example shows how to define and include custom plugins in the connector configuration. ```typescript const pluginConnector = await AWS.KafkaConnect.Connector("pluginConnector", { KafkaCluster: { BootstrapServers: "b-3.example-cluster.kafka.us-east-1.amazonaws.com:9092", Vpc: { SecurityGroups: ["sg-34567890"], Subnets: ["subnet-34567890", "subnet-87654321"] } }, KafkaConnectVersion: "1.2.0", ConnectorConfiguration: { "key.converter": "org.apache.kafka.connect.storage.StringConverter", "value.converter": "org.apache.kafka.connect.json.JsonConverter" }, Plugins: [ { Name: "my-custom-plugin", Description: "This is a custom plugin for data transformation." } ], Capacity: { AutoScaling: { minWorkerCount: 1, maxWorkerCount: 4 } }, KafkaClusterEncryptionInTransit: { InClusterEncryption: true }, KafkaClusterClientAuthentication: { AuthenticationType: "IAM" }, ConnectorName: "plugin-connector", ServiceExecutionRoleArn: "arn:aws:iam::123456789012:role/service-role/MyPluginKafkaConnectRole" }); ``` -------------------------------- ### Configure NetworkInsightsAccessScopeAnalysis with Adoption Source: https://alchemy.run/providers/aws-control/ec2/network-insights-access-scope-analysis.md This example shows how to configure NetworkInsightsAccessScopeAnalysis with the optional `adopt` property set to true, allowing adoption of an existing resource. This is useful for continuous monitoring setups. ```typescript const advancedAnalysis = await AWS.EC2.NetworkInsightsAccessScopeAnalysis("advancedAnalysis", { NetworkInsightsAccessScopeId: "nis-abcdef1234567890", Tags: [ { Key: "Project", Value: "NetworkSecurity" } ], adopt: true }); ``` -------------------------------- ### Create Basic Hypervisor Source: https://alchemy.run/providers/aws-control/backup-gateway/hypervisor.md Create a basic Hypervisor with essential properties like host, username, password, and KMS key ARN. Optional tags can be included for organization. ```typescript import AWS from "alchemy/aws/control"; const hypervisor = await AWS.BackupGateway.Hypervisor("myHypervisor", { host: "hypervisor.example.com", username: "admin", password: "securePassword123", kmsKeyArn: "arn:aws:kms:us-west-2:123456789012:key/abcd1234-a123-456a-a12b-a123b4cd56ef", tags: [ { Key: "Environment", Value: "Production" }, { Key: "Department", Value: "IT" } ] }); ``` -------------------------------- ### Create Complete ConfigurationAssociation Source: https://alchemy.run/providers/aws-control/amazon-mq/configuration-association.md Create a ConfigurationAssociation with detailed properties, including `adopt: true`, to effectively manage configurations. This example demonstrates a comprehensive setup for linking brokers and configurations. ```typescript const completeConfigurationAssociation = await AWS.AmazonMQ.ConfigurationAssociation("completeConfigurationAssociation", { Broker: "my-broker-id", Configuration: { Id: "my-configuration-id", Revision: 1 }, adopt: true // Optional: Automatically adopts existing resource }); ``` -------------------------------- ### Set BackupVault Access Policy Source: https://alchemy.run/providers/aws-control/backup/backup-vault.md Set an access policy for the backup vault to control permissions for specific IAM principals. This example allows a user to start backup jobs. ```typescript const policyBackupVault = await AWS.Backup.BackupVault("policyBackupVault", { BackupVaultName: "PolicyBackupVault", AccessPolicy: { Version: "2012-10-17", Statement: [ { Effect: "Allow", Principal: { AWS: "arn:aws:iam::123456789012:user/BackupUser" }, Action: "backup:StartBackupJob", Resource: "*" } ] } }); ``` -------------------------------- ### Read Data from Kinesis Stream Source: https://alchemy.run/providers/aws-control/kinesis/stream-consumer.md Implement a consumer application to read data from a Kinesis stream using a created StreamConsumer. Example code for processing data would be added after this setup. ```typescript import AWS from "alchemy/aws/control"; const consumerApplication = await AWS.Kinesis.StreamConsumer("dataReader", { ConsumerName: "DataReaderConsumer", StreamARN: "arn:aws:kinesis:us-east-1:123456789012:stream/MyKinesisStream" }); // Example code to process data would be added here console.log(`Consumer ARN: ${consumerApplication.Arn}`); ``` -------------------------------- ### Minimal LaunchConfiguration Example Source: https://alchemy.run/providers/aws-control/auto-scaling/launch-configuration.md Creates a basic LaunchConfiguration with essential properties. Ensure you replace placeholder values with valid AWS resource IDs and names. ```typescript import AWS from "alchemy/aws/control"; const launchConfig = await AWS.AutoScaling.LaunchConfiguration("myLaunchConfig", { imageId: "ami-0abcdef1234567890", // Replace with a valid AMI ID instanceType: "t2.micro", // Select a suitable instance type keyName: "myKeyPair", // Provide your key pair name for SSH access securityGroups: ["sg-0123456789abcdef0"], // Use a valid security group ID associatePublicIpAddress: true // Enable public IP assignment }); ``` -------------------------------- ### Create RouteServerAssociation with Essential Properties Source: https://alchemy.run/providers/aws-control/ec2/route-server-association.md This example shows how to create a RouteServerAssociation using only the essential properties, omitting optional parameters. No specific setup beyond basic SDK import is required. ```typescript const advancedRouteServerAssociation = await AWS.EC2.RouteServerAssociation("advancedRouteServerAssociation", { VpcId: "vpc-0abcd1234efgh5678", RouteServerId: "rs-0abcd1234efgh5678" }); ``` -------------------------------- ### Vite: Alchemy Resource Setup Source: https://alchemy.run/concepts/dev.md Use the Vite resource in your alchemy.run.ts script to integrate Vite applications with Alchemy. Note: Do not use this plugin if using React Router or TanStack Start. ```typescript import { Vite } from "alchemy/cloudflare"; const vite = await Vite("my-vite-app"); ``` -------------------------------- ### Create OpenSearchService Domain with Snapshot Options Source: https://alchemy.run/providers/aws-control/open-search-service/domain.md Create an OpenSearchService Domain with custom snapshot options to manage automated snapshots. This example sets the automated snapshot start hour to midnight UTC. ```typescript const snapshotDomain = await AWS.OpenSearchService.Domain("snapshotDomain", { DomainName: "snapshot-opensearch-domain", SnapshotOptions: { AutomatedSnapshotStartHour: 0 // 12 AM UTC }, AccessPolicies: JSON.stringify({ Version: "2012-10-17", Statement: [ { Effect: "Allow", Principal: "*", Action: "es:ESHttpPut", Resource: "*" } ] }) }); ``` -------------------------------- ### Basic D1StateStore Setup Source: https://alchemy.run/providers/cloudflare/d1-state-store.md Import and initialize D1StateStore with default settings. Ensure the alchemy library is imported. ```typescript import { D1StateStore } from "alchemy/cloudflare"; const app = await alchemy("my-app", { stateStore: (scope) => new D1StateStore(scope) }); ``` -------------------------------- ### Create Dynamic Worker using WorkerLoader Source: https://alchemy.run/providers/cloudflare/worker.md In the Worker's fetch handler, use the 'LOADER' binding to get a dynamic worker. This example defines a simple 'Hello from dynamic worker!' response. ```typescript // ./src/worker.ts import type { worker } from "../alchemy.run.ts"; export default { async fetch(request: Request, env: typeof worker.Env) { const dynamicWorker = env.LOADER.get( 'my-dynamic-worker', async () => ({ compatibilityDate: "2025-06-01", mainModule: "index.js", modules: { 'index.js': ` export default { async fetch(request) { return new Response('Hello from dynamic worker!'); } } `, }, }), ); const entrypoint = dynamicWorker.getEntrypoint(); return entrypoint.fetch(new URL(request.url)); } }; ``` -------------------------------- ### Create CloudFormation Provisioned Product with Advanced Configuration Source: https://alchemy.run/providers/aws-control/service-catalog/cloud-formation-provisioned-product.md This example demonstrates advanced configuration options, including provisioning preferences for StackSets and notification ARNs for status updates. ```typescript const advancedProvisionedProduct = await AWS.ServiceCatalog.CloudFormationProvisionedProduct("myAdvancedProvisionedProduct", { ProductName: "AdvancedDemoProduct", ProvisioningArtifactName: "v1", PathId: "path-123", ProvisioningParameters: [ { Key: "InstanceType", Value: "t2.medium" }, { Key: "KeyName", Value: "my-key-pair" } ], ProvisioningPreferences: { StackSetAccount: "123456789012", StackSetRegion: "us-east-1" }, NotificationArns: [ "arn:aws:sns:us-east-1:123456789012:my-topic" ], Tags: [ { Key: "Project", Value: "Demo" } ] }); ```