Amazon web services 如何将消息发布到另一个AWS帐户中的推送通知端点?
我想在另一个AWS帐户中使用SNS推送通知服务发送推送通知 这是我的密码:Amazon web services 如何将消息发布到另一个AWS帐户中的推送通知端点?,amazon-web-services,amazon-sns,Amazon Web Services,Amazon Sns,我想在另一个AWS帐户中使用SNS推送通知服务发送推送通知 这是我的密码: import boto3 import json region = 'my-region' endpoint = 'arn:aws:sns:my-region:123456789123:endpoint/APNS_SANDBOX/APNS_Dev/f8deq51b-9007-3139-9n66-0da63z4ca615' message_data = { 'foo': 'bar' } sns = boto3.
import boto3
import json
region = 'my-region'
endpoint = 'arn:aws:sns:my-region:123456789123:endpoint/APNS_SANDBOX/APNS_Dev/f8deq51b-9007-3139-9n66-0da63z4ca615'
message_data = {
'foo': 'bar'
}
sns = boto3.client('sns', region_name=region)
response = sns.publish(
TargetArn=endpoint,
Message=str(json.dumps(message_data)),
MessageStructure='json'
)
请注意,代码在AWS帐户(987654321987
)下运行,该帐户不同于123456789123
上述代码的错误消息为
botocore.errorfactory.AuthorizationErrorException: An error occurred (AuthorizationError) when calling the Publish operation: User: arn:aws:iam::987654321987:user/my.name is not authorized to perform: SNS:Publish on resource: arn:aws:sns:my-region:123456789123:app/APNS_SANDBOX/APNS_Dev
有没有办法授权987654321987
将消息发布到123456789123
帐户
没用。因为它讨论了如何在另一个帐户中发布到AWS SNS“主题”
这与推送通知端点无关。您可以检查一下
arn:aws:iam::987654321987:user/my.name
是否有足够的权限发布到端点
<代码>IAM以及资源级别策略
都应被允许。如果您使用的是组织
请检查是否附加了用于控制权限的SCP。