Bug: sam delete keeps asking for --region found in samconfig.toml
See original GitHub issueDescription:
sam delete
doesn’t let me delete a stack without providing a set of parameters already defined in the samconfig.toml
file.
Steps to reproduce:
Create a stack with samconfig.toml
looking a bit like this:
version = 0.1
[default]
[default.deploy]
[default.deploy.parameters]
s3_bucket = "<your bucket>"
s3_prefix = "<your prefix>"
kms_key_id = "<your S3 access key>"
region = "eu-central-1"
capabilities = "CAPABILITY_IAM"
image_repositories = []
confirm_changeset = false
disable_rollback = false
With this you should be able to deploy a stack based on template.yaml
only by calling
sam build
sam deploy --stack-name mystack
Try deleting it:
sam delete --stack-name mystack --no-prompts --debug
Observed result:
sam delete --stack-name tsb-aim-production --no-prompts --debug
2022-08-14 15:55:23,217 | Using config file: samconfig.toml, config environment: default
2022-08-14 15:55:23,217 | Expand command line arguments to:
2022-08-14 15:55:23,217 | --stack_name=tsb-aim-production --no_prompts
2022-08-14 15:55:23,308 | Config file location: /c/user/git/tsb-lambda/samconfig.toml
2022-08-14 15:55:23,310 | Loading configuration values from [default.['deploy'].parameters] (env.command_name.section) in config file at '/c/user/git/tsb-lambda/samconfig.toml'...
2022-08-14 15:55:23,315 | Configuration values successfully loaded.
2022-08-14 15:55:23,315 | Configuration values are: {'s3_bucket': '[redacted]', 's3_prefix': 'tsb', 'kms_key_id': '[redacted]', 'region': 'eu-central-1', 'capabilities': 'CAPABILITY_IAM', 'image_repositories': [], 'confirm_changeset': False, 'disable_rollback': False}
Usage: sam delete [OPTIONS]
Error: Missing option '--region', region is required to run the non guided delete command.
Expected result:
The SAM stack is deleted.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
- OS: Windows 10 / WSL2 Ubuntu 20.04.4 LTS
sam --version
: SAM CLI, version 1.53.0- AWS region: eu-central-1
Issue Analytics
- State:
- Created a year ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
AWS SAM CLI configuration file
The AWS SAM CLI supports a project-level configuration file that stores default parameters for its commands. This configuration file is in the TOML...
Read more >AWS Sam Hello World Failed - Stack Overflow
sam deploy --guided Looking for config file [samconfig.toml] : Not ... Name [sam-app]: AWS Region [eu-west-2]: #Shows you resources changes ...
Read more >AWS SAM Deploy Missing option '--image-repository'...
I am trying to deploy to Lambda using `aws-sam-deploy` pipe and got an "Missing option '--image-repository' or '--image-repositories'" error when packaging.
Read more >aws-sam-cli Changelog - pyup.io
fix: add `MaxAttempts` to `sam delete` by sriram-mv in ... users can turn cached builds off specifically even it is enabled in the...
Read more >How to create serverless applications with SAM - Playing AWS
SAM (Serverless Application Model) is an open-source framework that ... if a samconfig.toml file exists and if not the AWS SAM CLI will...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@jsmucr You need to have
default.delete.parameters
in yoursamconfig.toml
. They way thesamconfig.toml
operates is by command config. Sodeploy
parameters will not be picked up indelete
.If you want to specify a region per environment (in your example default is the environment), you can add
to the
samconfig.toml
, which should yield the results you want. https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-config.html has more info on this.@cortexcompiler This mechanism is mainly aimed to focus on protecting users from accidentally deleting stacks if the stack name specified in command line option doesn’t match with what’s in the samconfig file, and you are poking at a direction where if the stack name is empty in the samconfig, it shouldn’t be treated the same way as having a different stack name and user should be able to proceed delete with other specified parameters like region?