本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
sam 本地生成事件
从不同的事件来源(例如 Amazon S3、Amazon Amazon API Gateway 和 Amazon SNS)生成示例有效负载。这些有效负载包含事件源发送给您的 Lambda 函数的信息。
使用方法:
sam local generate-event [OPTIONS] COMMAND [ARGS]...
示例:
Generate the event that S3 sends to your Lambda function when a new object is uploaded sam local generate-event s3 [put/delete] # You can even customize the event by adding parameter flags. To find which flags apply to your command, run: sam local generate-event s3 [put/delete] --help # Then you can add in those flags that you wish to customize using sam local generate-event s3 [put/delete] --bucket <bucket> --key <key> # After you generate a sample event, you can use it to test your Lambda function locally sam local generate-event s3 [put/delete] --bucket <bucket> --key <key> | sam local invoke -e - <function logical id>
选项:
| 选项 | 描述 |
|---|---|
--config-file PATH |
配置文件的路径和文件名,包含要使用的默认参数值。默认值为项目目录根目录中的 “samconfig.toml”。有关配置文件的详细信息,请参阅 Amazon SAM CLI 配置文件。 |
--config-env TEXT |
指定配置文件中要使用的默认参数值的环境名称。默认值为 “默认值”。有关配置文件的详细信息,请参阅 Amazon SAM CLI 配置文件。 |
--help |
显示此消息并退出。 |
命令:
-
alb -
alexa-skills-kit -
alexa-smart-home -
apigateway -
batch -
cloudformation -
cloudfront -
cloudwatch -
codecommit -
codepipeline -
cognito -
config -
dynamodb -
kinesis -
lex -
lex-v2 -
rekognition -
s3 -
ses -
sns -
sqs -
stepfunctions -
workmail