问题描述
我有一个 template.yml,我试图在其中定义此资源:
HelloFunction:
Type: 'AWS::Serverless::Function'
Properties:
Handler: handler.hello
Runtime: nodejs12.x
InlineCode:
ZipFile: |
exports.handler = async (event) => {
const response = {
statusCode: 200,body: JSON.stringify('Hello from Lambda function!'),};
return response;
};
Events:
HelloAPI:
Type: HttpApi
Properties:
ApiId: !Ref SpikeApi
Path: /hello
Method: GET
Properties validation Failed for resource HelloFunction with message: #/Code/ZipFile: expected type: String,found: JSONObject
解决方法
使用 SAM 时不需要 ZipFile
。在此处查看 InlineCode
的文档:https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html#sam-function-inlinecode