Skip to content

Presets

Presets are shared default values that you reference from resource definitions. They reduce repetition when multiple resources of the same type share common configuration.

Extract shared properties into exported const declarations:

src/preset-defaults.ts
import { ServerSideEncryptionByDefault, PublicAccessBlockConfiguration } from "@intentius/chant-lexicon-aws";
export const encryptionDefault = new ServerSideEncryptionByDefault({
SSEAlgorithm: "AES256",
});
export const publicAccessBlock = new PublicAccessBlockConfiguration({
BlockPublicAcls: true,
BlockPublicPolicy: true,
IgnorePublicAcls: true,
RestrictPublicBuckets: true,
});

Import the preset and use it in resource properties:

src/preset-usage.ts
import { Bucket, BucketEncryption, ServerSideEncryptionRule, Sub, AWS, Ref } from "@intentius/chant-lexicon-aws";
import { publicAccessBlock, encryptionDefault } from "./preset-defaults";
import { environment } from "./parameters";
export const secureBucket = new Bucket({
BucketName: Sub`${AWS.StackName}-${Ref(environment)}-secure-data`,
PublicAccessBlockConfiguration: publicAccessBlock,
BucketEncryption: new BucketEncryption({
ServerSideEncryptionConfiguration: [
new ServerSideEncryptionRule({
ServerSideEncryptionByDefault: encryptionDefault,
}),
],
}),
});

Properties listed after the preset reference override the preset values.

  • The spread source must be a const binding. Spreading from let, var, or function calls triggers lint rule EVL004.
  • Preset objects are plain data — they are not resource instances.
  • Properties in the spread are merged shallowly. Nested objects are replaced entirely, not deep-merged.

See your lexicon’s documentation for working preset examples with concrete resource types.