Skip to content

chant import

chant import <template-file> [flags]
chant import --from <env> [flags]

chant import reads an existing infrastructure template (e.g. a CloudFormation JSON template), detects which lexicon handles it, and generates TypeScript resource definitions. This lets you adopt chant incrementally by importing your current infrastructure rather than rewriting it from scratch.

With --from <env> it reads the live cloud/cluster instead of a file: it resolves the environment, calls each project lexicon’s exportResources() for full-fidelity config, and generates TypeScript from that. This is the cloud→code direction — the way to adopt an orphaned resource back into source.

The import process:

  1. Reads and parses the template file (JSON)
  2. Asks each lexicon plugin if it recognizes the template via detectTemplate()
  3. Uses the matching lexicon’s templateParser() to extract resources into an intermediate representation
  4. Uses the lexicon’s templateGenerator() to produce TypeScript files
  5. Organizes generated files by resource category (storage, compute, network, other)
FlagDescription
--from <env>Import from a live environment instead of a template file
-d, --lexicon <name>With --from, restrict to one lexicon (e.g. aws, k8s)
--type <ResourceType>With --from, export only resources of this type
--name <name>With --from, export only the resource with this name
--ownedWith --from, restrict to chant-owned resources — those carrying the live ownership marker
--verbatimWith --from, keep server-defaulted fields instead of stripping to declared shape
-o, --output <dir>Output directory (default: ./infra/)
--forceOverwrite existing files
Terminal window
# Import a template file
chant import template.json
# Import to a specific directory
chant import template.json --output src/
# Import live infrastructure from an environment
chant import --from prod
# Adopt a single orphaned resource back into source
chant import --from prod --name my-bucket --output src/
# Keep server-defaulted fields
chant import --from prod --verbatim
CodeMeaning
0Import completed successfully
1Error (unrecognized template format, parse error, or write failure)