Change S3 bucket policy programmatically - boto3 ideally

Viewed 24

All accounts in our company need to access a specific bucket. Whenever a new account is created the policies of that bucket are changed manually by adding a new account e.g.:

 {
        "Sid": "AllowOtherAccountsAccess",
        "Effect": "Allow",
        "Principal": {
            "AWS": [
                "arn:aws:iam::111111111111:root",
                "arn:aws:iam::222222222222:root",
   
            ]
        },
        "Action": [
            "s3:GetObject",
            "s3:ListBucket"

How would I add automatically a new account with ID 3333333333333 to the bucket policies? Couldn't find anything in Boto3 that would allow it.

0 Answers
Related