简体   繁体   中英

Limit AWS S3 Bucket to only Lambda access

I am using an AWS S3 bucket to hold configuration files for Java AWS Lambdas. How do I configure the bucket to only allow access to any lambda function and nothing else?

You need to add s3 bucket policy for account 123456789012 in region us-east-1 -

   {
     "Id": "Policy1498253351771",
     "Version": "2012-10-17",
     "Statement": [
        {
           "Sid": "Stmt1498253327847",
           "Action": [
                        "s3:GetObject",
                        "s3:PutObject"
                     ],
           "Effect": "Allow",
           "Resource": "arn:aws:s3:::<bucket_name>/<prefix>",
           "Principal": {
           "AWS": [
                 "arn:aws:lambda:us-east-1:123456789012:function:*"
                ]
           }
        }
    ]
 }

Above is a general policy for all lambda functions.

If you need to generate a more granular policy as per your usecase , you can try AWS Policy Generator

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