chant import
Synopsis
Section titled “Synopsis”chant import <template-file> [flags]chant import --from <env> [flags]Description
Section titled “Description”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:
- Reads and parses the template file (JSON)
- Asks each lexicon plugin if it recognizes the template via
detectTemplate() - Uses the matching lexicon’s
templateParser()to extract resources into an intermediate representation - Uses the lexicon’s
templateGenerator()to produce TypeScript files - Organizes generated files by resource category (storage, compute, network, other)
| Flag | Description |
|---|---|
--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 |
--owned | With --from, restrict to chant-owned resources — those carrying the live ownership marker |
--verbatim | With --from, keep server-defaulted fields instead of stripping to declared shape |
-o, --output <dir> | Output directory (default: ./infra/) |
--force | Overwrite existing files |
# Import a template filechant import template.json
# Import to a specific directorychant import template.json --output src/
# Import live infrastructure from an environmentchant import --from prod
# Adopt a single orphaned resource back into sourcechant import --from prod --name my-bucket --output src/
# Keep server-defaulted fieldschant import --from prod --verbatimExit Codes
Section titled “Exit Codes”| Code | Meaning |
|---|---|
| 0 | Import completed successfully |
| 1 | Error (unrecognized template format, parse error, or write failure) |
See Also
Section titled “See Also”- Importing Templates — user guide
- Lexicon Authoring — implementing
detectTemplate()andtemplateParser()