2020-10-31

How to update an Amazon S3 Bucket Policy via the AWS CLI?

I have a requirement to add a new line "arn:aws:sts::1262767:assumed-role/EC2-support-services" to an Amazon S3 bucket policy.

Something like this:

Before:

{
  "Version":"2012-10-17",
  "Statement":[
    {
      "Sid":"AddCannedAcl",
      "Effect":"Allow",
    "Principal": {"AWS": ["arn:aws:iam::111122223333:root","arn:aws:iam::444455556666:root"]},
      "Action":["s3:PutObject","s3:PutObjectAcl"],
      "Resource":"arn:aws:s3:::awsexamplebucket1/*",
      "Condition":{
     "StringNotLike": {
        "aws:arn": [
          "arn:aws:sts::1262767:assumed-role/GR_COF_AWS_Prod_Support/*"
        ]
      }       
     }
   
    }
  ]
}

After:

{
  "Version":"2012-10-17",
  "Statement":[
    {
      "Sid":"AddCannedAcl",
      "Effect":"Allow",
    "Principal": {"AWS": ["arn:aws:iam::111122223333:root","arn:aws:iam::444455556666:root"]},
      "Action":["s3:PutObject","s3:PutObjectAcl"],
      "Resource":"arn:aws:s3:::awsexamplebucket1/*",
      "Condition":{
     "StringNotLike": {
        "aws:arn": [
          "arn:aws:sts::1262767:assumed-role/GR_COF_AWS_Prod_Support/*",
           "arn:aws:sts::1262767:assumed-role/EC2-support-services"
        ]
      }       
     }
   
    }
  ]
}

What is the AWS CLI command I need to use to add this line?



from Recent Questions - Stack Overflow https://ift.tt/31ZnyMb
https://ift.tt/eA8V8J

No comments:

Post a Comment