[英]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我想将资源添加到我的根堆栈,并以某种方式找到了一个 function,我可以首先像这样首先获取堆栈
my_api = RestApi.from_rest_api_attributes(self, "RestApi",
rest_api_id='test',
root_resource_id='test'
)
reference https://docs.aws.amazon.com/cdk/api/v1/python/aws_cdk.aws_apigateway/README.html#breaking-up-methods-and-resources-across-stacks参考https://docs.aws.amazon.com/cdk/api/v1/python/aws_cdk.aws_apigateway/README.html#breaking-up-methods-and-resources-across-stacks
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 ValueError:网址必须以斜杠开头
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__
urls must start with a leading slash
is not an error that CDK throws. urls must start with a leading slash
不是 CDK 抛出的错误。 It's a werkzeug error, you can see the code in question here .这是一个 werkzeug 错误,您可以在此处查看有问题的代码。
So the error doesn't have anything to do with your CDK code.所以这个错误与你的 CDK 代码没有任何关系。
The reason for the error is that SAM does not support testing multiple stacks at this point.错误的原因是 SAM 不支持此时测试多个堆栈。 So either compile everything into a single stack, or avoid using
sam-beta-cdk
.因此,要么将所有内容编译到一个堆栈中,要么避免使用
sam-beta-cdk
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.