【问题标题】:Deploying Lambda with Cloud9使用 Cloud9 部署 Lambda
【发布时间】:2023-03-03 18:38:01
【问题描述】:

您好,这是我的项目结构: -AppName -Common -common.js //Global module which i'm using in all functions -Func1 -index.js -Func2 -index.js -template.yaml 这是 template.yaml 的内容:

AWSTemplateFormatVersion: '2010-09-09' Transform: 'AWS::Serverless-2016-10-31' Description: An AWS Serverless Specification template describing your function. Resources: Func1: Type: 'AWS::Serverless::Function' Properties: Handler: Func1/index.handler Runtime: nodejs6.10 MemorySize: 512 Timeout: 10 Func2: Type: 'AWS::Serverless::Function' Properties: Handler: Func2/index.handler Runtime: nodejs6.10 MemorySize: 512 Timeout: 10

当我部署例如 Func2 时,结果包包含应用程序内的所有文件夹,而只有 Func2。是否可以通过 yaml 文件进行配置,结果包中会包含哪些文件? 例如,如果我部署 Func2,我想在下一个包中查看:

-Common -common.js -Func2 -index.js

【问题讨论】:

  • 有人有想法吗?

标签: aws-lambda amazon-cloudformation cloud9 aws-sam-cli aws-cloud9


【解决方案1】:

您可以在 SAM 中使用 CodeUri 键并将其指向您的代码所在的文件夹以执行该功能。

所以对于这个功能,你想做:

  Func2:
    Type: 'AWS::Serverless::Function'
    Properties:
      CodeUri: Func2
      Handler: index.handler
      Runtime: nodejs6.10
      MemorySize: 512
      Timeout: 10

【讨论】:

  • 感谢您的回答。我认为在这种情况下,我将失去与每个功能所需的 Common 文件夹的连接
猜你喜欢
  • 2018-09-07
  • 2016-02-21
  • 2019-06-19
  • 2014-09-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多