我得到了 AWS 示例无服务器应用程序,其中有单个 yaml 文件和多个处理程序。
问题是 template.yaml 一直在增长,如何为每个处理程序或一组处理程序分离 yaml 以便于管理。
我得到了 AWS 示例无服务器应用程序,其中有单个 yaml 文件和多个处理程序。
问题是 template.yaml 一直在增长,如何为每个处理程序或一组处理程序分离 yaml 以便于管理。
对于我们的项目,我们开始将主要的 YAML 划分为以下方式:
所有 lambdas 仍然在 serverless.yml 文件中描述
在 serverless.yml
resources:
- ${file(./sls-config/cognito-user-pools-authorizer.yml)}
- ${file(./sls-config/aurora.yml)}
- ${file(./sls-config/bucket.yml)}
- ${file(./sls-config/queues.yml)}
- ${file(./sls-config/alarms.yml)}
- ${file(./sls-config/roles.yml)}
- ${file(./sls-config/outputs.yml)}
是的,资源分配给你。
警报.yml
Resources:
SQSAlarmTopic:
Type: AWS::SNS::Topic
Properties:
DisplayName: ${self:provider.prefix}-sqs-alarm-topic
TopicName: ${self:provider.prefix}-sqs-alarm-topic
Subscription:
- Endpoint: example-email@mail.com
Protocol: email
Tags: ${self:custom.sqsTags}
等等。
输出.yml
Outputs:
CognitoUserPoolId:
Value: ${self:custom.userPool}
CognitoUserPoolClientId:
Value: ${self:custom.userPoolClientId}
DSClusterID:
Description: "RDS Cluster "
Value: { Ref: RDSCluster }
DBAddress:
Value: !GetAtt RDSCluster.Endpoint.Address
来自 custom 和 provide 的变量可以通过 sub_configs.yml 轻松使用。
注意 yaml 文件中的间距/填充:)