I’m using the Serverless Framework (sls
) to deploy an AWS Lambda function. When I run:
sls deploy --stage dev
I get this error:
✖ Error: Please specify a stack name using the --stack option, or persist it in the samconfig.toml file.
Context:
- My
serverless.yml
already includes theservice
field:service: py-events provider: name: aws
- This worked previously but suddenly started failing.
- I’m not explicitly using AWS SAM, but my project has a
template.yaml
file.
Debug Logs:
The error traces to getCfnConfig
in the Serverless Framework, with the MISSING_STACK_NAME
code.
Question:
How do I resolve this stack name error, and why did it suddenly appear despite having a service
defined?
What I’ve tried:
- Adding
stage: dev
toprovider
inserverless.yml
. - Specifying
--stack my-stack-dev
in the CLI.
I’m using the Serverless Framework (sls
) to deploy an AWS Lambda function. When I run:
sls deploy --stage dev
I get this error:
✖ Error: Please specify a stack name using the --stack option, or persist it in the samconfig.toml file.
Context:
- My
serverless.yml
already includes theservice
field:service: py-events provider: name: aws
- This worked previously but suddenly started failing.
- I’m not explicitly using AWS SAM, but my project has a
template.yaml
file.
Debug Logs:
The error traces to getCfnConfig
in the Serverless Framework, with the MISSING_STACK_NAME
code.
Question:
How do I resolve this stack name error, and why did it suddenly appear despite having a service
defined?
What I’ve tried:
- Adding
stage: dev
toprovider
inserverless.yml
. - Specifying
--stack my-stack-dev
in the CLI.
1 Answer
Reset to default 0Answer
This error occurs when the Serverless Framework (or an integrated tool like AWS SAM) cannot resolve a CloudFormation stack name. Here’s how to fix it:
1. Ensure service
and stage
Are Properly Configured
Add stage
under the provider
in serverless.yml
. The stack name is auto-generated as ${service}-${stage}
:
service: py-events
provider:
name: aws
stage: dev #