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:
stageStage to useregionAWS region to useprofileAWS profile to useroleAWS 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:
nameThe name of your applicationstageThe stage to use*regionAWS region to use*profileAWS profile to use*roleAWS role to use*ssmPrefixSSM prefix for all SSM parameters that SST createsadvanceddisableParameterizedStackNameCheckDisable the check for stack names to be parameterized with the stage name.disableAppModeCheckDisables the confirmation prompt when switching betweensst deployandsst devdeployment modes. If set totrue, the prompt will be suppressed when changing modes.
bootstrapbucketNameThe name to use for the SST bootstrap bucketstackNameThe name to use for the SST bootstrap stackstackDescriptionThe description to use for the SST bootstrap stacktagsTags to use for the SST bootstrap stackuseCdkBucketUse the S3 bucket created by the CDK bootstrap process instead of creating a new one
cdkbootstrapStackVersionSsmParameterThe name of the SSM parameter which describes the bootstrap stack version numbercloudFormationExecutionRoleIAM role assumed by the CloudFormation to deploycustomPermissionsBoundaryThe name of the IAM permissions boundary policy to use for the CDK toolkit stack and SST bootstrap stackdeployRoleArn: IAM role used to initiate a deploymentfileAssetPublishingRoleArnIAM role used to publish file assets to the S3 bucketfileAssetsBucketNameThe name of the CDK toolkit bucketimageAssetPublishingRoleArnIAM role used to publish image assets to the ECR repositoryimageAssetsRepositoryNameThe name of the ECR repository for Docker image assetslookupRoleArnIAM role used to look up values from the AWS accountpathMetadataAdd CDK path metadata to templates. This enables the CDK Construct tree view in the CloudFormation console. Defaultfalse.publicAccessBlockConfigurationBlock public access configuration on the CDK toolkit bucket and SST bootstrap bucketqualifierThe qualifier for the CDK toolkit stacktoolkitStackNameThe 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.