Skip to content

Parameters & Outputs

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/getting-started/parameters-and-outputs/.
Add the CloudFormation parameters and stack outputs I describe to this project: an exported `Parameter` for each input, `Ref` or an import where a resource uses it, and `output()` for each value to expose.
Run `npx chant build -o template.json` and show me the template's `Parameters` and `Outputs` sections, then run `npx chant lint` 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`.

Parameters let you customize a stack at deploy time. Outputs expose values from the stack for use by other stacks or scripts.

This page is about Parameter, a deploy-time input that resolves when the stack applies. To vary the build itself (which environment, which tier, which resources are even produced), see Build-Time Parameters.

src/defaults.ts
import {
ServerSideEncryptionByDefault,
ServerSideEncryptionRule,
BucketEncryption,
PublicAccessBlockConfiguration,
VersioningConfiguration,
} from "@intentius/chant-lexicon-aws";
export const encryptionDefault = new ServerSideEncryptionByDefault({
SSEAlgorithm: "AES256",
});
export const encryptionRule = new ServerSideEncryptionRule({
ServerSideEncryptionByDefault: encryptionDefault,
});
export const bucketEncryption = new BucketEncryption({
ServerSideEncryptionConfiguration: [encryptionRule],
});
export const publicAccessBlock = new PublicAccessBlockConfiguration({
BlockPublicAcls: true,
BlockPublicPolicy: true,
IgnorePublicAcls: true,
RestrictPublicBuckets: true,
});
export const versioningEnabled = new VersioningConfiguration({
Status: "Enabled",
});
export const lambdaTrustPolicy = {
Version: "2012-10-17",
Statement: [
{
Effect: "Allow",
Principal: { Service: "lambda.amazonaws.com" },
Action: "sts:AssumeRole",
},
],
};
export const lambdaBasicExecutionArn =
"arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole";
src/parameter.ts
import { Parameter } from "@intentius/chant-lexicon-aws";
export const environment = new Parameter("String", {
description: "Deployment environment",
defaultValue: "dev",
});

Export a Parameter to add it to the template’s Parameters section:

src/parameter-declaration.ts
import { Parameter } from "@intentius/chant-lexicon-aws";
export const environment = new Parameter("String", {
description: "Deployment environment",
defaultValue: "dev",
});

The first argument is the CloudFormation parameter type ("String", "Number", "List<Number>", "CommaDelimitedList", or an AWS SSM type). The second argument supports:

  • description — human-readable description
  • defaultValue — value used when none is provided at deploy time

The exported variable name becomes the logical parameter name (PascalCased). name becomes Name in the template.

Use Ref to reference a parameter’s value inside resource properties:

src/parameter-ref.ts
import { Bucket, Sub, Ref } from "@intentius/chant-lexicon-aws";
export const paramRefBucket = new Bucket({
BucketName: Sub`${Ref("Environment")}-data`,
PublicAccessBlockConfiguration: {
BlockPublicAcls: true,
BlockPublicPolicy: true,
IgnorePublicAcls: true,
RestrictPublicBuckets: true,
},
});

Or import it directly when the parameter is in another file:

src/parameter-cross-file-ref.ts
import { Bucket, Sub, Ref } from "@intentius/chant-lexicon-aws";
import { environment } from "./parameter-declaration";
export const crossRefBucket = new Bucket({
BucketName: Sub`${Ref(environment)}-data`,
PublicAccessBlockConfiguration: {
BlockPublicAcls: true,
BlockPublicPolicy: true,
IgnorePublicAcls: true,
RestrictPublicBuckets: true,
},
});

Use output() to create explicit stack outputs. An output wraps an AttrRef (a resource attribute reference) with a name:

src/output-explicit.ts
import { Bucket, Sub, AWS, output } from "@intentius/chant-lexicon-aws";
export const dataBucket = new Bucket({
BucketName: Sub`${AWS.StackName}-data`,
PublicAccessBlockConfiguration: {
BlockPublicAcls: true,
BlockPublicPolicy: true,
IgnorePublicAcls: true,
RestrictPublicBuckets: true,
},
});
export const dataBucketArn = output(dataBucket.Arn, "DataBucketArn");

This produces:

"Outputs": {
"DataBucketArn": {
"Value": { "Fn::GetAtt": ["DataBucket", "Arn"] }
}
}

chant