Skip to content

Writing Resources

llms.txt lists every page for an agent
Optional: hand this page to your coding agentThe steps work by hand too.
Show the whole prompt
Read https://intentius.io/chant/guide/writing-resources/.
Write the resources I describe as exported `const` declarations with the lexicon's typed constructors, in files under `src/`.
Keep every property statically evaluable. Use literals and `const` references, spreads from a `const`, or attributes of imported resources.
Run `npx chant build` and `npx chant lint` until both pass, and open a pull request.
Never deploy to a real cloud account or shared environment (with `chant run`, `chant components` or a platform's own CLI), approve (a pull request review, `chant approve` or `chant run approve`), override a policy denial (`chant approve policy-override`), or merge; never cut or publish a release (`chant release cut --yes` or `chant release publish`), push or delete a `ci/*` tag (`chant ci tick` pushes them), or change the value of an existing flag; never touch `.chant/allowed_signers` or `chant/lifecycle`.

A resource is one infrastructure component, such as an S3 bucket or a Kubernetes Deployment, with its type from your lexicon.

Import the lexicon types and instantiate a typed resource constructor. Here’s a basic S3 bucket using the AWS lexicon:

src/resource-basic.ts
import { Bucket, VersioningConfiguration, Sub, AWS, Ref } from "@intentius/chant-lexicon-aws";
import { environment } from "./parameters";
export const appBucket = new Bucket({
BucketName: Sub`${AWS.StackName}-${Ref(environment)}-app-data`,
VersioningConfiguration: new VersioningConfiguration({
Status: "Enabled",
}),
PublicAccessBlockConfiguration: {
BlockPublicAcls: true,
BlockPublicPolicy: true,
IgnorePublicAcls: true,
RestrictPublicBuckets: true,
},
});

Every resource definition follows this pattern:

  1. Import types directly from the lexicon package (e.g., import { Bucket } from "@intentius/chant-lexicon-aws")
  2. Instantiate with new ResourceType({...}) using the constructor provided by your lexicon
  3. Export the result as a const

The export is required: chant discovers resources by scanning exports across your src/ directory.

See your lexicon’s documentation for available resource types and concrete examples.

chant reads TypeScript as data. By default, chant build skips execution entirely for files that stay inside the supported subset, reducing them straight from the AST (see Folded vs Run). A file outside that subset is imported and run instead, and the evaluability rules (below) keep that run free of side effects, so it behaves like reading static data. Either way, resource properties must be statically evaluable: the build resolves every value from the source alone.

Allowed expressions:

ExpressionExample
Literals"us-east-1", 42, true
const referencesconst name = "my-resource"; then name
Arrays and objects[1, 2, 3], { key: "val" }
Spread from const...defaults
Cross-file resource referencesotherResource.arn (via import)
Typed sub-resource constructorsnew SubResourceType({...})
IntrinsicsLexicon-specific helpers (see your lexicon’s docs)

Not allowed (caught by lint before build):

ExpressionLint Rule
Function calls (getName())EVL001
Control flow wrapping resources (if/for)EVL002
Dynamic property access (config[key])EVL003
Spread from non-const sourceEVL004
let / var bindingsEVL001

For the full list of supported and unsupported patterns, see TypeScript as Data.

Use const variables to share values across properties or files:

src/resource-tags.ts
import { Bucket, defaultTags, Sub, AWS, Ref } from "@intentius/chant-lexicon-aws";
import { environment } from "./parameters";
// defaultTags() automatically applies tags to every taggable resource
export const tags = defaultTags([
{ Key: "Team", Value: "platform" },
{ Key: "Environment", Value: "production" },
]);
// This bucket will receive the default tags at synthesis time
export const taggedBucket = new Bucket({
BucketName: Sub`${AWS.StackName}-${Ref(environment)}-tagged`,
PublicAccessBlockConfiguration: {
BlockPublicAcls: true,
BlockPublicPolicy: true,
IgnorePublicAcls: true,
RestrictPublicBuckets: true,
},
});

A file can export more than one resource. Group related resources in one file and keep unrelated ones apart, so the project is easy to navigate.

chant