简体   繁体   中英

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

I am writing a policy for a user on AWS so that it can do whatever it want with stacks that have a stack name containing foo . I have looked at the documentation and found information about the Condition value but I did not find how to use the name of the stack in it.

My policy currently looks like that:

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

The AWS documentation is hard to use, I know what I should do if I was working with s3 buckets but not for CloudFormation stacks.

Condition is not needed here. You can simply set the right resource.

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

Let me know if this helps ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM