Microservices 同一AWS API网关内的多个微服务
我正在开发一系列需要共享同一AWSAPI网关的微服务。这是我的结构:Microservices 同一AWS API网关内的多个微服务,microservices,aws-api-gateway,serverless-framework,serverless-architecture,Microservices,Aws Api Gateway,Serverless Framework,Serverless Architecture,我正在开发一系列需要共享同一AWSAPI网关的微服务。这是我的结构: / /assessments /skills /work-values /graphql /技能、/work values和/graphql是我试图在同一个AWSAPI网关上注册的3种不同的微服务。我遇到的问题是如何将/skills、/work values路由的serverless.yaml文件嵌套在“assessment”下。其本身没有用于/评估的功能。它的存在只是为了让我
/
/assessments
/skills
/work-values
/graphql
/技能、/work values和/graphql是我试图在同一个AWSAPI网关上注册的3种不同的微服务。我遇到的问题是如何将/skills、/work values路由的serverless.yaml文件嵌套在“assessment”下。其本身没有用于/评估的功能。它的存在只是为了让我们可以在相同的URL路径结构下组织所有评估
这是我的serverless.yaml文件,用于“/work values”:
这是我的serverless.yaml文件,用于“/assessments”:
问题似乎是在serverless.yaml文件中为评估路由编码输出。运行无服务器部署时,会收到以下错误消息:
Error: The CloudFormation template is invalid: Unresolved resource dependencies [ApiGatewayRestApi] in the Outputs block of the template
在文章的最后,作者提到“您必须从计费api导入/计费,因此新服务只需要创建/billing/xyz部分。”这似乎就是我所处的情况。但是,作者没有解释如何导入/计费。或者,在我的例子中,如何为每个评估微服务导入/评估到serverless.yaml文件中?进一步研究后,我发现以下链接: 我最终按照上面的文章重新设计了我原来的方法。我缺少的是一个根或基本无服务器文件,用于在AWS API Gateway中创建路由,并将这些占位符作为输出公开,随后的无服务器子文件将其用作输入,用于将子lambda函数连接到API Gateway保护伞下的路由
service:
name: assessments
custom:
stage: ${opt:stage, self:provider.stage}
provider:
...
apiGateway:
restApiId:
# THE FOLLOWING REFERENCES A VARIABLE FROM MY API GATEWAY ROOT
'Fn::ImportValue': ${self:custom.stage}-ApiGatewayRestApiId
restApiRootResourceId:
'Fn::ImportValue': ${self:custom.stage}-ApiGatewayRestApiRootResourceId
functions:
...
resources:
Outputs:
ApiGatewayRestApiId:
Value:
Ref: ApiGatewayRestApi
Export:
Name: ${self:custom.stage}-Assessments-ApiGatewayRestApiId
ApiGatewayRestApiRootResourceId:
Value:
Fn::GetAtt:
- ApiGatewayRestApi
- RootResourceId
Export:
Name: ${self:custom.stage}-Assessments-ApiGatewayRestApiRootResourceId
Error: The CloudFormation template is invalid: Unresolved resource dependencies [ApiGatewayRestApi] in the Outputs block of the template