我对Serverless还是个新手。我最近在Serverless上遇到了可怕的200资源限制问题,因此我试图分解我的服务,并在它们之间使用一个公共的API网关,但我一直得到Another resource with the same parent already has this name: assets。我使用公共api网关属性,因为我没有此服务的域。
这是我的主serverless.yml
app: xxx
org: xxx
service: xxx
provider:
name: aws
runtime: nodejs12.x
region: xxx
functions:
....
resources:
Outputs:
ApiGatewayRestId:
Value:
Ref: ApiGatewayRestApi
Export:
Name: assetsapi-${opt:stage, self:provider.stage}-ApiGatewayRestId
RootResourceId:
Value:
Fn::GetAtt:
- ApiGatewayRestApi
- RootResourceId
Export:
Name: assetsapi-${opt:stage, self:provider.stage}-RootResourceId
IamRoleLambdaExecution:
Value:
Fn::GetAtt: IamRoleLambdaExecution.Arn
Export:
Name: assetsapi-${opt:stage, self:provider.stage}-IamRoleLambdaExecution
ApiGatewayResourceMaintainence:
Value:
Ref: ApiGatewayResourceMaintainence
Export:
Name: assetsapi-${opt:stage, self:provider.stage}-ApiGatewayResourceMaintainence
Resources:
# Rest API
ApiGatewayRestApi:
Type: AWS::ApiGateway::RestApi
Properties:
Name: assetsapi
Description: assets API Gateway
# Rest API Paths
ApiGatewayResourceMaintainence:
Type: AWS::ApiGateway::Resource
Properties:
RestApiId: { Ref: 'ApiGatewayRestApi' }
ParentId: { Fn::GetAtt: 'ApiGatewayRestApi.RootResourceId' }
PathPart: maintain这是位于路径api/maintainence/serverless.yml内的第二个服务的serverless.yml文件
service: maintainencemanagementservice
custom:
stage: '${opt:stage, self:provider.stage}'
region: ${opt:region, self:provider.region}
prefix: ${self:service}-${self:custom.region}-${self:custom.stage}
rootApiGatewayId: 'assets-api-${self:custom.region}-${self:custom.stage}-restApiId'
rootApiGatewayResourceId: 'assets-api-${self:custom.region}-${self:custom.stage}-rootResourceId'
provider:
name: aws
runtime: nodejs12.x
stage: dev
region: xxxx
apiGateway:
restApiId:
Fn::ImportValue: assetsapi-${opt:stage, self:provider.stage}-ApiGatewayRestId
restApiRootResourceId:
Fn::ImportValue: assetsapi-${opt:stage, self:provider.stage}-RootResourceId
restApiResources:
/maintainence:
Fn::ImportValue: assetsapi-${opt:stage, self:provider.stage}-ApiGatewayResourceMaintainence,
role:
Fn::ImportValue: assetsapi-${opt:stage, self:provider.stage}-IamRoleLambdaExecution发布于 2020-06-02 20:07:22
我意外地使用了从第二个服务函数i.e. assets/addmaintainence开始的相同路径,将其更改为maintainence/addmaintainence实现了此目的
https://stackoverflow.com/questions/62138579
复制相似问题