• 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 Keys
DeployingPackagingBuildingTestingDev ModeServicesFunctions
OverviewHTTP (API Gateway v2)REST (API Gateway v1)ActiveMQApplication Load BalancerAlexa SkillAlexa Smart HomeCloudWatch EventCloudWatch LogCloudFrontCognito User PoolEventBridge EventIoTIoT Fleet ProvisioningKafkaKinesis & DynamoDBMSKRabbitMQS3ScheduleSNSSQSWebsocket
LayersManaged 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. Hashi Corp
  4. Vault

HashiCorp Vault Secret Variables

A ${vault:<path>/<property>} variable reads a secret from a HashiCorp Vault server while the Serverless Framework loads serverless.yml. Use it to keep secrets such as database passwords in Vault instead of in serverless.yml or CI settings.

The following serverless.yml reads the credentials.password property of the secret/data/mongo secret:

# serverless.yml
service: my-service

provider:
  name: aws
  runtime: nodejs24.x

functions:
  hello:
    handler: handler.hello
    environment:
      MONGO_PASSWORD: ${vault:secret/data/mongo/credentials.password}

Deploy with the Vault address and a token in the environment:

VAULT_ADDR=https://vault.example.com:8200 VAULT_TOKEN=YOUR_VAULT_TOKEN serverless deploy

Replace YOUR_VAULT_TOKEN with a Vault token that can read the secret. If the secret holds {"credentials": {"password": "example-password"}}, MONGO_PASSWORD is example-password.

Syntax of the vault variable

${vault:SECRET_PATH/PROPERTY}
${RESOLVER_NAME:SECRET_PATH/PROPERTY}
  • SECRET_PATH: the path of the secret in Vault's HTTP API, without the version prefix. For a KV version 2 secrets engine mounted at secret, that's secret/data/<name>.
  • PROPERTY: the part after the last /, a dot path inside the secret (credentials.password).
  • RESOLVER_NAME: the name of a resolver with type: vault under stages.<stage>.resolvers; see Configure a Vault resolver. Without a declared resolver, use vault.

For a path in a KV version 2 secrets engine, the variable reads the secret's own key-value pairs (the data.data object of Vault's response), so PROPERTY starts at your keys. KV version 1 secrets aren't supported: their variables get no value. For other secrets engines, it reads the data object of the response.

When the property doesn't exist in the secret, the variable uses its default (${vault:secret/data/mongo/credentials.password, 'none'}), otherwise the command stops with a Cannot resolve error. An error from Vault, such as a missing token, a secret path that doesn't exist or a denied request, stops the command even when a default is set.

Vault address and token

Without a resolver, the vault variable reads its settings from the environment:

  • VAULT_ADDR: the Vault server's URL. Default: http://localhost:8200/.
  • VAULT_TOKEN: the token sent in the X-Vault-Token header. Without a token, the command stops with No Vault token provided. Please provide a token in the Vault configuration or set the VAULT_TOKEN environment variable.

Configure a Vault resolver

To set the address, token, API version or a path prefix in serverless.yml, declare a resolver with type: vault. The following resolver reads the token from MY_VAULT_TOKEN and prefixes every path with secret/data:

stages:
  default:
    resolvers:
      vault:
        type: vault
        address: https://vault.example.com:8200
        token: ${env:MY_VAULT_TOKEN}
        path: secret/data

provider:
  name: aws

functions:
  hello:
    handler: handler.hello
    environment:
      MONGO_PASSWORD: ${vault:mongo/credentials.password}

With the path prefix, ${vault:mongo/credentials.password} reads the secret/data/mongo secret.

KeyTypeDefaultDescription
typeStringRequiredvault.
addressStringVAULT_ADDR, then http://localhost:8200/URL of the Vault server.
tokenStringVAULT_TOKENVault token.
versionStringv1Vault HTTP API version, the first segment of the request path.
pathStringNonePrefix added before the secret path of every variable that uses this resolver.

Another key stops the command with Only 'token', 'address', 'version', and 'path' are allowed in the Vault configuration.

A resolver can have any name. To read from two Vault servers or with two tokens, declare two resolvers with type: vault and reference each by name, for example ${prodVault:mongo/credentials.password}.

Related

  • Variables in serverless.yml: syntax, defaults and resolvers.
  • Terraform state outputs: read outputs of a Terraform state.
  • Doppler secrets: read secrets from Doppler.
Edit this page
Prev OverviewNextTerraform State Output

Contents

  • HashiCorp Vault Secret Variables
  • Syntax of the vault variable
  • Vault address and token
  • Configure a Vault resolver
  • Related

Related

GuidesPluginsExamplesSlack CommunitySupport