• Documentation
  • Pricing
© 2026 Serverless, Inc. All rights reserved.

Framework

  • Overview
  • Documentation
  • Plugins360
  • Pricing

Learn

  • Blog
  • GuidesUpdated
  • Examples240
  • Courses

Resources

  • Support
  • Security
  • Trust Center
  • Status

Community

  • Slack
  • GitHub47k
  • Forum
  • Meetups

Company

  • About
  • Careers
  • Contact
  • Partners

Legal

  • Terms of Service
  • Privacy Policy
  • Trademark
  • DMCA
Serverless Framework Logo

Serverless Framework

Intro
SetupUpgrading To V4ConceptsTutorialAWS CredentialsLicense KeysVerifying Downloads
DeployingPackagingBuildingTestingDev ModeServicesFunctions
OverviewHTTP (API Gateway v2)REST (API Gateway v1)ActiveMQApplication Load BalancerAlexa SkillAlexa Smart HomeCloudWatch EventCloudWatch LogCloudFrontCognito User PoolEventBridge EventIoTIoT Fleet ProvisioningKafkaKinesis & DynamoDBMSKRabbitMQS3ScheduleSNSSQSWebsocket
Layers
OverviewTroubleshooting
Managed InstancesWeb Apps (Lambda Web Functions)Sandboxes (Lambda MicroVMs)MCP ServersAlertsVersion PruningDomainsIAM Function PermissionsParameters
OverviewSelf-reference serverless.ymlServerless CoreEnvironment VariablesCLI OptionsExternal YAML/JSON FilesJavascript propertiesGitDoppler
OverviewS3 ObjectsSSM Parameter Store & Secrets ManagerCloudFormation Stack Outputs
OverviewVaultTerraform State Output
ResourcesComposing ServicesDeployment BucketStateAgent SkillsPython support
OverviewRuntimeGatewayMemoryBrowserCode InterpreterDev Mode
API Gateway Proxy
OverviewGeneral ConfigurationAuthenticationAPI KeysData SourcesResolversPipeline FunctionsSubstitutionsCachingDelta SyncCustom DomainWAFCLI Commands
Deploying SAM/CFN TemplatesWorkflow Tips
OverviewCreating PluginsCLI OutputCustom CommandsCustom VariablesExtending the Configuration schemaExtending and overriding configuration
OverviewDashboardAxiom
Overviewagent docsagent inspectagent setupagent skills installagent skills list / readdeploydeploy functiondeploy listdevdiffinfoinvokeinvoke localloginlogin awslogin aws ssologsmetricspackageplugin installplugin uninstallprintprunereconcileremoverollbackrollback functionusage
OverviewConcepts
OverviewMetricsTracesTroubleshoot
OverviewNode.jsPython
OutputsProviders
OverviewBranch DeploymentsPreview DeploymentsCustom ScriptsTestingPrivate PackagesNotificationsMono ReposDeploy in your own CI/CDBest PracticesTroubleshootingFAQ
OverviewSetupToolsAWS Integration
Serverless.yml Reference
Examples and TutorialsConfiguration Validation
  1. Usage
  2. Variables
  3. Serverless Core

Serverless Core Variables

The ${sls:...} variables expose two values the Serverless Framework computes for each run: the stage being deployed (${sls:stage}) and an ID that changes on every CLI run (${sls:instanceId}). Use ${sls:stage} whenever a name or setting depends on the stage, instead of repeating the stage logic yourself.

The following serverless.yml names a DynamoDB table after the stage and records the CLI run that deployed the function:

# serverless.yml
service: my-service

provider:
  name: aws
  runtime: nodejs24.x
  environment:
    TABLE_NAME: my-service-${sls:stage}-users
    DEPLOYMENT_ID: ${sls:instanceId}

functions:
  hello:
    handler: handler.hello

Running serverless deploy --stage prod sets TABLE_NAME to my-service-prod-users.

Stage name

${sls:stage} returns the stage of the current run, taken from the first of these that is set:

  1. The --stage option, or its alias -s.
  2. provider.stage in serverless.yml.
  3. dev.

This is the same value as ${opt:stage, self:provider.stage, 'dev'}, in one variable. Use ${sls:stage} instead of ${self:provider.stage}, which returns only what the file sets and ignores --stage.

${sls:stage} can be part of another variable's key, for example to pick a stage-specific file: ${file(./config.${sls:stage}.json):dbHost}.

Instance ID

${sls:instanceId} returns the time the Serverless CLI process started, in milliseconds since the Unix epoch, as a string (for example 1793491279117). The value is set once per CLI run, so every ${sls:instanceId} in that run returns the same value, and the next run returns a different one.

Use it where a value must change on every deployment, for example to make a CloudFormation custom resource run again or to tag a deployment. A function that uses ${sls:instanceId} in its configuration, as in the opening example, has a changed configuration on every deployment, so the Framework updates the function each time.

Unknown core variable names

Only stage and instanceId are available. Any other name stops the command with an error, for example for ${sls:region}:

Failed to resolve variable 'region' with resolver 'framework' and provider 'sls': Error: Resolver framework is not supported

To read the region, use ${aws:region} (AWS variables) or ${opt:region, self:provider.region, 'us-east-1'} (CLI options).

Related variable sources

  • Variables: how variables work, and the list of all variable sources.
  • CLI option variables: read any option passed to the command.
  • Self-reference variables: reuse values from the same serverless.yml.
  • Parameters: stage-specific values set with params.
Edit this page
Prev Self-reference serverless.ymlNextEnvironment Variables

Contents

  • Serverless Core Variables
  • Stage name
  • Instance ID
  • Unknown core variable names
  • Related variable sources

Related

GuidesPluginsExamplesSlack CommunitySupport