0

我正在使用 Claduiajs 创建 lambda 函数,但我仍在发现它可以做什么和不能做什么,到目前为止,我能够创建一个连接到 AWS DynamoDB 的 lambda 函数,并且一切都按预期工作,但是当我尝试添加按照本教程使用 Claudia API Builder 在 API中,触发器不会添加到 lambda 函数中。

我在设置 npm 并安装依赖项后采取的步骤是:

第 1 步:将这个函数写在main.js

    const AWS = require('aws-sdk'); // Used for DynamoDB
    const performance = require('performance-now'); // Used to measure performance
    const deepExtend = require('deep-extend'); // Used to deep extend json arrays

    const docClient = new AWS.DynamoDB.DocumentClient({region: 'ap-southeast-2'});
    const TableName = 'Agent-commands';

    var ApiBuilder = require('claudia-api-builder'),
    api = new ApiBuilder();

    module.exports = api;

    api.post('/',function(request){
      console.info('request',request);
    });

第 2 步:运行此命令以创建函数和 apiclaudia create --name add-command-for-agent --region ap-southeast-2 --api-module main --timeout 10 --policies policies/*.json 一旦我这样做了,我会在终端中得到这个:

saving configuration
{
  "lambda": {
    "role": "add-command-for-agent-executor",
    "name": "add-command-for-agent",
    "region": "ap-southeast-2"
  },
  "api": {
    "id": "l223cd1rl7",
    "module": "main",
    "url": "https://l223cd1rl7.execute-api.ap-southeast-2.amazonaws.com/latest"
  }
}

当我去那个网址时,我得到{"message":"Missing Authentication Token"}

当我检查claduia.json由 create 命令创建的文件时,我看不到那里的 url,只有 id 和模块。

当我在 AWS 控制台上检查 lambda 函数时,没有附加任何触发器。

我做错了什么还是一个错误?

4

1 回答 1

0

我之前遇到过这个问题,在我的情况下,IAM 角色没有必要的权限。我会重新检查您的 IAM 角色以确保它具有所需的所有权限。

于 2017-11-08T11:12:05.030 回答