我在AWS Cloudformation上遇到了一些问题。我正在尝试合并嵌套堆栈,因为我已经用尽了200个资源限制。这就是我的例子
堆栈A-具有API资源的父堆栈
RestAPI:
Type: AWS::Serverless::Api
Properties:
StageName: !Sub ${Stage}
DefinitionBody:
Fn::Transform:
Name: AWS::Include
Parameters:
Location:
- Fn::Join:
- ''
- - 's3://'
- Ref: S3BucketName
- '/swagger.yaml'
GetLogs:
Type: AWS::Serverless::Function
Properties:
Handler: Logs_Lambda/index.getHandler
Role: !GetAtt RDSLambdaExecutionRole.Arn
Events:
GetUsers:
Type: Api
Properties:
Path: management/logs
Method: get
RestApiId: !Ref RestAPI
堆栈B-堆栈A的子堆栈
LambdaSaveLogsInvokePermission:
Type: AWS::Lambda::Permission
Properties:
FunctionName: !Ref SaveLogs
Action: 'lambda:InvokeFunction'
Principal: apigateway.amazonaws.com
SaveLogs:
Type: AWS::Serverless::Function
Properties:
FunctionName: SaveLogs
CodeUri:
Bucket: !Ref BuildBucketName
Key: !Ref BuildObjectKey
Handler: logs_Lambda/index.saveHandler
Role: !Ref RDSLambdaExecutionRoleArn
Events:
SaveLogs:
Type: Api
Properties:
Path: management/logs/save
Method: post
RestApiId: !Ref RestAPI
我的swagger文件具有这些引用
x-amazon-apigateway-integration:
uri:
Fn::Sub: "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${SaveLogs.Arn}/invocations"
x-amazon-apigateway-integration:
uri:
Fn::Sub: "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${GetLogs.Arn}/invocations"
请注意,堆栈B引用了RestAPI资源,该资源作为参数从堆栈A传递
我的问题和尝试的方法
问题
我的问题是我们如何克服这个问题?
是否可以为每个堆栈使用不同的swagger文件 不知何故?
是否有另一种方法来编写用于API的嵌套堆栈
在考虑可扩展性?
任何人都可以对此发表评论或提供帮助吗?
提前谢谢