我尝试在cloudformation中创建一个模板,具有由一个cloudwatch事件规则触发的lambda函数(每10分钟)。在cloudwatch图表中,我可以看到调用,但也可以看到所有失败的调用。我认为这是规则的作用问题,但我无法弄清楚。
import datetime
today = datetime.date.today()
year = int(input('Enter a year: '))
month = int(input('Enter a month: '))
day = int(input('Enter a day: '))
last_market = str(input('Enter date of last known market(yyyymmdd): '))
lm = datetime.date(int(last_market[:4]),int(last_market[4:6]),int(last_market[6:]))
date2 = datetime.date(year, month, day)
mday = datetime.timedelta(days=4)
print('Market days till ',date2.strftime('%d-%m-%Y'))
while lm <= today:
lm = lm + mday
today = lm
while today <= date2:
mtoday = (today.strftime('\nNext Market day: %A, %B %d, %Y'))
print (mtoday)
today = today + mday
答案 0 :(得分:2)
有点晚了,但这里的基本问题是你错过了AWS::Lambda:Permission
的条目。你需要创建一个条目,允许你的事件规则像这样调用你的lambda(我更喜欢yaml,但你明白了):
LambdaInvokePermission:
Type: "AWS::Lambda::Permission"
Properties:
FunctionName: !GetAtt
- CreateBackUp
- Arn
Action: 'lambda:InvokeFunction'
Principal: events.amazonaws.com
SourceArn: !GetAtt
- ER1SCU1
- Arn