使用 CloudFormation 堆栈的名称在 AWS 策略中添加条件

Adding a condition in an AWS policy using the name of the CloudFormation stacks

我正在为 AWS 上的用户编写策略,以便它可以对堆栈名称包含 foo 的堆栈做任何想做的事情。我查看了文档并找到了有关 Condition 值的信息,但我没有找到如何使用其中的堆栈名称。

我的政策目前是这样的:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "private value",
            "Effect": "Allow",
            "Action": [
                "cloudformation:*"
            ],
            "Resource": [
                "*"
            ],
            "Condition": {
                "StringLike": {
                    "I do not know what to write here": "foo"
                }
            }
        }
    ]
}

AWS 文档很难用,我知道如果我使用的是 s3 buckets 而不是 CloudFormation 堆栈,我应该怎么做。

这里不需要条件。您可以简单地设置正确的资源。

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "private value",
            "Effect": "Allow",
            "Action": [
                "cloudformation:*"
            ],
            "Resource": [
                "arn:aws:cloudformation:*:*:stack/foo-*/*"
            ]
        }
    ]
}

如果有帮助请告诉我 ;)