我有一个带有节点的 lambda,对于本地部署,我使用的是 SAM CLI。此 lambda 需要 SSM 参数存储中的一些参数才能连接到数据库。除了区域之外,我还将 AWS_ACCES_KEY_ID 和 AWS_SECRET_ACCESS_KEY 配置为环境变量。执行本地 lamda 时,我没有收到任何错误,因为它转到 aws,但它没有给我带来任何东西。这不是代码问题,因为如果我已经在 aws 中部署它,它可以正常工作。我不知道是否需要进行其他配置才能使其正常工作。
模板.yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
ciencuadras-appraisal-request
Sample SAM Template for ciencuadras-appraisal-request
Parameters:
Stage:
Type: String
Default: dev
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 3
Resources:
ApiDeployment:
Type: AWS::Serverless::Api
Properties:
StageName: !Ref Stage
RequestAppraisalFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: dist/
Handler: main.handler
Runtime: nodejs14.x
Environment:
Variables:
AWS_REGION: 'us-east-1'
Events:
RequestAppraisal:
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Properties:
Path: /sendemail-new-appraisal
Method: post
RestApiId: !Ref ApiDeployment
谢谢