我有一个SAM模板文件,该文件在执行select Status as "Status",
max(case when ceil(rn/(cn/2))=1 then val end) as "High",
max(case when ceil(rn/(cn/2))=2 then val end) as "Normal"
from
(
select row_number() over (order by 1) as rn,
count(*) over (order by 1) as cn,
Status,val
from tab
unpivot (val for Status in (Total, Executed, Pass, Fail, Blocked, Not_Executed))
)
group by status;
时出错:function averageString(name,numbers) {
let sum = 0;
numbers.forEach(function (x) {
sum += x;
});
return 'The average of (' + name + ') is ' + sum / numbers.length;
}
document.getElementById("returnVal").innerHTML = averageString('age',[12, 15, 20])
首先,在我的文件顶部(与sam build
处于同一级别),我发生了此事件(其想法是定义每15分钟触发一次并调用lambda的CloudWatch时间表):>
[InvalidResourceException('MyFunction', "Type of property 'Events' is invalid.")]
这是函数的样子:
Globals
之所以这样做,是因为我早先看到以下语法是有效的:
Events:
Type: Schedule
Properties:
Schedule: rate(15 mins)
name: InvokeEvery15MinutesSchedule
Description: Invoke the target every 15 mins
Enabled: True
所以,我认为,如果我在顶级定义一个事件并在lambda中引用它,那么它将起作用。我想将其保留在Lambda声明之外,因为我希望将其应用于多个函数。
有人可以帮我解决我做错的事吗?
答案 0 :(得分:1)
“事件”是一个lambda源对象,它定义触发该功能的事件。描述触发该函数的事件源的对象。 试试这个:
MyFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./path-to-code
Events:
RateSchedule:
Type: Schedule
Properties:
Schedule: rate(15 mins)
Name: InvokeEvery15MinutesSchedule
Description: Invoke the target every 15 mins
Enabled: True