AWS Eventbridge 名称参数
AWS Eventbridge Name param
我正在使用此库 https://www.npmjs.com/package/@aws-sdk/client-eventbridge 从我们拥有的 Typescript 应用程序内部实施 AWS v3 事件桥,但是当我 运行 此代码时:
import { EventBridgeClient, ActivateEventSourceCommand } from "@aws-sdk/client-eventbridge";
const client = new EventBridgeClient({ region: process.env.AWS_REGION });
// this is the BODY section of what is sent
const dataToSend = {
email_address: user_email,
status: action,
merge_fields: {
FNAME: user_givenName,
LNAME: user_familyName,
},
interests: interestId,
};
const entry = {
Entries: [
{
EventBusName: "Subscriptions",
Source: "custom.subscriptions",
DetailType: "subscription",
Detail: JSON.stringify(dataToSend),
},
],
};
const params = {
Name: "TestBus",
Description: "data bus",
Entry: JSON.stringify(entry),
};
const command = new ActivateEventSourceCommand(params);
try {
const data = await client.send(command);
// process data.
console.log("data>>", data);
} catch (error) {
// error handling.
console.log("err>>", error);
}
我收到错误:
err>> ValidationException:检测到 1 个验证错误:'name' 处的值 'TestBus' 未能满足约束:成员必须满足正则表达式模式:aws.partner( /[.-_A-Za-z0-9]+){2,}
运行 通过此站点的正则表达式:https://www.regextester.com/ 它显示为正斜杠无效。
查看提供的代码,我可以看到 'Name' 参数应该是一个字符串,我查看的其他示例与我正在使用的名称相似。我的代码有什么问题?
看来我有两个问题:
EventBusName: "Subscriptions",
应该是:
EventBusName: "default",
(或使用提供的名称创建新的 EventBus)和 ActivateEventSourceCommand
应该是 PutEventsCommand
删除 params
const 并使用以下命令:
const command = new PutEventsCommand(entry);
我正在使用此库 https://www.npmjs.com/package/@aws-sdk/client-eventbridge 从我们拥有的 Typescript 应用程序内部实施 AWS v3 事件桥,但是当我 运行 此代码时:
import { EventBridgeClient, ActivateEventSourceCommand } from "@aws-sdk/client-eventbridge";
const client = new EventBridgeClient({ region: process.env.AWS_REGION });
// this is the BODY section of what is sent
const dataToSend = {
email_address: user_email,
status: action,
merge_fields: {
FNAME: user_givenName,
LNAME: user_familyName,
},
interests: interestId,
};
const entry = {
Entries: [
{
EventBusName: "Subscriptions",
Source: "custom.subscriptions",
DetailType: "subscription",
Detail: JSON.stringify(dataToSend),
},
],
};
const params = {
Name: "TestBus",
Description: "data bus",
Entry: JSON.stringify(entry),
};
const command = new ActivateEventSourceCommand(params);
try {
const data = await client.send(command);
// process data.
console.log("data>>", data);
} catch (error) {
// error handling.
console.log("err>>", error);
}
我收到错误:
err>> ValidationException:检测到 1 个验证错误:'name' 处的值 'TestBus' 未能满足约束:成员必须满足正则表达式模式:aws.partner( /[.-_A-Za-z0-9]+){2,}
运行 通过此站点的正则表达式:https://www.regextester.com/ 它显示为正斜杠无效。
查看提供的代码,我可以看到 'Name' 参数应该是一个字符串,我查看的其他示例与我正在使用的名称相似。我的代码有什么问题?
看来我有两个问题:
EventBusName: "Subscriptions",
应该是:
EventBusName: "default",
(或使用提供的名称创建新的 EventBus)和 ActivateEventSourceCommand
应该是 PutEventsCommand
删除 params
const 并使用以下命令:
const command = new PutEventsCommand(entry);