- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试将堆栈拆分为嵌套堆栈,因为我达到了 AWS 最大堆栈资源限制。我正在构建一个 REST API。我想对所有堆栈使用一个 API 网关。下面是我的代码。
模板.yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
aws-restapi
Sample SAM Template for aws-restapi
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 5
VpcConfig:
SecurityGroupIds:
- sg-041f2xxxd921e8e
SubnetIds:
- subnet-03xxxb2d
- subnet-c4dxxxcb
Resources:
ApiGatewayApi:
Type: AWS::Serverless::Api
Properties:
StageName: prod
GetAllAccountingTypesFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: aws-restapi/
Handler: source/accounting-types/accountingtypes-getall.getallaccountingtypes
Runtime: nodejs14.x
Events:
GetAllAccountingTypesAPIEvent:
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Properties:
Path: /accountingtypes/getall
Method: get
RestApiId:
Ref: ApiGatewayApi
GetAccountingTypeByIDFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: aws-restapi/
Handler: source/accounting-types/accountingtypes-byid.getbyid
Runtime: nodejs14.x
Events:
GetAllAccountingTypesAPIEvent:
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Properties:
Path: /accountingtypes/getbyid
Method: get
RestApiId:
Ref: ApiGatewayApi
NestedStackTwo:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: nestedstack.yaml
LambdaRole:
Type: 'AWS::IAM::Role'
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action:
- 'sts:AssumeRole'
Path: /
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
Policies:
- PolicyName: root
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- ec2:DescribeNetworkInterfaces
- ec2:CreateNetworkInterface
- ec2:DeleteNetworkInterface
- ec2:DescribeInstances
- ec2:AttachNetworkInterface
Resource: '*'
Outputs:
HelloWorldApi:
Description: "API Gateway endpoint URL for Prod stage for functions"
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/"
nestedstack.yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
aws-restapi
Sample SAM Template for aws-restapi
Globals:
Function:
Timeout: 5
VpcConfig:
SecurityGroupIds:
- sg-041f2459dcd921e8e
SubnetIds:
- subnet-03xxxx2d
- subnet-c4dxxxxcb
Parameters:
ApiId: ApiGatewayApi
Resources:
GetAllPromotionsFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: aws-restapi/
Handler: source/promotions/promotions-getall.getAllPromotions
Runtime: nodejs14.x
Events:
GetAllPromotionsAPIEvent:
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Properties:
Path: /promotions/getall
Method: get
RestApiId:
Ref: !Ref ApiId
SavePromotionsFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: aws-restapi/
Handler: source/promotions/promotions-save.savePromotions
Runtime: nodejs14.x
Events:
SavePromotionsAPIEvent:
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Properties:
Path: /promotions/save
Method: post
RestApiId:
Ref: !Ref ApiId
UpdatePromotionsFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: aws-restapi/
Handler: source/promotions/promotions-update.updatePromotions
Runtime: nodejs14.x
Events:
UpdatePromotionsAPIEvent:
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Properties:
Path: /promotions/update
Method: post
RestApiId:
Ref: !Ref ApiId
GetAllStaticInfoFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: aws-restapi/
Handler: source/static-info/staticinfo-getall.getAllStaticInfo
Runtime: nodejs14.x
Events:
GetAllStaticInfoAPIEvent:
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Properties:
Path: /staticinfo/getall
Method: get
RestApiId:
Ref: !Ref ApiId
SaveStaticInfoFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: aws-restapi/
Handler: source/static-info/staticinfo-save.saveStaticInfo
Runtime: nodejs14.x
Events:
SaveStaticInfoAPIEvent:
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Properties:
Path: /staticinfo/save
Method: post
RestApiId:
Ref: !Ref ApiId
UpdateStaticInfoFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: aws-restapi/
Handler: source/static-info/staticinfo-update.updateStaticInfo
Runtime: nodejs14.x
Events:
UpdateStaticInfoAPIEvent:
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Properties:
Path: /staticinfo/update
Method: post
RestApiId:
Ref: !Ref ApiId
但是,我无法使用 sam build
构建此项目。我收到以下错误。
InvalidSamDocumentException(
samcli.commands.validate.lib.exceptions.InvalidSamDocumentException: [InvalidResourceException('GetAllPromotionsFunction', 'Event with id [GetAllPromotionsAPIEvent] is invalid. Api Event must reference an Api in the same template.')
嵌套堆栈中的所有函数都会生成上述错误。如果您需要完整的堆栈跟踪,请参见下面。
Traceback (most recent call last):
File "/opt/homebrew/Cellar/aws-sam-cli/1.29.0/libexec/lib/python3.8/site-packages/samcli/lib/samlib/wrapper.py", line 68, in run_plugins
parser.parse(template_copy, all_plugins) # parse() will run all configured plugins
File "/opt/homebrew/Cellar/aws-sam-cli/1.29.0/libexec/lib/python3.8/site-packages/samcli/lib/samlib/wrapper.py", line 88, in parse
sam_plugins.act(LifeCycleEvents.before_transform_template, sam_template)
File "/opt/homebrew/Cellar/aws-sam-cli/1.29.0/libexec/lib/python3.8/site-packages/samtranslator/plugins/__init__.py", line 136, in act
raise ex
File "/opt/homebrew/Cellar/aws-sam-cli/1.29.0/libexec/lib/python3.8/site-packages/samtranslator/plugins/__init__.py", line 133, in act
getattr(plugin, method_name)(*args, **kwargs)
File "/opt/homebrew/Cellar/aws-sam-cli/1.29.0/libexec/lib/python3.8/site-packages/samtranslator/plugins/api/implicit_api_plugin.py", line 100, in on_before_transform_template
raise InvalidDocumentException(errors)
samtranslator.model.exceptions.InvalidDocumentException: [InvalidResourceException('GetAllPromotionsFunction', 'Event with id [GetAllPromotionsAPIEvent] is invalid. Api Event must reference an Api in the same template.'), InvalidResourceException('SavePromotionsFunction', 'Event with id [SavePromotionsAPIEvent] is invalid. Api Event must reference an Api in the same template.'), InvalidResourceException('UpdatePromotionsFunction', 'Event with id [UpdatePromotionsAPIEvent] is invalid. Api Event must reference an Api in the same template.'), InvalidResourceException('GetAllStaticInfoFunction', 'Event with id [GetAllStaticInfoAPIEvent] is invalid. Api Event must reference an Api in the same template.'), InvalidResourceException('SaveStaticInfoFunction', 'Event with id [SaveStaticInfoAPIEvent] is invalid. Api Event must reference an Api in the same template.'), InvalidResourceException('UpdateStaticInfoFunction', 'Event with id [UpdateStaticInfoAPIEvent] is invalid. Api Event must reference an Api in the same template.')]
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/homebrew/bin/sam", line 8, in <module>
sys.exit(cli())
File "/opt/homebrew/Cellar/aws-sam-cli/1.29.0/libexec/lib/python3.8/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/opt/homebrew/Cellar/aws-sam-cli/1.29.0/libexec/lib/python3.8/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/opt/homebrew/Cellar/aws-sam-cli/1.29.0/libexec/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/opt/homebrew/Cellar/aws-sam-cli/1.29.0/libexec/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/opt/homebrew/Cellar/aws-sam-cli/1.29.0/libexec/lib/python3.8/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/opt/homebrew/Cellar/aws-sam-cli/1.29.0/libexec/lib/python3.8/site-packages/click/decorators.py", line 73, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "/opt/homebrew/Cellar/aws-sam-cli/1.29.0/libexec/lib/python3.8/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/opt/homebrew/Cellar/aws-sam-cli/1.29.0/libexec/lib/python3.8/site-packages/samcli/lib/telemetry/metric.py", line 153, in wrapped
raise exception # pylint: disable=raising-bad-type
File "/opt/homebrew/Cellar/aws-sam-cli/1.29.0/libexec/lib/python3.8/site-packages/samcli/lib/telemetry/metric.py", line 122, in wrapped
return_value = func(*args, **kwargs)
File "/opt/homebrew/Cellar/aws-sam-cli/1.29.0/libexec/lib/python3.8/site-packages/samcli/lib/utils/version_checker.py", line 42, in wrapped
actual_result = func(*args, **kwargs)
File "/opt/homebrew/Cellar/aws-sam-cli/1.29.0/libexec/lib/python3.8/site-packages/samcli/cli/main.py", line 90, in wrapper
return func(*args, **kwargs)
File "/opt/homebrew/Cellar/aws-sam-cli/1.29.0/libexec/lib/python3.8/site-packages/samcli/commands/build/command.py", line 210, in cli
do_cli(
File "/opt/homebrew/Cellar/aws-sam-cli/1.29.0/libexec/lib/python3.8/site-packages/samcli/commands/build/command.py", line 279, in do_cli
with BuildContext(
File "/opt/homebrew/Cellar/aws-sam-cli/1.29.0/libexec/lib/python3.8/site-packages/samcli/commands/build/build_context.py", line 84, in __enter__
self._stacks, remote_stack_full_paths = SamLocalStackProvider.get_stacks(
File "/opt/homebrew/Cellar/aws-sam-cli/1.29.0/libexec/lib/python3.8/site-packages/samcli/lib/providers/sam_stack_provider.py", line 242, in get_stacks
stacks_in_child, remote_stack_full_paths_in_child = SamLocalStackProvider.get_stacks(
File "/opt/homebrew/Cellar/aws-sam-cli/1.29.0/libexec/lib/python3.8/site-packages/samcli/lib/providers/sam_stack_provider.py", line 236, in get_stacks
current = SamLocalStackProvider(
File "/opt/homebrew/Cellar/aws-sam-cli/1.29.0/libexec/lib/python3.8/site-packages/samcli/lib/providers/sam_stack_provider.py", line 51, in __init__
self._template_dict = self.get_template(
File "/opt/homebrew/Cellar/aws-sam-cli/1.29.0/libexec/lib/python3.8/site-packages/samcli/lib/providers/sam_base_provider.py", line 189, in get_template
template_dict = SamTranslatorWrapper(template_dict, parameter_values=parameters_values).run_plugins()
File "/opt/homebrew/Cellar/aws-sam-cli/1.29.0/libexec/lib/python3.8/site-packages/samcli/lib/samlib/wrapper.py", line 70, in run_plugins
raise InvalidSamDocumentException(
samcli.commands.validate.lib.exceptions.InvalidSamDocumentException: [InvalidResourceException('GetAllPromotionsFunction', 'Event with id [GetAllPromotionsAPIEvent] is invalid. Api Event must reference an Api in the same template.'), InvalidResourceException('SavePromotionsFunction', 'Event with id [SavePromotionsAPIEvent] is invalid. Api Event must reference an Api in the same template.'), InvalidResourceException('UpdatePromotionsFunction', 'Event with id [UpdatePromotionsAPIEvent] is invalid. Api Event must reference an Api in the same template.'), InvalidResourceException('GetAllStaticInfoFunction', 'Event with id [GetAllStaticInfoAPIEvent] is invalid. Api Event must reference an Api in the same template.'), InvalidResourceException('SaveStaticInfoFunction', 'Event with id [SaveStaticInfoAPIEvent] is invalid. Api Event must reference an Api in the same template.'), InvalidResourceException('UpdateStaticInfoFunction', 'Event with id [UpdateStaticInfoAPIEvent] is invalid. Api Event must reference an Api in the same template.')] ('GetAllPromotionsFunction', 'Event with id [GetAllPromotionsAPIEvent] is invalid. Api Event must reference an Api in the same template.') ('GetAllStaticInfoFunction', 'Event with id [GetAllStaticInfoAPIEvent] is invalid. Api Event must reference an Api in the same template.') ('SavePromotionsFunction', 'Event with id [SavePromotionsAPIEvent] is invalid. Api Event must reference an Api in the same template.') ('SaveStaticInfoFunction', 'Event with id [SaveStaticInfoAPIEvent] is invalid. Api Event must reference an Api in the same template.') ('UpdatePromotionsFunction', 'Event with id [UpdatePromotionsAPIEvent] is invalid. Api Event must reference an Api in the same template.') ('UpdateStaticInfoFunction', 'Event with id [UpdateStaticInfoAPIEvent] is invalid. Api Event must reference an Api in the same template.')
我该如何解决这个问题?
最佳答案
如果你查看documentation对于无服务器功能的 API 事件,他们写道:
RestApiId Identifier of a RestApi resource, which must contain anoperation with the given path and method. Typically, this is set toreference an AWS::Serverless::Api resource defined in this template.
If you don't define this property, AWS SAM creates a defaultAWS::Serverless::Api resource using a generated OpenApi document. Thatresource contains a union of all paths and methods defined by Apievents in the same template that do not specify a RestApiId.
This cannot reference an AWS::Serverless::Api resource defined inanother template.
template.yaml:
NestedStackTwo:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: nestedstack.yaml
Parameters:
ApiId: !Ref ApiGatewayApi
nestedstack.yaml:
Parameters:
ApiId:
Type: string
关于amazon-web-services - AWS 云信息 : How to fix "Api Event must reference an Api in the same template" error?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68979324/
我想在 java 中声明一个对象,就像在 C++ 中指向指针的指针,让我给你看一个例子: //*** At the application startup //Initialize a setting
考虑这段代码, struct A {}; struct B { B(const A&) {} }; void f(B) { cout << "f()"<
我正在尝试将一个C程序翻译成Rust。。C程序具有以下结构(归结为MRE):。在一个函数中,我将执行以下指针魔术:。不,我的问题是:我将如何在铁锈中实现同样的目标?。到目前为止,我在《铁锈》中尝试过的
我目前正在尝试将一个C程序翻译成Rust。。C程序具有以下结构(归结为MRE):。在一个函数中,我将执行以下指针魔术:。不,我的问题是:我将如何在铁锈中实现同样的目标?。到目前为止,我在《铁锈》中尝试
这个问题在这里已经有了答案: Add managed DLL dependencied to unmanaged C++ project (1 个回答) 关闭 6 年前。 我有这样一个场景: 使用
这是一个常见问答的集合,这也是一个社区维基,所以每个人都被邀请参与维护它。。正则表达式正在遭受给我ZE代码类型的问题和没有解释的糟糕答案。此参考旨在提供指向质量问答的链接。。此参考适用于以下语言:PH
我正在尝试在方案中模拟堆栈。我正在使用 DrScheme 并选择语言 R5RS。我需要创建 pop、push 和 peek 的函数。但我无法弄清楚如何通过引用传递。我已经阅读了一些关于盒子的信息,但是
我陷入了这个错误。我将代码部署在生产服务器上,它在端口 80 上运行。当我尝试登录管理页面时。如图所示,它给了我 403 错误。 可能是什么原因?我的 Django 代码或 nginx 配置有问题吗?
这是一段简单的 C++ 代码: A foo(){ A a; // create a local A object return a; } void bar(const A & a_r){ }
我正在使用从 torrenteditor 获取的 php 脚本来创建 torrent 文件,但是当我使用指定的方法创建新的 torrent 文件时,torrent 文件被创建但我收到很多通知。,就像这
MySQL: REFERENCES vs FOREIGN KEY + REFERENCES 我认为 REFERENCES 是更冗长的 FOREIGN KEY REFERENCES 语法的某种速记语法。
我想使用基于另一个方法引用的方法引用。这有点难以解释,所以我给你举个例子: Person.java public class Person{ Person sibling; int a
Java/C# 语言律师喜欢说他们的语言通过值传递引用。这意味着“引用”是在调用函数时复制的对象指针。 同时,在 C++ 中(以及在 Perl 和 PHP 中更动态的形式),引用是某个其他名称(或动态
当我需要实现递归 lambda 时,通常我这样做: auto factorial = [](auto& self, int n) -> int { return n == 0 ? 1 : n
我目前正在研究 DDD ,需要一些启发。 我有两个实体 Temple TempleVariant Temple(听筒)包含基本信息(名称,描述等),并具有n个变体,它们具有技术描述(CAD绘图,尺寸,
在 Grails 中 belongsTo允许一个域类与另一个域类建立级联关系。使用belongsTo时有两种类型的关系:引用和无引用。 Reference 在拥有的对象上创建属性,而 No Refer
我正在使用 AWS 和 Django Rest Framework 开发 Web 应用程序。(Django:v1.8,DRF:v3) 我一直在为 POST 多部分表单请求获取 django.reque
我按照下面的定义公开了 WCF 端点, 当我在 .NET 3.5 中添加“服务引用”时,我们在代理中获得了以下类,这非常好: [Syst
我在玩 constexpr 引用时产生了这种感觉。但问题本身与 constexpr 无关,只是被它揭示。 我们知道有“指向const的指针”,也有“const指针”。顺便说一句,由于后者的使用比前者少
我有 2 种类型的 refences,它们中的每一种都可以正常工作。 我尝试使用每一个并在 project build 中得到相同的结果。 请向我解释 COM 引用和引用之间的区别。 谢谢你。 最佳答
我是一名优秀的程序员,十分优秀!