无服务器框架:无服务器错误功能未找到:

用户名

我开始使用nodejs和无服务器框架。

我的handler.js包含:

'use strict';
var index = require('./index.js');

module.exports.hello = async event => {
  var res = await index.main();

  console.log('hello');
  console.log(res);

  console.log('IN HANDLER');
  return {
    statusCode: 200,
    body: JSON.stringify(
      {
        message: 'main function executed!',
        input: event,
      },
      null,
      2
    ),
  };


};

我的serverless.yml包含:

# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
# frameworkVersion: "=X.X.X"

provider:
  name: aws
  runtime: nodejs12.x
  region: us-east-1
  # here we put the layers we want to use
  layers:
    # Google Chrome for AWS Lambda as a layer
    # Make sure you use the latest version depending on the region
    # https://github.com/shelfio/chrome-aws-lambda-layer
    # - arn:us-east-1:arn:aws:lambda:us-east-1:764866452798:layer:chrome-aws-lambda:10
    - arn:aws:lambda:us-east-1:764866452798:layer:chrome-aws-lambda:10
  # function parameters

# you can add packaging information here
#package:
#  include:
#    - include-me.js
#    - include-me-dir/**
#  exclude:
#    - exclude-me.js
#    - exclude-me-dir/**

functions:
  hello:
    handler: handler.hello
  # main:
    # handler: handler.main
#    The following are a few example events you can configure
#    NOTE: Please make sure to change your handler code to work with those events
#    Check the event documentation for details
    events:
     - http:
         path: hello/get
         method: get

我的index.js:

async function main(event, context, callback) {
  const chromium = require('chrome-aws-lambda');
  const puppeteer = require('puppeteer');
  const os = require('os');
  const CREDS = require('./.creds');

  // exports.handler = async (event, context, callback) => {
  let result = null;
  let browser = null;

    try {
      browser = await chromium.puppeteer.launch({
        args: chromium.args,
        defaultViewport: chromium.defaultViewport,
        executablePath: await chromium.executablePath,
        headless: chromium.headless,
        ignoreHTTPSErrors: true,
      })
    } 
      catch {
      console.log('browser failed')
    };



  var page = await browser.newPage();

   ........



  // })().catch(e => { console.error(e) });
};

main().catch(e => { console.error(e) });

module.exports.main = main;

当我跑步时:

$ sls invoke -f hello

 Serverless Error ---------------------------------------

 Function not found: arn:aws:lambda:us-east-1:155754363046:function:sellthelandnow-dev-hello

错误在标题中。我在这里做错了什么?

艾希什·巴蒂亚(Ashish Bhatia)

让我在这里解释。无服务器框架可以通过两种方式(本地和在Cloud-AWS中)调用(运行)lambda。看来您正在尝试在AWS中调用lambda。(arn:aws:lambda:us-east-1:155754363046:function:sellthelandnow-dev-hello)基本上,您的AWS-155754363046帐户中不存在该arn。你需要使用

serverless deploy

将lamdba部署到aws env。如果只想在本地测试,则命令为

serverless invoke local --function functionName

因此我建议您在云中调用lambda。您需要先进行部署,或者使用invoke local。

谢谢,

阿什什

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

无服务器框架最佳实践

来自分类Dev

无服务器框架输出

来自分类Dev

微服务与Lambda与无服务器功能之间的差异

来自分类Dev

AWS无服务器框架使用GIT进行协作

来自分类Dev

无服务器框架Postgresql版本升级问题

来自分类Dev

带有节点MySQL的无服务器框架

来自分类Dev

无服务器框架TypeError:e不是函数

来自分类Dev

无服务器框架lambda执行角色不匹配?

来自分类Dev

无服务器框架Python lambda直接返回JSON

来自分类Dev

在无服务器框架中使用路径参数

来自分类Dev

使用无服务器框架模拟响应数据

来自分类Dev

无服务器框架-无法识别的属性“参数”

来自分类Dev

无服务器框架Postgresql版本升级问题

来自分类Dev

AWS无服务器框架使用GIT进行协作

来自分类Dev

如何在无服务器框架中使用 jquery?

来自分类Dev

无服务器框架 S3 事件规则

来自分类Dev

无服务器部署-找不到功能

来自分类Dev

如何使用无服务器功能获取RAW主体?

来自分类Dev

REST API 的服务器与无服务器

来自分类Dev

使用无服务器框架部署cube.js会导致错误

来自分类Dev

使用graphql,aws lambda和无服务器框架的多个URL路径选项错误

来自分类Dev

无服务器框架错误策略语句必须包含操作

来自分类Dev

带有节点MySQL的无服务器框架:PROTOCOL_INCORRECT_PACKET_SEQUENCE错误

来自分类Dev

如何使用无服务器框架在AWS Aurora无服务器中自动创建表

来自分类Dev

Sequelize无服务器脱机迁移错误

来自分类Dev

无服务器部署错误配置堆栈

来自分类Dev

无服务器-部署期间出现“未知对象类型异步功能”错误

来自分类Dev

无服务器计划,检测cron

来自分类Dev

节点服务器无响应

Related 相关文章

热门标签

归档