sam delete fails due to nested stack templateURL
- Dominant language
- Python
- Stars
- 6.7k
- Forks
- 1.2k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 52
Description
### Description:
Hello, I noticed an issue regarding nested stack declaration when used in an AWS SAM template file. On deletion, the version_checker.py raises the following error: _URL given to the parse method is not a valid S3_.
It seems that the version_checker.py is complaining because the TemplateURL is not starting with "s3://".
SAM CLI version used: 1.36.0 (also tested with v1.33.0)
### Steps to reproduce:
1. Add a nested stack declaration to your AWS SAM template YAML file, with an **hard-coded** string for the TemplateURL parameter
```
MyNestedStack:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: https://my-nested-stack-bucket.s3.eu-west-1.amazonaws.com/my-nested-stack-cfn-template.yaml
```
2. Build and deploy your SAM application
3. Try to delete your previously deployed Cloudformation stack with the **sam delete** command line
### Observed result:
```
Traceback (most recent call last):
File "samcli/__main__.py", line 12, in
File "click/core.py", line 829, in __call__
File "click/core.py", line 782, in main
File "click/core.py", line 1259, in invoke
File "click/core.py", line 1066, in invoke
File "click/core.py", line 610, in invoke
File "click/decorators.py", line 73, in new_func
File "click/core.py", line 610, in invoke
File "samcli/lib/utils/version_checker.py", line 42, in wrapped
File "samcli/cli/main.py", line 90, in wrapper
File "samcli/commands/delete/command.py", line 83, in cli
File "samcli/commands/delete/command.py", line 101, in do_cli
File "samcli/commands/delete/delete_context.py", line 349, in run
File "samcli/commands/delete/delete_context.py", line 300, in delete
File "samcli/lib/package/artifact_exporter.py", line 265, in delete
File "samcli/lib/package/packageable_resources.py", line 169, in delete
File "samcli/lib/package/packageable_resources.py", line 186, in get_property_value
File "samcli/lib/package/s3_uploader.py", line 265, in parse_s3_url
ValueError: URL given to the parse method is not a valid S3 url https://my-nested-stack-bucket.s3.eu-west-1.amazonaws.com/my-nested-stack-cfn-template.yaml**
[76] Failed to execute script __main__
```
### Expected result:
The **TemplateURL** parameter value of a **AWS::CloudFormation::Stack** resource is ignored by the version_checker.py and "**sam delete**" command is successful.
### Current workaround:
For an unknown reason, just adding **!Sub** in front of the TemplateURL's value (even if you don't use it to compute the TemplateURL's value) seems to resolve the issue:
```
MyNestedStack:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: !Sub https://my-nested-stack-bucket.s3.eu-west-1.amazonaws.com/my-nested-stack-cfn-template.yaml
```
Contributor guide
Assessment
This issue has not been assessed yet.