Murtaza Heyderi:
can anybody help me with modifying s3 bucket policy using boto3. I don’t want to put new policy I just want to add a new statement to the existing policy. Any help would be appreciated
Alistair Mackay:
I think you need to do it in 3 steps
- Call https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3/client/get_bucket_policy.html|get_bucket_policy to retrieve the existing policy
- Modify the policy document
- Call https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3/client/put_bucket_policy.html|put_bucket_policy to set the new, adjusted policy.
You are advised to create a test bucket with the same policy as the existing one on which to test your code.
Murtaza Heyderi:
thank you!