AWS SNS 应该触发我的 lambda,但不会 [英] AWS SNS ought to trigger my lambda, but does not

查看:38
本文介绍了AWS SNS 应该触发我的 lambda,但不会的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个通过 apex 创建的 AWS lambda 函数.我还通过 terraform 创建了 SNS 主题和订阅.

I have an AWS lambda function that I created via apex. I've also created a SNS topic and a subscription through terraform.

我的主题是:arn:aws:sns:ap-southeast-1:178284945954:fetch_realm_auctions

我有一个订阅:arn:aws:sns:ap-southeast-1:178284945954:fetch_realm_auctions:2da1d182-946d-4afd-91cb-1ed3453c5d86 带有 lambda类型和端点是:arn:aws:lambda:ap-southeast-1:178284945954:function:wowauctions_get_auction_data

I have a subscription: arn:aws:sns:ap-southeast-1:178284945954:fetch_realm_auctions:2da1d182-946d-4afd-91cb-1ed3453c5d86 with a lambda type and the endpoint is: arn:aws:lambda:ap-southeast-1:178284945954:function:wowauctions_get_auction_data

我已经确认这是正确的函数 ARN.一切似乎都连接正确:

I've confirmed this is the correct function ARN. Everything seems wired up correctly:

我手动触发 SNS:

aws sns publish 
  --topic-arn arn:aws:sns:ap-southeast-1:178284945954:fetch_realm_auctions 
  --message '{"endpoint": "https://us.api.battle.net", "realm": "spinebreaker"}'

它返回消息 ID 但没有调用发生.为什么?

It returns the message ID but no invocation happens. Why?

推荐答案

我添加了一个内联策略以允许调用 lambda:

I added an inline policy to allow the lambda to be invoked:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Stmt1474873816000",
            "Effect": "Allow",
            "Action": [
                "lambda:InvokeFunction"
            ],
            "Resource": [
                "arn:aws:lambda:ap-southeast-1:178284945954:function:wowauctions_get_auction_data"
            ]
        }
    ]
}

它现在可以工作了.

这篇关于AWS SNS 应该触发我的 lambda,但不会的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆