'SAM-local fails to start API with multiple stacks
I want to add resources to my root stack and somehow found a function where I can first get stack first like this
my_api = RestApi.from_rest_api_attributes(self, "RestApi",
rest_api_id='test',
root_resource_id='test'
)
and then trying to add resources after getting this stack
mine_ = my_api.root.add_resource("mine")
mine_.add_method(
http_method='GET',
authorizer=api_authorizer
)
on this I am getting this error
ValueError: urls must start with a leading slash
any help would be highly appreciated ..
Edit full traceback of error:
Traceback (most recent call last):
File "samcli/__main__.py", line 12, in <module>
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 1259, in invoke
File "click/core.py", line 1066, in invoke
File "click/core.py", line 610, in invoke
File "samcli/lib/iac/utils/helpers.py", line 55, in wrapper
File "samcli/commands/_utils/iac_validations.py", line 79, in wrapped
File "click/decorators.py", line 73, in new_func
File "click/core.py", line 610, in invoke
File "samcli/lib/telemetry/metric.py", line 174, in wrapped
File "samcli/lib/telemetry/metric.py", line 141, in wrapped
File "samcli/lib/utils/version_checker.py", line 42, in wrapped
File "samcli/cli/main.py", line 90, in wrapper
File "samcli/commands/local/start_api/cli.py", line 128, in cli
File "samcli/commands/local/start_api/cli.py", line 205, in do_cli
File "samcli/commands/local/lib/local_api_service.py", line 68, in start
File "samcli/local/apigw/local_apigw_service.py", line 173, in create
File "flask/app.py", line 98, in wrapper_func
File "flask/app.py", line 1275, in add_url_rule
File "werkzeug/routing.py", line 666, in __init__
ValueError: urls must start with a leading slash
[8038] Failed to execute script __main__
Solution 1:[1]
urls must start with a leading slash
is not an error that CDK throws. It's a werkzeug error, you can see the code in question here.
So the error doesn't have anything to do with your CDK code.
The reason for the error is that SAM does not support testing multiple stacks at this point. So either compile everything into a single stack, or avoid using sam-beta-cdk
.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |