我正在包括在外部文件中定义的各种资源,并且我在资源部分中也有输出变量。
resources:
- ${file(resources/api-gateway-errors.yml)}
- ${file(resources/dynamodb-table.yml)}
- ${file(resources/cognito-user-pool.yml)}
- ${file(resources/cognito-identity-pool.yml)}
Outputs:
CampaignStateMachine:
Value: !Ref CreateCampaignStateFunction
ProspectStateMachine:
Value: !Ref ProspectCreateStateFunction
使用上面的代码,我得到以下错误:
Cannot parse "serverless.yml": bad indentation of a mapping entry in "/Users/user/serverless/outreachful-api/serverless.yml" (101:3)
98 | - ${file(resources/dynamodb-tab ...
99 | - ${file(resources/cognito-user ...
100 | - ${file(resources/cognito-iden ...
101 | Outputs:
---------^
102 | CampaignStateMachine:
103 | Value: !Ref CreateCampaignS ...
如果删除所有外部文件并仅保留输出,则不会出现错误:
resources:
Outputs:
CampaignStateMachine:
Value: !Ref CreateCampaignStateFunction
ProspectStateMachine:
Value: !Ref ProspectCreateStateFunction
在通过外部文件包含资源以及使用输出变量时,应如何修复此错误的缩进问题?
提前谢谢。
如果看不到您试图导入的示例文件,可能会有点困难,但是仅通过查看您的配置,就会发现您似乎在推荐答案配置中混合了数组表示法和对象表示法。我认为Outputs
也应该是数组的项,所以应该是这样的:
resources:
- ${file(resources/api-gateway-errors.yml)}
- ${file(resources/dynamodb-table.yml)}
- ${file(resources/cognito-user-pool.yml)}
- ${file(resources/cognito-identity-pool.yml)}
- Outputs:
CampaignStateMachine:
Value: !Ref CreateCampaignStateFunction
ProspectStateMachine:
Value: !Ref ProspectCreateStateFunction