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.
Defining a Preset
Section titled “Defining a Preset”Extract shared properties into exported const declarations:
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,});Using a Preset
Section titled “Using a Preset”Import the preset and use it in resource properties:
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
constbinding. Spreading fromlet,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.