• 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. CLI Reference
  2. Package

serverless package

serverless package builds everything a deployment needs, the code packages and the CloudFormation templates, into .serverless without deploying it. Use it to inspect what would be deployed, or to build once in CI and deploy the same package later with serverless deploy --package. serverless deploy runs the same packaging step itself.

serverless package

Options

serverless package accepts these options:

OptionAliasValueDefaultRequiredDescription
--stage-sstringprovider.stage, else devNoStage to package for.
--region-rstringprovider.region, else us-east-1NoAWS Region to package for.
--aws-profilestringprovider.profileNoAWS profile whose credentials the command uses.
--config-cfile pathserverless.ymlNoService configuration file to use.
--package-pdirectorypackage.path, else .serverlessNoDirectory to write the package to, relative to the current working directory. Replaced on every run.
--minify-templateflagoffNoWrite the compiled CloudFormation template without whitespace.

serverless package also accepts the options every command takes: --param="key=value" (repeatable), --org, --app, --verbose, --debug and --help (-h).

The --package directory is deleted and written again on every run, so the command rejects the service directory itself and any directory that contains it. Use a dedicated directory inside the service, such as .serverless-package, or outside it, such as ../artifacts.

Files that serverless package writes

serverless package empties .serverless (keeping a Dev Mode session's dev/ folder) and writes:

  • the code packages: <service>.zip, or <function>.zip per function with package.individually, and <layer>.zip per layer;
  • cloudformation-template-create-stack.json, the template that creates the stack;
  • cloudformation-template-update-stack.json, the full compiled template;
  • serverless-state.json, the resolved service that serverless deploy --package reads.

With --package or package.path, these files are moved from .serverless to that directory. To change what goes into the code packages, see Packaging.

AWS access during serverless package

serverless package needs AWS credentials, though it deploys nothing. Unless the service sets provider.deploymentBucket or uses the legacy in-stack deployment bucket, it looks up the region's shared deployment bucket, and creates the bucket and its SSM parameter when they don't exist yet. See AWS Credentials Requirement for Packaging and Deployment bucket.

serverless package is safe to re-run, and has no prompts of its own. In CI, sign in with SERVERLESS_ACCESS_KEY or SERVERLESS_LICENSE_KEY; see Non-interactive use.

Output of serverless package

Packaging "my-service" for stage "dev" (us-east-1)

✔ Service packaged (2s)

Provided lifecycle events

  • package:cleanup
  • package:initialize
  • package:setupProviderConfiguration
  • package:createDeploymentArtifacts
  • package:compileLayers
  • package:compileFunctions
  • package:compileEvents
  • package:finalize

Examples

Package for a specific stage and region

serverless package --stage prod --region eu-central-1

Build a package in CI and deploy it in a later step

serverless package --stage prod --region eu-central-1 --package ./artifacts
serverless deploy --stage prod --region eu-central-1 --package ./artifacts

The first command writes the package to ./artifacts; the second, run later from the same service directory with the same stage, region and AWS account, deploys it without packaging again. See Run serverless deploy in CI.

Related commands

  • serverless deploy packages and deploys the service.
  • serverless print shows the resolved serverless.yml without packaging.
  • serverless diff compares a package with the deployed stack.
Edit this page
Prev metricsNextplugin install

Contents

  • serverless package
  • Options
  • Files that serverless package writes
  • AWS access during serverless package
  • Output of serverless package
  • Provided lifecycle events
  • Examples
  • Package for a specific stage and region
  • Build a package in CI and deploy it in a later step
  • Related commands

Related

GuidesPluginsExamplesSlack CommunitySupport