【发布时间】:2022-01-18 08:21:39
【问题描述】:
我能够创建一个 SQS 队列 + lambda 函数并通过触发器/订阅连接它们。
如何通过 CDK 创建主题过滤器?
我可以像这样创建主题、lambda 和触发器/订阅:
const queue = new sqs.Queue(this, 'OurSqsQueue', {
queueName: 'OurSQSQueue',
});
const lambdaFunction = new lambda.Function(this,'test', {
code: lambda.Code.fromAsset('src'),
handler: index.lambdaHandler,
functionName: 'test',
runtime: lambda.Runtime.NODEJS_14_X,
});
const eventSource = new lambdaEventSources.SqsEventSource(queue);
lambdaFunction.addEventSource(eventSource);
According to the docs Amazon SQS 主题订阅者接收发布到该主题的每条消息。要接收消息的子集,订阅者必须为主题订阅分配过滤策略。
【问题讨论】:
标签: amazon-web-services aws-cdk