我需要有关Java AWS-Lambda的帮助。我正在使用Lambda更新数据库。有cloudwatch事件触发器,并根据某些条件为更新数据库调用Lambda。我想在数据库更新后立即发送通知。我想从Lambda调用SNS服务。我正在使用以多因素身份验证运行的SNS帐户。请建议如何创建/设置Lambda以发送SNS。注意:我正在[[不查看“如何从SNS触发Lambda”。我正在查看如何从Java中的Lambda函数发送SNS。
// Publish a message to an Amazon SNS topic.
final String msg = "If you receive this message, publishing a message to an Amazon SNS topic works.";
final PublishRequest publishRequest = new PublishRequest(topicArn, msg);
final PublishResult publishResponse = snsClient.publish(publishRequest);
// Print the MessageId of the message.
System.out.println("MessageId: " + publishResponse.getMessageId());