aws / aws/aws-sam-cli

SAM deploy complains about the config file, when the template file is not in current directory

Open
#5,009 14 comments 5 reactions 0 assignees View on GitHub
area/config
Dominant language
Python
Stars
6.7k
Forks
1.2k
Avg merge
1d 10h
Merged PRs (30d)
52

Description

### Description:

SAM deploy complains about the config file (the --config-file) missing or unreadable, but it's really the about the path to the template file (the -t argument). 
If the specified template file is not in the current directory the error from SAM is 
`Error: Configfile sam-config-file.toml does not exist or could not be read!
`

### Steps to reproduce:

This gives the error:
`> sam deploy -t ./folder/my_template.yaml --config-file sam-config-file.toml --s3-bucket thebucket --region us-east-1
`
It doesn't matter if the path to the template file is absolute or relative. The template file must be in the current directory, like this:
`> sam deploy -t my_template.yaml --config-file sam-config-file.toml --s3-bucket thebucket --region us-east-1
`

### Observed result:

2023-04-13 10:39:48,139 | Using SAM Template at /Users/tgronwall/sam-bugreport/folder/template.yaml
2023-04-13 10:39:48,139 | Config file sam-config-file.toml does not exist or could not be read!
Error: Config file sam-config-file.toml does not exist or could not be read!

### Expected result:

It should find the template file when I use a correct path (either absolute or relative) to a a template file in a sub folder, not only a file in the current directory.
It should not complain about the config file, if it can't find the template file

### Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
Both MacOS and Linux (in our gitlab runner)
I have tracked this bug to have been introduced in SAM v1.56. It did not occur in previous versions.
See https://github.com/aws/aws-sam-cli/issues/3899

1. OS: Macos 12.6.4
2. `sam --version`: 1.78
3. AWS region: us-east-1

```
# Paste the output of `sam --info` here
```
{
"version": "1.78.0",
"system": {
"python": "3.8.16",
"os": "macOS-12.6.4-x86_64-i386-64bit"
},
"additional_dependencies": {
"docker_engine": "20.10.12",
"aws_cdk": "Not available",
"terraform": "Not available"
}
}

`Add --debug flag to command you are running`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.