• 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. Plugins
  3. Extending And Overriding Configuration

Extend the service configuration from a plugin

A Serverless Framework plugin can add values to the service configuration, or replace values from serverless.yml, with serverless.extendConfiguration(). Use it when a plugin generates configuration, such as functions, resources or custom settings, that the rest of the Framework and other plugins should see as if it were in serverless.yml.

This plugin sets custom.myPlugin in its constructor:

// my-plugin.mjs
export default class MyPlugin {
  constructor(serverless) {
    serverless.extendConfiguration(['custom', 'myPlugin'], {
      bucket: 'my-assets-${sls:stage}',
    })
  }
}

With the plugin listed in plugins, serverless print --stage prod shows the value, with its variable resolved:

custom:
  myPlugin:
    bucket: my-assets-prod

serverless.extendConfiguration() arguments

serverless.extendConfiguration(configurationPathKeys, value) sets value at the path configurationPathKeys of the configuration:

ArgumentTypeDescription
configurationPathKeysarray of stringsThe path of the property to set, for example ['functions', 'hello', 'timeout']. At least one key.
valueany JSON valueThe new value of the property.
  • If the property exists, the value replaces it; the Framework doesn't merge objects or arrays.
  • If the property or its parents don't exist, the Framework creates them.
  • The Framework stores a JSON copy of value: functions and properties set to undefined are left out, and Date objects become strings.

When a plugin can extend the configuration

Call serverless.extendConfiguration() in the plugin constructor or in asyncInit(). Use asyncInit() when the value comes from an asynchronous call:

// my-plugin.mjs
import { readFile } from 'node:fs/promises'

export default class MyPlugin {
  constructor(serverless) {
    this.serverless = serverless
  }

  async asyncInit() {
    const path = `${this.serverless.serviceDir}/my-plugin.json`
    const settings = JSON.parse(await readFile(path, 'utf8'))
    this.serverless.extendConfiguration(['custom', 'myPlugin'], settings)
  }
}

After all plugins are initialized, the Framework:

  1. Resolves the variables in the values that plugins added, with built-in and plugin-defined sources.
  2. Validates the whole configuration against the schema, including the added values. See Custom configuration.
  3. Runs the command's lifecycle events. In hooks, serverless.service and serverless.configurationInput contain the added values.

A call from a hook throws Cannot extend configuration: It can only be extended during initialization phase.

Merge a value with the existing configuration

To add keys to an object from serverless.yml instead of replacing it, read the current value from serverless.configurationInput and pass the merged object:

// my-plugin.mjs
export default class MyPlugin {
  constructor(serverless) {
    const current = serverless.configurationInput.custom?.myPlugin ?? {}
    serverless.extendConfiguration(['custom', 'myPlugin'], {
      ...current,
      region: 'us-east-1',
    })
  }
}

In the constructor, values from built-in variable sources are already resolved, and variables of plugin-defined sources still hold their ${...} text. The Framework resolves that text after the call, as part of the added value.

Errors from serverless.extendConfiguration()

serverless.extendConfiguration() throws these errors:

  • Cannot extend configuration: ConfigurationPathKeys needs to contain at least one element. for an empty array.
  • <value> is not an array when configurationPathKeys isn't an array, for example a string.
  • Cannot extend configuration: Received non JSON value: <value> when value can't be converted to JSON, for example undefined or an object that refers to itself.
  • Cannot extend configuration: It can only be extended during initialization phase. when it's called after the constructors and asyncInit() of all plugins have run.

Related pages

  • Create a plugin: the plugin class, asyncInit() and lifecycle hooks
  • Custom configuration: validate the keys your plugin adds
  • Custom variables: add ${source:...} variable sources
Edit this page
Prev Extending the Configuration schemaNextOverview

Contents

  • Extend the service configuration from a plugin
  • serverless.extendConfiguration() arguments
  • When a plugin can extend the configuration
  • Merge a value with the existing configuration
  • Errors from serverless.extendConfiguration()
  • Related pages

Related

GuidesPluginsExamplesSlack CommunitySupport