Clo*_*ing 5 amazon-sns aws-lambda
我一直关注以下来自亚马逊的博客文章(场景3:从另一个帐户中的Amazon S3存储桶通知触发Lambda函数)关于授权Lambda函数用于各种用途.我想设置一个Lambda函数来接受来自外部帐户的SNS消息(带有lambda函数的acct外部).
https://aws.amazon.com/blogs/compute/easy-authorization-of-aws-lambda-functions/
我期望添加远程调用函数的权限,如下所示:
$ aws lambda add-permission \
--function-name MyFunction \
--region us-west-2 \
--statement-id Id-123 \
--action "lambda:InvokeFunction" \
--principal sns.amazonaws.com \
--source-arn arn:aws:sns:::<topic name> \
--source-account <account number> \
--profile adminuser
Run Code Online (Sandbox Code Playgroud)
然后我尝试转到我的SNS主题并将Lambda设置为端点,并在第一个帐户中输入lambda函数的远程ARN.这不能很好地工作,因为端点期望帐户中的函数具有arn ...
计划B:尝试通过CLI创建订阅以规避控制台中的限制...
aws sns --profile adminuser \
--region us-west-2 subscribe
--topic-arn arn:aws:sns:us-west-2:<account #>:<topic name>
--protocol lambda
--notification-endpoint arn:aws:lambda:us-west-2:<account id>:function:<lambda function name>
Run Code Online (Sandbox Code Playgroud)
响应:
A client error (AuthorizationError) occurred when calling the Subscribe operation: The account <account id> is not the owner of the lambda function arn:aws:lambda:us-west-2:<account id>:function:<function name>
有没有人能够从另一个帐户中的"远程"SNS调用Lambda函数?关于我可能出错的地方,我有点难过......根据博客文章中的说明,我完全期望一个远程SNS可以工作:
Note: Amazon SNS (Simple Notification Service) events sent to Lambda works the same way, with “sns.amazonaws.com” replacing “s3.amazonaws.com” as the principal.
如果提供者帐户授权拥有lambda的使用者帐户可以订阅SNS主题,则可以。这可以在主题页面下的“编辑主题策略”中完成。
这是允许lambda收听来自外部帐户的SNS主题的步骤的摘要:
之前对我有用的示例命令,适用于第4步:
aws sns subscribe --topic-arn <provider_sns_arn> --protocol lambda --notification-endpoint <consumer_lambda_arn> --profile consumer-IAM-account
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4006 次 |
| 最近记录: |