-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
I'm using SAM 1.84.0 on Windows 10.
I can deploy a stack using something like this:
sam deploy \
--profile my-aws-profile \
--template-file $SCRIPT_DIR/sam-template.yaml \
--stack-name my-stack \
--s3-bucket sam-bucketNote that I don't specify a region anywhere. My samconfig.toml doesn't contain anything about a region. I have set up a default region in my-aws-profile, which is standard for AWS CLI work. For example my ~/.aws/cofig might look like this:
[default]
region = us-east-1
output = json
[profile my-aws-profile]
region = us-east-2
output = json
That all works as expected. But then it comes time to delete the stack:
sam delete \
--profile my-aws-profile \
--stack-name my-stack \
--s3-bucket sam-bucket
--no-promptsUnfortunately that produces:
Error: Missing option '--region', region is required to run the non guided delete command.
But I don't want to remember what region to use and provide a --region on the command line. The region is already known because I specified a --profile, for while a region is specified. Again this is standard AWS CLI configuration.
I didn't need to specify a --region when I ran sam deploy …. I shouldn't be required to provide a --region when I delete the same stack, providing the same information, when running sam delete ….
This is not just an inconvenience: it is a duplication of information that promotes errors in the future. We have a centralized location for defining the profile, and it gets passed to the batch files as $awsProfile. Imagine for example that we take this project and simply change $awsProfile. The entire deployment will work exactly the same, except that it will use the other AWS profile in the appropriate region. But because sam delete … requires a separate --region designation (even though it should already know that information, just as sam deploy … does), what happens if we forget to go update the --region information in the batch files when we update $awsProfile? The whole thing breaks — needlessly.
Please update the sam delete … logic to determine the region based upon the AWS profile in the standard AWS CLI ~/.aws/cofig configuration, as it does for sam deploy ….