serverless deploy: Usage, Options & Common CI Errors
Deploy your Serverless Framework service and its AWS resources.
serverless deploy (alias sls deploy) packages your service and provisions it via CloudFormation. In CI you deploy a specific stage with AWS credentials supplied to the runner.
What it does
serverless deploy builds a deployment package from serverless.yml, uploads it to S3, and creates or updates a CloudFormation stack containing your functions, events, and resources. Without --function it does a full deploy; with --function <name> it does a faster code-only update of one function.
Common usage
# Full deploy to a stage and region
serverless deploy --stage prod --region us-east-1
# Fast single-function code update
serverless deploy function --function api
# Verbose output for CI logs
sls deploy --stage staging --verboseCommon error in CI: missing AWS credentials / stack update failed
deploy fails with "AWS provider credentials not found" or a CloudFormation error like "UPDATE_ROLLBACK_COMPLETE ... is not in a state to update". Fix: give the runner AWS credentials (env vars, an OIDC role, or serverless config credentials), and pass --stage/--region explicitly. For a stack stuck in ROLLBACK, resolve the root cause and redeploy; if the stack is in a non-updatable state, you may need to fix or delete it in CloudFormation before the next deploy succeeds.
Key options
| Option | Purpose |
|---|---|
| --stage NAME | Target stage (dev, prod, …) |
| --region NAME | AWS region |
| function --function NAME | Deploy one function (code only) |
| --verbose | Show CloudFormation progress |
| --force | Force a full redeploy |