aws python sns_允许AWS Lambda列出所有SNS主题

我有一个cloudformation模板来创建lambda函数和SNS主题。lambda函数执行一些处理并将结果发布到SNS主题。在

为了获得SNS主题的ARN,我使用boto3.client('sns').list_topics()函数,然后搜索我在模板中设置的SNS主题名。在

但是调用list_topics()API会给我带来以下错误:

An error occurred (AuthorizationError) when calling the ListTopics operation: User: arn:aws:sts::136732452473:assumed-role/test/severless-btc-update-PriceUpdateFunction-B38KNZMCBGB is not authorized to perform: SNS:ListTopics on resource: arn:aws:sns:eu-west-1:136732452473:*

如何向cloudformation模板YAML文件中的lambda资源添加ListTopics权限?在

这是我的云形成.yaml文件:AWSTemplateFormatVersion: "2010-09-09"

Transform: AWS::Serverless-2016-10-31

Description: Bitcoin daily update

Parameters:

PhoneNumber:

Type: String

Description: The phone number recipient of the update, in E.164 (e.g. +919876123456) format.

UTCHour:

Type: String

Default: 3

Description: The hour at which to send the update, in the UTC time zone.

Resources:

PriceUpdateFunction:

Type: AWS::Serverless::Function

Properties:

Handler: main.lambda_handler

Runtime: python3.6

Timeout: 5

CodeUri: main.py

Environment:

Variables:

PHONE_NUMBER: !Ref PhoneNumber

Events:

ScheduledEvent:

Type: Schedule

Properties:

Schedule: !Join [' ', ['cron(0', !Ref UTCHour, '* * ? *)']]

Policies:

- SNSPublishMessagePolicy:

TopicName: !GetAtt SNSTopic.TopicName

SNSTopic:

Type: "AWS::SNS::Topic"

Properties:

TopicName: "sendSMS"

DisplayName: "BitcoinPriceTopic"

Subscription:

-

Endpoint: !Ref PhoneNumber

Protocol: "sms"

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值