不同 SMS 号码的 AWS 角色策略

问题描述 投票:0回答:1

我需要一些帮助来在 AWS 中设置短信角色策略。

基本上我正在编写 lambda 函数来发送短信,但发送到哪个号码取决于日期。

例如:我现在有2个号码。

const myMobile = 333;
const partnerMobile = 444;

我将在 lambda 中做一个逻辑,看看在什么条件下短信将发送到

myMobile
partnerMobile

我知道我可以创建一个带有访问权限和密钥的新

IAM user
,这会起作用,但由于它是aws lambda,所以看起来有点太多了,因为aws产品可以使用角色和权限来相互访问,而无需创建额外的键。

我尝试使用

topic
subscription
但如果使用
topic
那么政策看起来像

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": "sns:Publish",
            "Resource": "arn:aws:sns:us-west-2:##73038361###:SMS-Some-topic"
        }
    ]
}
But this wouldn't work though, because it'll publish too all numbers under the topic which means both `myMobile` and `parterMobile` will get the number but I only want one of them to get it when logic matches.

I know by doing this below would work
```json
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": "sns:Publish",
            "Resource": "*"
        }
    ]
}

但是感觉使用通配符有点太多了?所以想知道是否还有其他不使用通配符的选项。如果没有其他选择,那么我可以坚持使用通配符,但再次想知道是否还有其他选择。

提前感谢大家的任何建议/建议。

amazon-web-services sms amazon-sns policy
1个回答
0
投票

您可以在策略中定义多个资源,而无需使用通配符。您只需添加括号即可:

{
"Version": "2012-10-17",
"Statement": [
    {
        "Sid": "VisualEditor0",
        "Effect": "Allow",
        "Action": "sns:Publish",
        "Resource": ["arn:aws:sns:us-west-2:##73038361###:SMS-Some-topic",
                     "arn:aws:sns:us-west-2:##73038361###:SMS-Other-topic"]
    }
]

}

© www.soinside.com 2019 - 2024. All rights reserved.