使用Alexa技能触发器将Lambda函数部署到AWS

时间:2017-06-13 19:43:24

标签: node.js amazon-web-services aws-lambda alexa-skill

我使用 node-aws-lambda 直接使用gulp和node.js部署lambda函数。功能本身正在正确部署。但是,我尝试配置的触发器是使用Amazon Alexa Smart Home Skill ARN。验证抱怨此ARN不被允许。

这是我的配置(访问和政策很好):

module.exports = {
  accessKeyId: 'AAAAAAAAAAAAAAAAAAA',  // User: 
  secretAccessKey: 'BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB',  // optional
  region: 'eu-west-1',
  handler: 'index.handler',
  role: 'arn:aws:iam::1234567890:role/SmartHomeSkillRole', // KNXSmartHomeSkillRole
  functionName: 'SmartHomeSkill_Remote',
  timeout: 10,
  memorySize: 128,
  publish: true,
  runtime: 'nodejs4.3',
  description: 'A remotely build skill for alexa',
  eventSource: {
    EventSourceArn: 'amzn1.ask.skill.d9d9f7b1-f7d6-4050-a3d1-753e47e7038a', 
    BatchSize: 200,
    StartingPosition: "TRIM_HORIZON"
  }
}

EventSourceArn 中的值是失败的来源(amzn1.ask.skill无效,而在控制台中手动设置触发器效果很好):

ValidationException: 1 validation error detected: Value 'amzn1.ask.skill.d9d9f7b1-f7d6-4050-a3d1-753e47e7038a' at 'eventSourceArn' failed to satisfy constraint: Member must satisfy regular  expression pattern: arn:(aws|aws-us-gov):([a-zA-Z0-9\-])+:([a-z]{2}(-gov)?-[a-z]+-\d{1})?:(\d{12})?:(.*)
    at Object.extractError (E:\DropBox\p\jisageek\IoT\AlexaKNX\node_modules\aws-sdk\lib\protocol\json.js:48:27)
    at Request.extractError (E:\DropBox\p\jisageek\IoT\AlexaKNX\node_modules\aws-sdk\lib\protocol\rest_json.js:37:8)
    at Request.callListeners (E:\DropBox\p\jisageek\IoT\AlexaKNX\node_modules\aws-sdk\lib\sequential_executor.js:105:20)
    at Request.emit (E:\DropBox\p\jisageek\IoT\AlexaKNX\node_modules\aws-sdk\lib\sequential_executor.js:77:10)
    at Request.emit (E:\DropBox\p\jisageek\IoT\AlexaKNX\node_modules\aws-sdk\lib\request.js:682:14)
    at Request.transition (E:\DropBox\p\jisageek\IoT\AlexaKNX\node_modules\aws-sdk\lib\request.js:22:10)
    at AcceptorStateMachine.runTo (E:\DropBox\p\jisageek\IoT\AlexaKNX\node_modules\aws-sdk\lib\state_machine.js:14:12)
    at E:\DropBox\p\jisageek\IoT\AlexaKNX\node_modules\aws-sdk\lib\state_machine.js:26:10
    at Request.<anonymous> (E:\DropBox\p\jisageek\IoT\AlexaKNX\node_modules\aws-sdk\lib\request.js:38:9)
    at Request.<anonymous> (E:\DropBox\p\jisageek\IoT\AlexaKNX\node_modules\aws-sdk\lib\request.js:684:12)

这是sdk中的错误还是我必须手动配置触发器还是有其他方式以编程方式创建触发器?

任何建议表示赞赏。谢谢!

约尔格

1 个答案:

答案 0 :(得分:0)

我之前没有做过您的尝试,但快速查看您的错误消息表明您提供了错误的ARN。

Value 'amzn1.ask.skill.d9d9f7b1-f7d6-4050-a3d1-753e47e7038a' at 'eventSourceArn' 
failed to satisfy constraint: 
Member must satisfy regular  expression pattern: arn:(aws|aws-us-gov):([a-zA-Z0-9\-])+:([a-z]{2}(-gov)?-[a-z]+-\d{1})?:(\d{12})?:(.*)

提供的正则表达式声明您的引用应该以“arn:”开头,就像Amazon Lambda提供的那样。

例如上面的ARN

arn:aws:iam::1234567890:role/SmartHomeSkillRole

您似乎已经提供了Alexa开发者服务提供的Alexa技能标识符。

amzn1.ask.skill.d9d9f7b1-f7d6-4050-a3d1-753e47e7038a

我会尝试交换EventSourceArn:使用Roll:或同时尝试两者作为arn值。 - 希望这会有所帮助,但就像我说的那样,这是对所提供信息的推测。