Skip to content

[Feature Request] Account scanner + LLM prompt generator for adopting existing resources (brownfield migration) #1412

Description

@ryan-mars

Problem

Alchemy is deliberately lightweight and AI-first, which makes greenfield development incredibly fast. However, when users have existing infrastructure (brownfield scenarios), there is currently no convenient way to bring resources under Alchemy management.

  • Terraform users can run aztfexport (or the Azure portal export) to get HCL + state.
  • Pulumi has import tools.
  • Alchemy currently requires manually writing the TypeScript declarations and then relying on adoption logic (or state refresh if the resource author implemented it — see Refresh state capability #985).

This creates a high barrier for teams migrating large accounts or wanting to adopt existing Cloudflare Workers, AWS resources, databases, buckets, etc.

Proposed Solution

Add a new scanning + LLM prompt generation feature (most likely as a new CLI command) that:

  1. Scans a cloud account/provider (AWS, Cloudflare, and any custom provider that implements the necessary hooks).
  2. Filters the scan (e.g. by region, tags, resource group, account/project, name pattern, resource type, etc.).
  3. Exports a clean, idiomatic JSON representation of the discovered resources.
  4. Generates a ready-to-use LLM prompt that includes:
    • The exported JSON data
    • Context about Alchemy’s resource model (await ResourceType("name", { props }))
    • Adoption best practices (adopt: true / state reconciliation)
    • Instructions to produce valid, idiomatic TypeScript code that can be dropped into an alchemy.run.ts file

Example CLI usage:

# Scan everything in the current AWS account
alchemy scan aws --output adoption-prompt.md

# Filtered scan
alchemy scan cloudflare --filter "type=Worker" --filter "name~my-app" --output adoption-prompt.md

# Azure example (once provider support lands)
alchemy scan azure --resource-group my-rg --output adoption-prompt.md

The output file (adoption-prompt.md) would contain something like:

You are an expert Alchemy (alchemy.run) engineer.

Here is the JSON export of existing cloud resources I want to adopt:

    {
      "provider": "aws",
      "resources": [
        {
          "type": "Bucket",
          "name": "my-data-bucket",
          "id": "my-data-bucket-12345",
          "properties": { ... },
          ...
        },
        ...
      ]
    }

Please generate complete, ready-to-run Alchemy TypeScript code that:
- Declares these resources using the correct providers (`Aws.Bucket`, `Cloudflare.Worker`, etc.)
- Uses `adopt: true` (or the current idiomatic adoption pattern) so Alchemy takes ownership without recreation
- Follows Alchemy style (async/await, proper scoping, etc.)
- Includes any necessary comments for the user

Only output the code block(s). Do not add extra commentary.

Users can then copy-paste the prompt into Claude/Codex/etc. and get production-ready Alchemy code in seconds — perfectly aligned with Alchemy’s “AI-first” philosophy.

Why JSON + LLM prompt (instead of auto-generating code)?

  • Keeps the core lightweight and deterministic.
  • Lets the user review/adjust the generated code before it touches their account.
  • Leverages the rapidly improving LLMs without baking model calls into the CLI.
  • Future-proof: we could later add an --llm flag that calls an LLM directly if desired.

Acceptance Criteria / Nice-to-Haves

  • Pluggable per-provider scanners (each provider implements scan() or similar).
  • Reasonable defaults and safety (dry-run mode, confirmation prompts, respect rate limits).
  • Output formats: --output json, --output markdown (with prompt), --output ts (future).
  • Works with local state or --state-store options.
  • Handles pagination, large accounts, and common filtering patterns.
  • Good error messages and progress indicators.
  • Docs + example in the getting-started / migration guide.

Related Issues / Context

  • Refresh state capability #985 – Refresh state capability (this feature would complement it nicely)
  • Alchemy’s existing AI-first design (“encourages the use of LLMs to create/copy/fork/modify resources”)

This feature would make Alchemy the most pleasant IaC tool for both greenfield and brownfield work, especially for teams already using LLMs in their workflow.

Happy to help implement or test once a design is agreed upon!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions