Search code examples
amazon-web-servicesamazon-s3policyaws-policies

AWS S3 Bucket Policy to allow only lowercase files


Is it possible to limit s3 bucket to lowercase files/directories only?

Some downstream systems are case insensitive so I want to prevent any issues.

There's a Lambda workaround, but is it possible to specify this requirement as a bucket policy?

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Enforce lower-case",
            "Effect": "Deny",
            "Principal":"*",
            "Action": "s3:PutObject",
            "Resource": "arn:aws:s3:::mybucket/*",
            "Condition": {
                "StringNotEquals": {
                    "s3:KeyName": "lower(s3:KeyName)"
                }
            }
        }
    ]
}

Solution

  • No, that is not possible because:

    • String manipulation isn't allowed in IAM policy
    • IAM string condition operators do not support regular expressions