Configuring SST
SST is configured using a TypeScript config file — sst.config.ts
File structure
The sst.config.ts
file is placed at the root of your application, typically in the top most directory in your repo.
While it's defined as a TypeScript file, it should not be treated as a subpackage in a monorepo setup. It is a root level config used for managing your entire application.
Basic config
Here's what a minimal config looks like.
import type { SSTConfig } from "sst";
export default {
config(input) {
return {
name: "myapp",
region: "us-east-1",
};
},
stacks(app) {},
} satisfies SSTConfig;
It takes a config
and a stacks
function. While the SSTConfig
type provides typesafety for the configuration object.
Config function
The config
function receives a global input object — this may contain any settings the user passes through the CLI options. These may include:
stage
Stage to useregion
AWS region to useprofile
AWS profile to userole
AWS role to assume for calls to AWS
These fields will only have values if the user explicitly passes them through the CLI options. You can use these flags to implement any kind of logic to run before returning a configuration.
For example, you can use a different profile based on what stage is being used.
config(input) {
return {
name: "myapp",
profile: input.stage === "production"
? "myapp-production"
: "myapp-dev"
}
},
Config options
Here's the full list of config options that can be returned:
name
The name of your applicationstage
The stage to use*region
AWS region to use*profile
AWS profile to use*role
AWS role to use*ssmPrefix
SSM prefix for all SSM parameters that SST createsadvanced
disableParameterizedStackNameCheck
Disable the check for stack names to be parameterized with the stage name.disableAppModeCheck
Disables the confirmation prompt when switching betweensst deploy
andsst dev
deployment modes. If set totrue
, the prompt will be suppressed when changing modes.
bootstrap
bucketName
The name to use for the SST bootstrap bucketstackName
The name to use for the SST bootstrap stackstackDescription
The description to use for the SST bootstrap stacktags
Tags to use for the SST bootstrap stackuseCdkBucket
Use the S3 bucket created by the CDK bootstrap process instead of creating a new one
cdk
bootstrapStackVersionSsmParameter
The name of the SSM parameter which describes the bootstrap stack version numbercloudFormationExecutionRole
IAM role assumed by the CloudFormation to deploycustomPermissionsBoundary
The name of the IAM permissions boundary policy to use for the CDK toolkit stack and SST bootstrap stackdeployRoleArn
: IAM role used to initiate a deploymentfileAssetPublishingRoleArn
IAM role used to publish file assets to the S3 bucketfileAssetsBucketName
The name of the CDK toolkit bucketimageAssetPublishingRoleArn
IAM role used to publish image assets to the ECR repositoryimageAssetsRepositoryName
The name of the ECR repository for Docker image assetslookupRoleArn
IAM role used to look up values from the AWS accountpathMetadata
Add CDK path metadata to templates. This enables the CDK Construct tree view in the CloudFormation console. Defaultfalse
.publicAccessBlockConfiguration
Block public access configuration on the CDK toolkit bucket and SST bootstrap bucketqualifier
The qualifier for the CDK toolkit stacktoolkitStackName
The name of the CDK toolkit stack
*These won't take effect if the CLI flag for it is specified.
Stacks function
The stacks
function is the entry point for your SST application. This is where you can specify the stacks that contain the resources that you want to deploy.
You can either do this inline, like so.
stacks(app) {
app.stack(function MyStack({ stack } ) {
new Bucket(stack, "public")
})
}
Where Bucket
is from import { Bucket } from "sst/constructs"
.
Or you can organize them as separate files.
stacks(app) {
app
.stack(MyStack)
.stack(MyOtherStack)
}
Where you might place your stacks code in a separate directory.
import { MyStack } from "./stacks/my-stack";
import { MyOtherStack } from "./stacks/my-other-stack";
Again as noted above, these aren't meant to be a subpackage in your monorepo. The stacks/
directory in this example is just a convenient way to organize your files.