【发布时间】:2021-10-24 16:07:51
【问题描述】:
我对 AWS Lambda 的 aws nodejs sdk 有疑问。从官方文档中,我尝试使用 lambda 获取 aws\ssm 参数。
文档:[https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-ssm/classes/getparameterscommand.html
这是我的 Lambda 代码
import { SSMClient, GetParametersCommand } from "@aws-sdk/client-ssm"
const config = { region: "eu-central-1"}
exports.handler = async (event, context) => {
const client = new SSMClient({ region: config.region});
const command = new GetParametersCommand({Names: ["/my-app/dev/db-url"]});
const response = await client.send(command);
console.log(response);
};
但是当运行 aws lambda 函数时,它通过错误给我如下:
"errorType": "Runtime.UserCodeSyntaxError",
"errorMessage": "SyntaxError: Cannot use import statement outside a module"
我是 JS 世界的新手。有人知道它为什么抱怨吗?
问候
【问题讨论】:
标签: node.js amazon-web-services aws-lambda devops