AWS步骤函数状态。Format不使用策略
我有一个步骤函数任务,我尝试根据作为输入传递的动态值设置 SQS 队列策略。不幸的是,每当我执行该步骤时它都会完成,但它分配给 Q 的策略文档无效,并且“State.Format”不起作用。
"SetQueueAttributes": {
"Type": "Task",
"Parameters": {
"Attributes": {
"Policy": {
"Version": "2008-10-17",
"Id": "__default_policy_ID",
"Statement": [
{
"Sid": "Allow-SNS-SendMessage",
"Effect": "Allow",
"Principal": {
"Service": "sns.amazonaws.com"
},
"Action": "sqs:SendMessage",
"Resource": "States.Format('arn:aws:sqs:us-east-1:{}:{}', $.Account, $.tenantId)",
"Condition": {
"ArnEquals": {
"aws:SourceArn": "States.Format('arn:aws:sns:us-east-1:{}:my-execution-results', $.Account)"
}
}
}
]
}
},
"QueueUrl.$": "$.CreatQueueResult.QueueUrl"
},
"Resource": "arn:aws:states:::aws-sdk:sqs:setQueueAttributes",
"End": true
}
我在这里做错了什么吗?有可能做到这一点吗?
I have a step function task where I try to set an SQS queue policy based on dynamic values passed as input. Unfortunately, it completes whenever I execute the step, but the policy document it assigns to the Q is invalid, and "State.Format" does not work.
"SetQueueAttributes": {
"Type": "Task",
"Parameters": {
"Attributes": {
"Policy": {
"Version": "2008-10-17",
"Id": "__default_policy_ID",
"Statement": [
{
"Sid": "Allow-SNS-SendMessage",
"Effect": "Allow",
"Principal": {
"Service": "sns.amazonaws.com"
},
"Action": "sqs:SendMessage",
"Resource": "States.Format('arn:aws:sqs:us-east-1:{}:{}', $.Account, $.tenantId)",
"Condition": {
"ArnEquals": {
"aws:SourceArn": "States.Format('arn:aws:sns:us-east-1:{}:my-execution-results', $.Account)"
}
}
}
]
}
},
"QueueUrl.quot;: "$.CreatQueueResult.QueueUrl"
},
"Resource": "arn:aws:states:::aws-sdk:sqs:setQueueAttributes",
"End": true
}
Am I doing something wrong here? is it even possible to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

我自己发现 States.Format 就像 JSON 路径选择器一样,因此任何策略键都必须以 .$ 结尾,以便 States.Format 正常工作
I figured it out myself States.Format is just like JSON path selector so any policy key must end with .$ in order for States.Format to work properly