질문 : 기능마다 하나씩 여러 개의 람다 식을 첨부해야합니까? 이 코드 목록 프로젝트? 답변 : 예
AWS CodeStar 프로젝트 세부 사항 :
AWS 코드 스타 프로젝트 파일 구조 아래에 포함 (reference link) :
README.md - this file
buildspec.yml - this file is used by AWS CodeBuild to package your service for deployment to AWS Lambda
app.js - this file contains the sample Node.js code for the web service
index.js - this file contains the AWS Lambda handler code
template.yml - this file contains the Serverless Application Model (SAM) used by AWS Cloudformation to deploy your service to AWS Lambda and Amazon API Gateway.
은 아래처럼 template.yml 파일이 있다고 가정 :
AWSTemplateFormatVersion: 2010-09-09
Transform:
- AWS::Serverless-2016-10-31
- AWS::CodeStar
Resources:
HelloWorld:
Type: AWS::Serverless::Function
Properties:
Handler: index.first_handler
Runtime: nodejs4.3
Role:
Fn::ImportValue:
!Join ['-', [!Ref 'ProjectId', !Ref 'AWS::Region', 'LambdaTrustRole']]
Events:
GetEvent:
Type: Api
Properties:
Path: /first
Method: get
HelloWorld2:
Type: AWS::Serverless::Function
Properties:
Handler: index.second_handler
Runtime: nodejs4.3
Role:
Fn::ImportValue:
!Join ['-', [!Ref 'ProjectId', !Ref 'AWS::Region', 'LambdaTrustRole']]
Events:
GetEvent:
Type: Api
Properties:
Path: /second
Method: get
위의 tamplate.yml 파일에서 "HelloWor ld "및"HelloWorld2 "구성을 지원합니다.
- 하여 HelloWorld 구성 "인덱스"하는 index.js의 파일명이고 first_handler하는 index.js이 파일의 방법 즉 "index.first_handler"로 "처리기"값을 포함한다.
- 마찬가지로 HelloWorld2 구성에는 "index"가 index.js의 파일 이름이고 "second_handler"가 index.js 파일의 메서드 인 "index.second_handler"라는 "Handler"값이 들어 있습니다.
결론 : 당신은 당신의하는 index.js (whatever.js) 파일에 람다 함수의 수를 지정할 수 있습니다
. 람다 함수를 식별하기 위해 적절한 핸들러 만 지정하면됩니다.
희망 사항입니다. 질문에 대한 답변입니다. 당신이 가진다면, 의심의 여지가 물어보십시오!
출처
2017-12-01 06:28:29
kit