• 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. Deploying

Deploying to AWS

The Serverless Framework deploys a service to AWS in three ways:

  • serverless deploy deploys the whole service (functions, events and resources) as one AWS CloudFormation stack. Use it for any change to serverless.yml, and in CI/CD.
  • serverless deploy function updates one function's code and configuration directly, without CloudFormation. Use it for fast iterations during development.
  • serverless deploy --package deploys artifacts built earlier with serverless package.

Run serverless deploy in the directory that holds serverless.yml:

serverless deploy

The deploy goes to the dev stage in us-east-1 unless provider.stage and provider.region in serverless.yml, or --stage and --region, say otherwise:

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

It uses the AWS credentials described in which credentials a deploy uses. Add --verbose to print the CloudFormation progress, and --config (or -c) to use a configuration file other than serverless.yml.

Deploy the service

serverless deploy turns serverless.yml into a CloudFormation template and creates or updates the service's stack, named <service>-<stage> unless provider.stackName is set. When an update fails, CloudFormation rolls the stack back to its previous state, unless provider.disableRollback is set.

How a deploy works

  1. The Framework resolves the deployment bucket, which stores the zip files and the compiled template. By default it is a shared deployment bucket per AWS Region, created on the first deploy to that Region. A service whose stack already contains a stack-managed deployment bucket (for example, one first deployed with an earlier major version) keeps using it, except inside Serverless Compose, where services always use the shared bucket. provider.deploymentBucket sets a bucket of your own.
  2. With the legacy stack-managed bucket (provider.enableLegacyDeploymentBucket: true) and no stack yet, the Framework creates a stack that holds only the bucket. Otherwise, no such initial stack is created.
  3. The Framework packages the functions into zip files (see Packaging), unless --package or package.path names a directory of artifacts that serverless package built earlier (see Deploying a package).
  4. For container images built from a local path, the Framework creates the service's ECR repository if needed, runs docker login against it, and builds and pushes the images.
  5. Unless --force is passed, the Framework compares the hashes of the compiled CloudFormation template, the service state file and the zip files with those of the newest deployment in the bucket. When all of them match, and no object of that deployment was uploaded after the functions were last updated, the deploy stops here without changing anything.
  6. The Framework uploads the zip files and the compiled template to the deployment bucket, under <deploymentPrefix>/<service>/<stage>/.
  7. CloudFormation creates the stack (first deploy) or updates it with the new template.

By default, each deploy that changes a function's code or configuration publishes a new version of it. provider.versionFunctions: false turns that off, and a function's own versionFunction overrides the provider setting. Functions with durableConfig, provisionedConcurrency or snapStart are always versioned, and versionFunction: false on a function with durableConfig stops the deploy with an error. See Versioning deployed functions.

A deploy needs AWS permissions for CloudFormation, for the resources in the stack, and for SSM and S3 to resolve the deployment bucket and upload the artifacts; inside Serverless Compose, also for the state bucket. See AWS credentials requirement for packaging.

Deployment method

By default, the Framework updates the stack with direct updates. To deploy through CloudFormation change sets instead, set provider.deploymentMethod to changesets (allowed values: direct, changesets; default direct):

provider:
  name: aws
  deploymentMethod: changesets

Deployment bucket settings

These provider settings change where and how the artifacts are stored:

  • deploymentBucket: a bucket of your own, by name, with settings such as serverSideEncryption. See the Deployment Bucket guide for every key.
  • deploymentPrefix: the S3 key prefix of the artifacts. Default serverless.
  • deploymentBucket.skipPolicySetup: don't create the default bucket policy. Applies only to the stack-managed deployment bucket.
  • deploymentBucket.versioning: true: turn on versioning for the stack-managed deployment bucket. The shared deployment bucket is always versioned.
  • enableLegacyDeploymentBucket: true: use a deployment bucket created and managed by the service's own stack. The --enable-legacy-deployment-bucket flag and the ENABLE_LEGACY_DEPLOYMENT_BUCKET environment variable do the same.

--aws-s3-accelerate uploads through S3 Transfer Acceleration, which the Framework turns on only for the stack-managed deployment bucket. With provider.deploymentBucket, the deploy stops with S3_TRANSFER_ACCELERATION_ON_EXISTING_BUCKET; with the shared deployment bucket, the bucket's acceleration setting is not changed.

AWS SDK for JavaScript v3 for Framework calls

The Framework's own calls to AWS during packaging and deployment (S3 uploads, CloudFormation updates) use the AWS SDK for JavaScript v2 code path by default. To use the v3 code path, set SLS_AWS_SDK=3 in the environment, on your machine or in the CI pipeline:

SLS_AWS_SDK=3 serverless deploy

Both paths read credentials through the standard AWS credential provider chain. The setting doesn't affect your function code, which uses whatever SDK you bundle or the runtime provides; AWS has ended support for the v2 SDK, so use @aws-sdk/* (v3) clients in handlers.

Deploy a single function

serverless deploy function updates one function without touching the CloudFormation stack, which makes it much faster than a full deploy:

serverless deploy function --function myFunction
  1. The Framework packages the function into a zip file.
  2. It compares the hash of the zip (for an image function, the image digest) with the code hash of the deployed function, and skips the code update when they match, unless --force is passed.
  3. Otherwise, it uploads the zip directly to the function with the Lambda UpdateFunctionCode API, bypassing the deployment bucket and CloudFormation.
  4. If the function's configuration (such as memory size, timeout or environment variables) differs from serverless.yml, it updates that too. --update-config updates only the configuration, without deploying code.

The function must already exist: otherwise the command stops with FUNCTION_NOT_YET_DEPLOYED, so deploy the service once with serverless deploy first. Changes made this way are not in the stack's template, so use the command during development and keep serverless deploy for CI/CD and production. See the deploy function command for its options.

Deploying a package

serverless deploy --package deploys a directory created earlier with serverless package, without packaging again. Build the artifacts once (for example in a CI build step) and deploy them in a later step:

serverless package --package path-to-package
serverless deploy --package path-to-package

The deploy reads the zip files and templates from that directory and uses them to create or update the stack. package.path in serverless.yml does the same as --package. See the deploy command for every option.

Recover a stack in UPDATE_ROLLBACK_FAILED

When a deploy fails and CloudFormation then can't roll back one of the stack's resources, for example a resource changed or deleted outside the stack, the stack stays in UPDATE_ROLLBACK_FAILED. Every later serverless deploy stops with:

Stack:arn:aws:cloudformation:us-east-1:123456789012:stack/my-service-dev/... is in UPDATE_ROLLBACK_FAILED state and can not be updated.

The stack must return to UPDATE_ROLLBACK_COMPLETE before it accepts another deploy. Run the commands below with the credentials and Region of the deploy, adding --region (and --profile) when your AWS CLI defaults differ. Fix what blocks the rollback if you can, then continue the rollback:

aws cloudformation continue-update-rollback --stack-name my-service-dev

If you can't fix it, force the rollback to complete. CloudFormation skips every resource whose rollback failed, including resources in nested stacks, and marks it Resource skipped during UpdateRollback:

aws cloudformation continue-update-rollback --stack-name my-service-dev --force-rollback

Warning: A skipped resource no longer matches the stack's template. Before the next deploy, check each skipped resource and bring it in line with the stack's current template, the one the rollback restored (aws cloudformation get-template --stack-name my-service-dev, or the nested stack's template for a resource in a nested stack), not with the changed serverless.yml; run drift detection on it to see the differences. Drift detection covers only resource types that support it and only the properties the template sets, so compare other resources with the template yourself. Then run serverless deploy. See Continue rolling back an update.

Related pages

  • Packaging: what goes into the artifacts.
  • Deployment Bucket: the shared bucket and your own bucket.
  • AWS credentials: where a deploy's credentials come from.
  • serverless deploy: command options.
Edit this page
Prev License KeysNextPackaging

Contents

  • Deploying to AWS
  • Deploy the service
  • How a deploy works
  • Deployment method
  • Deployment bucket settings
  • AWS SDK for JavaScript v3 for Framework calls
  • Deploy a single function
  • Deploying a package
  • Recover a stack in UPDATE_ROLLBACK_FAILED
  • Related pages

Related

GuidesPluginsExamplesSlack CommunitySupport