简体   繁体   中英

AWS policy condition operator 'NULL' in 'YAML'

How can I write the below JSON bucket policy in YAML?

"Policy": 
        {
            "Type" : "AWS::S3::BucketPolicy",
            "Properties" : {
                "Bucket" : { "Ref" : "Bucket" },
                "PolicyDocument" : {
                    "Statement":[
                        {
                            "Action":["s3:PutObject"],
                            "Effect": "Deny",
                            "Resource": { "Fn::Join" : ["", ["arn:aws:s3:::", { "Ref" : "Bucket" } , "/*" ]]},
                            "Principal":"*",
                            "Condition":{
                                "Null": {
                                    "s3:x-amz-server-side-encryption": "true"
                                },
                                "StringNotEquals":{
                                    "s3:x-amz-server-side-encryption": "AES256"
                                }
                            }
                        }
                    ]
                }
            }
        },

My main concern is with the 'NULL' condition operator. How is it written in yaml? I tried AWS::NoValue but doesn't help. I keep getting error - 'Invalid condition prefix: AWS'. If I use NULL or 'NULL' the error is - 'Malformed'.

So the syntax for IAM Policy "Null" condition in YAML is as follows:

            Condition:
              'Null':
                's3:x-amz-server-side-encryption': 'true'

I've translated JSON from this page to YAML using CloudFormation designer -- added IAM Policy to the designer and filled JSON version with example from that page. Then switched to YAML and got the part I needed.

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